We have UI! kind of
This commit is contained in:
parent
52647a9ce1
commit
5b40e9d298
7 changed files with 221 additions and 40 deletions
|
|
@ -281,25 +281,31 @@ export class Parser {
|
|||
const field = (fieldToken as { value: string }).value;
|
||||
expr = { kind: 'record-access', record: expr, field };
|
||||
} else if (this.current().kind === 'open-brace') {
|
||||
// Record update
|
||||
this.advance();
|
||||
const updates: { [key: string]: AST } = {};
|
||||
let first = true;
|
||||
if (expr.kind === 'constructor') {
|
||||
// Constructor application
|
||||
const record = this.parsePrimary();
|
||||
expr = { kind: 'apply', func: expr, args: [record] };
|
||||
} else {
|
||||
// Record update
|
||||
this.advance();
|
||||
const updates: { [key: string]: AST } = {};
|
||||
let first = true;
|
||||
|
||||
while (this.current().kind !== 'close-brace') {
|
||||
if (!first) {
|
||||
this.expect('comma');
|
||||
while (this.current().kind !== 'close-brace') {
|
||||
if (!first) {
|
||||
this.expect('comma');
|
||||
}
|
||||
first = false;
|
||||
|
||||
const keyToken = this.expect('ident');
|
||||
const key = (keyToken as { value: string }).value;
|
||||
this.expect('equals');
|
||||
updates[key] = this.parseExpression();
|
||||
}
|
||||
first = false;
|
||||
|
||||
const keyToken = this.expect('ident');
|
||||
const key = (keyToken as { value: string }).value;
|
||||
this.expect('equals');
|
||||
updates[key] = this.parseExpression();
|
||||
this.expect('close-brace');
|
||||
expr = { kind: 'record-update', record: expr, updates }
|
||||
}
|
||||
|
||||
this.expect('close-brace');
|
||||
expr = { kind: 'record-update', record: expr, updates }
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue