@@ -183,9 +183,9 @@ while_stmt[stmt_ty]:
183183
184184for_stmt[stmt_ty]:
185185 | invalid_for_stmt
186- | 'for' t=star_targets 'in' ~ ex=star_expressions && ':' tc=[TYPE_COMMENT] b=block el=[else_block] {
186+ | 'for' t=star_targets 'in' ~ ex=star_expressions ':' tc=[TYPE_COMMENT] b=block el=[else_block] {
187187 _PyAST_For(t, ex, b, el, NEW_TYPE_COMMENT(p, tc), EXTRA) }
188- | ASYNC 'for' t=star_targets 'in' ~ ex=star_expressions && ':' tc=[TYPE_COMMENT] b=block el=[else_block] {
188+ | ASYNC 'for' t=star_targets 'in' ~ ex=star_expressions ':' tc=[TYPE_COMMENT] b=block el=[else_block] {
189189 CHECK_VERSION(stmt_ty, 5, "Async for loops are", _PyAST_AsyncFor(t, ex, b, el, NEW_TYPE_COMMENT(p, tc), EXTRA)) }
190190 | invalid_for_target
191191
@@ -488,7 +488,7 @@ class_def[stmt_ty]:
488488 | class_def_raw
489489class_def_raw[stmt_ty]:
490490 | invalid_class_def_raw
491- | 'class' a=NAME b=['(' z=[arguments] ')' { z }] && ':' c=block {
491+ | 'class' a=NAME b=['(' z=[arguments] ')' { z }] ':' c=block {
492492 _PyAST_ClassDef(a->v.Name.id,
493493 (b) ? ((expr_ty) b)->v.Call.args : NULL,
494494 (b) ? ((expr_ty) b)->v.Call.keywords : NULL,
@@ -954,8 +954,8 @@ invalid_import_from_targets:
954954 RAISE_SYNTAX_ERROR("trailing comma not allowed without surrounding parentheses") }
955955
956956invalid_with_stmt:
957- | [ASYNC] 'with' ','.(expression ['as' star_target])+ && ':'
958- | [ASYNC] 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' && ':'
957+ | [ASYNC] 'with' ','.(expression ['as' star_target])+ NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
958+ | [ASYNC] 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
959959invalid_with_stmt_indent:
960960 | [ASYNC] a='with' ','.(expression ['as' star_target])+ ':' NEWLINE !INDENT {
961961 RAISE_INDENTATION_ERROR("expected an indented block after 'with' statement on line %d", a->lineno) }
@@ -979,11 +979,11 @@ invalid_except_stmt_indent:
979979 RAISE_INDENTATION_ERROR("expected an indented block after 'except' statement on line %d", a->lineno) }
980980 | a='except' ':' NEWLINE !INDENT { RAISE_INDENTATION_ERROR("expected an indented block after 'except' statement on line %d", a->lineno) }
981981invalid_match_stmt:
982- | "match" subject_expr !':' { CHECK_VERSION(void*, 10, "Pattern matching is", RAISE_SYNTAX_ERROR("expected ':'") ) }
982+ | "match" subject_expr NEWLINE { CHECK_VERSION(void*, 10, "Pattern matching is", RAISE_SYNTAX_ERROR("expected ':'") ) }
983983 | a="match" subject=subject_expr ':' NEWLINE !INDENT {
984984 RAISE_INDENTATION_ERROR("expected an indented block after 'match' statement on line %d", a->lineno) }
985985invalid_case_block:
986- | "case" patterns guard? !':' { RAISE_SYNTAX_ERROR("expected ':'") }
986+ | "case" patterns guard? NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
987987 | a="case" patterns guard? ':' NEWLINE !INDENT {
988988 RAISE_INDENTATION_ERROR("expected an indented block after 'case' statement on line %d", a->lineno) }
989989invalid_as_pattern:
@@ -1012,12 +1012,14 @@ invalid_while_stmt:
10121012 | a='while' named_expression ':' NEWLINE !INDENT {
10131013 RAISE_INDENTATION_ERROR("expected an indented block after 'while' statement on line %d", a->lineno) }
10141014invalid_for_stmt:
1015+ | [ASYNC] 'for' star_targets 'in' star_expressions NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
10151016 | [ASYNC] a='for' star_targets 'in' star_expressions ':' NEWLINE !INDENT {
10161017 RAISE_INDENTATION_ERROR("expected an indented block after 'for' statement on line %d", a->lineno) }
10171018invalid_def_raw:
10181019 | [ASYNC] a='def' NAME '(' [params] ')' ['->' expression] ':' NEWLINE !INDENT {
10191020 RAISE_INDENTATION_ERROR("expected an indented block after function definition on line %d", a->lineno) }
10201021invalid_class_def_raw:
1022+ | 'class' NAME ['(' [arguments] ')'] NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
10211023 | a='class' NAME ['('[arguments] ')'] ':' NEWLINE !INDENT {
10221024 RAISE_INDENTATION_ERROR("expected an indented block after class definition on line %d", a->lineno) }
10231025
0 commit comments