Fixing pretty print ast. adding a few more builtins :( getting further with inspector
This commit is contained in:
parent
30234875fe
commit
8bc05efa1e
9 changed files with 272 additions and 82 deletions
|
|
@ -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') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue