selfhost: port append + spread — N_SPREAD parser + rt_ensure builtin
This commit is contained in:
@@ -217,6 +217,14 @@ fn parsearglist(p: *parser, closekind: tkind, headout: **node) void = {
|
||||
let tail: *node = nil;
|
||||
for (true) {
|
||||
let e: *node = parseexpr(p);
|
||||
// Hare-style spread: `expr...` in an arg slot becomes a
|
||||
// marker the callee/builtin can iterate over. Mirrors
|
||||
// cmd/wcc/parse.c. The only consumer today is `append`.
|
||||
if (accepttok(p, tkind.TK_ELLIPSIS)) {
|
||||
let sp: *node = newnode(p.a, nkind.N_SPREAD, e.file, e.line, e.col);
|
||||
sp.lhs = e;
|
||||
e = sp;
|
||||
};
|
||||
if (head == nil) { head = e; tail = e; }
|
||||
else { tail.next = e; tail = e; };
|
||||
if (!accepttok(p, tkind.TK_COMMA)) { break; };
|
||||
|
||||
Reference in New Issue
Block a user