Skip to content

Commit b66524a

Browse files
committed
Use a loop to collect args in the parser instead of recursion
1 parent 9b648a9 commit b66524a

File tree

4 files changed

+626
-515
lines changed

4 files changed

+626
-515
lines changed

Grammar/python.gram

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -535,22 +535,11 @@ arguments[expr_ty] (memo):
535535
| a=args [','] &')' { a }
536536
| incorrect_arguments
537537
args[expr_ty]:
538-
| a=starred_expression b=[',' c=args { c }] {
539-
_Py_Call(_PyPegen_dummy_name(p),
540-
(b) ? CHECK(_PyPegen_seq_insert_in_front(p, a, ((expr_ty) b)->v.Call.args))
541-
: CHECK(_PyPegen_singleton_seq(p, a)),
542-
(b) ? ((expr_ty) b)->v.Call.keywords : NULL,
543-
EXTRA) }
538+
| a=','.(starred_expression | named_expression !'=')+ b=[',' k=kwargs {k}] { _PyPegen_collect_call_seqs(p, a, b) }
544539
| a=kwargs { _Py_Call(_PyPegen_dummy_name(p),
545540
CHECK_NULL_ALLOWED(_PyPegen_seq_extract_starred_exprs(p, a)),
546541
CHECK_NULL_ALLOWED(_PyPegen_seq_delete_starred_exprs(p, a)),
547542
EXTRA) }
548-
| a=named_expression b=[',' c=args { c }] {
549-
_Py_Call(_PyPegen_dummy_name(p),
550-
(b) ? CHECK(_PyPegen_seq_insert_in_front(p, a, ((expr_ty) b)->v.Call.args))
551-
: CHECK(_PyPegen_singleton_seq(p, a)),
552-
(b) ? ((expr_ty) b)->v.Call.keywords : NULL,
553-
EXTRA) }
554543
kwargs[asdl_seq*]:
555544
| a=','.kwarg_or_starred+ ',' b=','.kwarg_or_double_starred+ { _PyPegen_join_sequences(p, a, b) }
556545
| ','.kwarg_or_starred+

0 commit comments

Comments
 (0)