Skip to content

Commit 1c22c4b

Browse files
Recognize optional comma's in class_def
1 parent d211ad2 commit 1c22c4b

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/lpython/parser/parser.yy

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -707,12 +707,12 @@ class_def
707707
$$ = CLASS_01($1, $3, $5, @$); }
708708
| decorators_opt KW_CLASS id "(" expr_list_opt ")" ":" body_stmts {
709709
$$ = CLASS_02($1, $3, $5, $8, @$); }
710-
| decorators_opt KW_CLASS id "(" expr_list "," keyword_items ")"
711-
":" body_stmts { $$ = CLASS_03($1, $3, $5, $7, $10, @$); }
710+
| decorators_opt KW_CLASS id "(" expr_list "," keyword_items comma_opt ")"
711+
":" body_stmts { $$ = CLASS_03($1, $3, $5, $7, $11, @$); }
712712
| decorators_opt KW_CLASS id "(" keyword_items "," expr_list ")"
713713
":" body_stmts { $$ = CLASS_03($1, $3, $7, $5, $10, @$); }
714-
| decorators_opt KW_CLASS id "(" keyword_items ")" ":" body_stmts {
715-
$$ = CLASS_04($1, $3, $5, $8, @$); }
714+
| decorators_opt KW_CLASS id "(" keyword_items comma_opt ")" ":" body_stmts
715+
{ $$ = CLASS_04($1, $3, $5, $9, @$); }
716716
;
717717

718718
async_func_def
@@ -770,7 +770,7 @@ while_statement
770770
;
771771

772772
expr_list_opt
773-
: expr_list { $$ = $1; }
773+
: expr_list comma_opt { $$ = $1; }
774774
| %empty { LIST_NEW($$); }
775775
;
776776

@@ -1002,7 +1002,6 @@ expr
10021002
| function_call { $$ = $1; }
10031003
| subscript { $$ = $1; }
10041004
| "[" expr_list_opt "]" { $$ = LIST($2, @$); }
1005-
| "[" expr_list "," "]" { $$ = LIST($2, @$); }
10061005
| "{" expr_list "}" { $$ = SET($2, @$); }
10071006
| "{" expr_list "," "}" { $$ = SET($2, @$); }
10081007
| expr "." id { $$ = ATTRIBUTE_REF($1, $3, @$); }

0 commit comments

Comments
 (0)