@@ -129,6 +129,7 @@ simple_stmt[stmt_ty] (memo):
129129compound_stmt[stmt_ty]:
130130 | &('def' | '@' | 'async') function_def
131131 | &'if' if_stmt
132+ | &"maybe" maybe_stmt
132133 | &('class' | '@') class_def
133134 | &('with' | 'async') with_stmt
134135 | &('for' | 'async') for_stmt
@@ -366,6 +367,11 @@ default[expr_ty]: '=' a=expression { a } | invalid_default
366367# If statement
367368# ------------
368369
370+ maybe_stmt[stmt_ty]:
371+ | invalid_maybe_stmt
372+ | "maybe" a=named_expression ':' b=block c=elif_stmt {
373+ _PyAST_If(a, b, CHECK(asdl_stmt_seq*, _PyPegen_singleton_seq(p, c)), EXTRA) }
374+ | "maybe" a=named_expression ':' b=block c=[else_block] { _PyAST_If(a, b, c, EXTRA) }
369375if_stmt[stmt_ty]:
370376 | invalid_if_stmt
371377 | 'if' a=named_expression ':' b=block c=elif_stmt {
@@ -1401,6 +1407,10 @@ invalid_class_pattern:
14011407 "positional patterns follow keyword patterns") }
14021408invalid_class_argument_pattern[asdl_pattern_seq*]:
14031409 | [positional_patterns ','] keyword_patterns ',' a=positional_patterns { a }
1410+ invalid_maybe_stmt:
1411+ | "maybe" named_expression NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
1412+ | a="maybe" a=named_expression ':' NEWLINE !INDENT {
1413+ RAISE_INDENTATION_ERROR("expected an indented block after 'if' statement on line %d", a->lineno) }
14041414invalid_if_stmt:
14051415 | 'if' named_expression NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
14061416 | a='if' a=named_expression ':' NEWLINE !INDENT {
0 commit comments