We have UI! kind of

This commit is contained in:
Dustin Swan 2026-02-01 23:26:30 -07:00
parent 52647a9ce1
commit 5b40e9d298
No known key found for this signature in database
GPG key ID: 30D46587E2100467
7 changed files with 221 additions and 40 deletions

View file

@ -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;
}