@@ -249,7 +249,7 @@ class_def[stmt_ty]:
249249
250250class_def_raw[stmt_ty]:
251251 | invalid_class_def_raw
252- | 'class' a=NAME b=['(' z=[arguments] ')' { z }] && ':' c=block {
252+ | 'class' a=NAME b=['(' z=[arguments] ')' { z }] ':' c=block {
253253 _PyAST_ClassDef(a->v.Name.id,
254254 (b) ? ((expr_ty) b)->v.Call.args : NULL,
255255 (b) ? ((expr_ty) b)->v.Call.keywords : NULL,
@@ -379,9 +379,9 @@ while_stmt[stmt_ty]:
379379
380380for_stmt[stmt_ty]:
381381 | invalid_for_stmt
382- | 'for' t=star_targets 'in' ~ ex=star_expressions && ':' tc=[TYPE_COMMENT] b=block el=[else_block] {
382+ | 'for' t=star_targets 'in' ~ ex=star_expressions ':' tc=[TYPE_COMMENT] b=block el=[else_block] {
383383 _PyAST_For(t, ex, b, el, NEW_TYPE_COMMENT(p, tc), EXTRA) }
384- | ASYNC 'for' t=star_targets 'in' ~ ex=star_expressions && ':' tc=[TYPE_COMMENT] b=block el=[else_block] {
384+ | ASYNC 'for' t=star_targets 'in' ~ ex=star_expressions ':' tc=[TYPE_COMMENT] b=block el=[else_block] {
385385 CHECK_VERSION(stmt_ty, 5, "Async for loops are", _PyAST_AsyncFor(t, ex, b, el, NEW_TYPE_COMMENT(p, tc), EXTRA)) }
386386 | invalid_for_target
387387
@@ -1231,8 +1231,8 @@ invalid_import_from_targets:
12311231 RAISE_SYNTAX_ERROR("trailing comma not allowed without surrounding parentheses") }
12321232
12331233invalid_with_stmt:
1234- | [ASYNC] 'with' ','.(expression ['as' star_target])+ && ':'
1235- | [ASYNC] 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' && ':'
1234+ | [ASYNC] 'with' ','.(expression ['as' star_target])+ NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
1235+ | [ASYNC] 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
12361236invalid_with_stmt_indent:
12371237 | [ASYNC] a='with' ','.(expression ['as' star_target])+ ':' NEWLINE !INDENT {
12381238 RAISE_INDENTATION_ERROR("expected an indented block after 'with' statement on line %d", a->lineno) }
@@ -1262,11 +1262,11 @@ invalid_except_star_stmt_indent:
12621262 | a='except' '*' expression ['as' NAME ] ':' NEWLINE !INDENT {
12631263 RAISE_INDENTATION_ERROR("expected an indented block after 'except*' statement on line %d", a->lineno) }
12641264invalid_match_stmt:
1265- | "match" subject_expr !':' { CHECK_VERSION(void*, 10, "Pattern matching is", RAISE_SYNTAX_ERROR("expected ':'") ) }
1265+ | "match" subject_expr NEWLINE { CHECK_VERSION(void*, 10, "Pattern matching is", RAISE_SYNTAX_ERROR("expected ':'") ) }
12661266 | a="match" subject=subject_expr ':' NEWLINE !INDENT {
12671267 RAISE_INDENTATION_ERROR("expected an indented block after 'match' statement on line %d", a->lineno) }
12681268invalid_case_block:
1269- | "case" patterns guard? !':' { RAISE_SYNTAX_ERROR("expected ':'") }
1269+ | "case" patterns guard? NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
12701270 | a="case" patterns guard? ':' NEWLINE !INDENT {
12711271 RAISE_INDENTATION_ERROR("expected an indented block after 'case' statement on line %d", a->lineno) }
12721272invalid_as_pattern:
@@ -1295,13 +1295,15 @@ invalid_while_stmt:
12951295 | a='while' named_expression ':' NEWLINE !INDENT {
12961296 RAISE_INDENTATION_ERROR("expected an indented block after 'while' statement on line %d", a->lineno) }
12971297invalid_for_stmt:
1298+ | [ASYNC] 'for' star_targets 'in' star_expressions NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
12981299 | [ASYNC] a='for' star_targets 'in' star_expressions ':' NEWLINE !INDENT {
12991300 RAISE_INDENTATION_ERROR("expected an indented block after 'for' statement on line %d", a->lineno) }
13001301invalid_def_raw:
13011302 | [ASYNC] a='def' NAME '(' [params] ')' ['->' expression] ':' NEWLINE !INDENT {
13021303 RAISE_INDENTATION_ERROR("expected an indented block after function definition on line %d", a->lineno) }
13031304invalid_class_def_raw:
1304- | a='class' NAME ['('[arguments] ')'] ':' NEWLINE !INDENT {
1305+ | 'class' NAME ['(' [arguments] ')'] NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
1306+ | a='class' NAME ['(' [arguments] ')'] ':' NEWLINE !INDENT {
13051307 RAISE_INDENTATION_ERROR("expected an indented block after class definition on line %d", a->lineno) }
13061308
13071309invalid_double_starred_kvpairs:
0 commit comments