@@ -183,9 +183,9 @@ while_stmt[stmt_ty]:
183
183
184
184
for_stmt[stmt_ty]:
185
185
| 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] {
187
187
_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] {
189
189
CHECK_VERSION(stmt_ty, 5, "Async for loops are", _PyAST_AsyncFor(t, ex, b, el, NEW_TYPE_COMMENT(p, tc), EXTRA)) }
190
190
| invalid_for_target
191
191
@@ -488,7 +488,7 @@ class_def[stmt_ty]:
488
488
| class_def_raw
489
489
class_def_raw[stmt_ty]:
490
490
| invalid_class_def_raw
491
- | 'class' a=NAME b=['(' z=[arguments] ')' { z }] && ':' c=block {
491
+ | 'class' a=NAME b=['(' z=[arguments] ')' { z }] ':' c=block {
492
492
_PyAST_ClassDef(a->v.Name.id,
493
493
(b) ? ((expr_ty) b)->v.Call.args : NULL,
494
494
(b) ? ((expr_ty) b)->v.Call.keywords : NULL,
@@ -954,8 +954,8 @@ invalid_import_from_targets:
954
954
RAISE_SYNTAX_ERROR("trailing comma not allowed without surrounding parentheses") }
955
955
956
956
invalid_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 ':'") }
959
959
invalid_with_stmt_indent:
960
960
| [ASYNC] a='with' ','.(expression ['as' star_target])+ ':' NEWLINE !INDENT {
961
961
RAISE_INDENTATION_ERROR("expected an indented block after 'with' statement on line %d", a->lineno) }
@@ -979,11 +979,11 @@ invalid_except_stmt_indent:
979
979
RAISE_INDENTATION_ERROR("expected an indented block after 'except' statement on line %d", a->lineno) }
980
980
| a='except' ':' NEWLINE !INDENT { RAISE_INDENTATION_ERROR("expected an indented block after 'except' statement on line %d", a->lineno) }
981
981
invalid_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 ':'") ) }
983
983
| a="match" subject=subject_expr ':' NEWLINE !INDENT {
984
984
RAISE_INDENTATION_ERROR("expected an indented block after 'match' statement on line %d", a->lineno) }
985
985
invalid_case_block:
986
- | "case" patterns guard? !':' { RAISE_SYNTAX_ERROR("expected ':'") }
986
+ | "case" patterns guard? NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
987
987
| a="case" patterns guard? ':' NEWLINE !INDENT {
988
988
RAISE_INDENTATION_ERROR("expected an indented block after 'case' statement on line %d", a->lineno) }
989
989
invalid_as_pattern:
@@ -1012,12 +1012,14 @@ invalid_while_stmt:
1012
1012
| a='while' named_expression ':' NEWLINE !INDENT {
1013
1013
RAISE_INDENTATION_ERROR("expected an indented block after 'while' statement on line %d", a->lineno) }
1014
1014
invalid_for_stmt:
1015
+ | [ASYNC] 'for' star_targets 'in' star_expressions NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
1015
1016
| [ASYNC] a='for' star_targets 'in' star_expressions ':' NEWLINE !INDENT {
1016
1017
RAISE_INDENTATION_ERROR("expected an indented block after 'for' statement on line %d", a->lineno) }
1017
1018
invalid_def_raw:
1018
1019
| [ASYNC] a='def' NAME '(' [params] ')' ['->' expression] ':' NEWLINE !INDENT {
1019
1020
RAISE_INDENTATION_ERROR("expected an indented block after function definition on line %d", a->lineno) }
1020
1021
invalid_class_def_raw:
1022
+ | 'class' NAME ['(' [arguments] ')'] NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
1021
1023
| a='class' NAME ['('[arguments] ')'] ':' NEWLINE !INDENT {
1022
1024
RAISE_INDENTATION_ERROR("expected an indented block after class definition on line %d", a->lineno) }
1023
1025
0 commit comments