Fixing pretty print ast. adding a few more builtins :( getting further with inspector

This commit is contained in:
Dustin Swan 2026-02-10 16:46:31 -07:00
parent 30234875fe
commit 8bc05efa1e
No known key found for this signature in database
GPG key ID: 30D46587E2100467
9 changed files with 272 additions and 82 deletions

View file

@ -475,7 +475,7 @@ export class Parser {
if (token.kind === 'open-brace') {
this.advance();
const fields: { [key: string]: AST } = {};
const entries: Array<{ kind: 'field', key: string, value: AST } | { kind: 'spread', expr: AST }> = [];
let first = true;
while (this.current().kind !== 'close-brace') {
@ -485,14 +485,20 @@ export class Parser {
}
first = false;
const keyToken = this.expect('ident');
const key = (keyToken as { value: string }).value;
this.expect('equals');
fields[key] = this.parseExpression();
if (this.current().kind === 'dot-dot-dot') {
this.advance();
const expr = this.parseExpression();
entries.push({ kind: 'spread', expr });
} else {
const keyToken = this.expect('ident');
const key = (keyToken as { value: string }).value;
this.expect('equals');
entries.push({ kind: 'field', key, value: this.parseExpression() });
}
}
this.expect('close-brace');
return { kind: 'record', fields, ...this.getPos(token) };
return { kind: 'record', entries, ...this.getPos(token) };
}
if (token.kind === 'int') {