@@ -249,7 +249,7 @@ class_def[stmt_ty]:
249
249
250
250
class_def_raw[stmt_ty]:
251
251
| invalid_class_def_raw
252
- | 'class' a=NAME b=['(' z=[arguments] ')' { z }] && ':' c=block {
252
+ | 'class' a=NAME b=['(' z=[arguments] ')' { z }] ':' c=block {
253
253
_PyAST_ClassDef(a->v.Name.id,
254
254
(b) ? ((expr_ty) b)->v.Call.args : NULL,
255
255
(b) ? ((expr_ty) b)->v.Call.keywords : NULL,
@@ -379,9 +379,9 @@ while_stmt[stmt_ty]:
379
379
380
380
for_stmt[stmt_ty]:
381
381
| 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] {
383
383
_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] {
385
385
CHECK_VERSION(stmt_ty, 5, "Async for loops are", _PyAST_AsyncFor(t, ex, b, el, NEW_TYPE_COMMENT(p, tc), EXTRA)) }
386
386
| invalid_for_target
387
387
@@ -1231,8 +1231,8 @@ invalid_import_from_targets:
1231
1231
RAISE_SYNTAX_ERROR("trailing comma not allowed without surrounding parentheses") }
1232
1232
1233
1233
invalid_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 ':'") }
1236
1236
invalid_with_stmt_indent:
1237
1237
| [ASYNC] a='with' ','.(expression ['as' star_target])+ ':' NEWLINE !INDENT {
1238
1238
RAISE_INDENTATION_ERROR("expected an indented block after 'with' statement on line %d", a->lineno) }
@@ -1262,11 +1262,11 @@ invalid_except_star_stmt_indent:
1262
1262
| a='except' '*' expression ['as' NAME ] ':' NEWLINE !INDENT {
1263
1263
RAISE_INDENTATION_ERROR("expected an indented block after 'except*' statement on line %d", a->lineno) }
1264
1264
invalid_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 ':'") ) }
1266
1266
| a="match" subject=subject_expr ':' NEWLINE !INDENT {
1267
1267
RAISE_INDENTATION_ERROR("expected an indented block after 'match' statement on line %d", a->lineno) }
1268
1268
invalid_case_block:
1269
- | "case" patterns guard? !':' { RAISE_SYNTAX_ERROR("expected ':'") }
1269
+ | "case" patterns guard? NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
1270
1270
| a="case" patterns guard? ':' NEWLINE !INDENT {
1271
1271
RAISE_INDENTATION_ERROR("expected an indented block after 'case' statement on line %d", a->lineno) }
1272
1272
invalid_as_pattern:
@@ -1295,13 +1295,15 @@ invalid_while_stmt:
1295
1295
| a='while' named_expression ':' NEWLINE !INDENT {
1296
1296
RAISE_INDENTATION_ERROR("expected an indented block after 'while' statement on line %d", a->lineno) }
1297
1297
invalid_for_stmt:
1298
+ | [ASYNC] 'for' star_targets 'in' star_expressions NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
1298
1299
| [ASYNC] a='for' star_targets 'in' star_expressions ':' NEWLINE !INDENT {
1299
1300
RAISE_INDENTATION_ERROR("expected an indented block after 'for' statement on line %d", a->lineno) }
1300
1301
invalid_def_raw:
1301
1302
| [ASYNC] a='def' NAME '(' [params] ')' ['->' expression] ':' NEWLINE !INDENT {
1302
1303
RAISE_INDENTATION_ERROR("expected an indented block after function definition on line %d", a->lineno) }
1303
1304
invalid_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 {
1305
1307
RAISE_INDENTATION_ERROR("expected an indented block after class definition on line %d", a->lineno) }
1306
1308
1307
1309
invalid_double_starred_kvpairs:
0 commit comments