summaryrefslogtreecommitdiffstats
path: root/Parser/pegen.c
diff options
context:
space:
mode:
Diffstat (limited to 'Parser/pegen.c')
-rw-r--r--Parser/pegen.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/Parser/pegen.c b/Parser/pegen.c
index f615907..2507bc4 100644
--- a/Parser/pegen.c
+++ b/Parser/pegen.c
@@ -2217,3 +2217,38 @@ _PyPegen_nonparen_genexp_in_call(Parser *p, expr_ty args)
"Generator expression must be parenthesized"
);
}
+
+
+expr_ty _PyPegen_collect_call_seqs(Parser *p, asdl_seq *a, asdl_seq *b) {
+ Py_ssize_t args_len = asdl_seq_LEN(a);
+ Py_ssize_t total_len = args_len;
+
+ if (b == NULL) {
+ expr_ty first = asdl_seq_GET(a, 0);
+ expr_ty last = asdl_seq_GET(a, args_len - 1);
+ return _Py_Call(_PyPegen_dummy_name(p), a, NULL, EXTRA_EXPR(first, last));
+
+ }
+
+ asdl_seq *starreds = _PyPegen_seq_extract_starred_exprs(p, b);
+ asdl_seq *keywords = _PyPegen_seq_delete_starred_exprs(p, b);
+
+ if (starreds) {
+ total_len += asdl_seq_LEN(starreds);
+ }
+
+ asdl_seq *args = _Py_asdl_seq_new(total_len, p->arena);
+
+ Py_ssize_t i = 0;
+ for (i = 0; i < args_len; i++) {
+ asdl_seq_SET(args, i, asdl_seq_GET(a, i));
+ }
+ for (; i < total_len; i++) {
+ asdl_seq_SET(args, i, asdl_seq_GET(starreds, i - args_len));
+ }
+
+ expr_ty first = asdl_seq_GET(args, 0);
+ expr_ty last = asdl_seq_GET(b, asdl_seq_LEN(b)-1);
+
+ return _Py_Call(_PyPegen_dummy_name(p), args, keywords, EXTRA_EXPR(first, last));
+}