@@ -583,18 +583,19 @@ ann_assign_subscript_attribute_target[expr_ty]:
583
583
| a=t_primary '[' b=slices ']' !t_lookahead { _Py_Subscript(a, b, Store, EXTRA) }
584
584
585
585
del_targets[asdl_seq*]: a=','.del_target+ [','] { a }
586
+ # The lookaheads to del_target_end ensure that we don't match expressions where a prefix of the
587
+ # expression matches our rule, thereby letting these cases fall through to invalid_del_target.
586
588
del_target[expr_ty] (memo):
587
- | a=t_primary '.' b=NAME !t_lookahead { _Py_Attribute(a, b->v.Name.id, Del, EXTRA) }
588
- | a=t_primary '[' b=slices ']' !t_lookahead { _Py_Subscript(a, b, Del, EXTRA) }
589
+ | a=t_primary '.' b=NAME &del_target_end { _Py_Attribute(a, b->v.Name.id, Del, EXTRA) }
590
+ | a=t_primary '[' b=slices ']' &del_target_end { _Py_Subscript(a, b, Del, EXTRA) }
589
591
| del_t_atom
590
592
del_t_atom[expr_ty]:
591
- # The lookahead here ensures that we don't match expressions where a prefix of the expression is
592
- # a name (like `del a + b`), thereby letting these cases fall through to invalid_del_target.
593
- | a=NAME &(')' | ']' | ',' | ';' | NEWLINE) { _PyPegen_set_expr_context(p, a, Del) }
593
+ | a=NAME &del_target_end { _PyPegen_set_expr_context(p, a, Del) }
594
594
| '(' a=del_target ')' { _PyPegen_set_expr_context(p, a, Del) }
595
595
| '(' a=[del_targets] ')' { _Py_Tuple(a, Del, EXTRA) }
596
596
| '[' a=[del_targets] ']' { _Py_List(a, Del, EXTRA) }
597
597
| invalid_del_target
598
+ del_target_end: ')' | ']' | ',' | ';' | NEWLINE
598
599
599
600
targets[asdl_seq*]: a=','.target+ [','] { a }
600
601
target[expr_ty] (memo):
0 commit comments