Just realized point { x = 1 } was ambiguous, could be record update or function application. changed record update syntax to: point.{ x = 1 }. And starting on ui components
This commit is contained in:
parent
645de97db2
commit
d55ae33848
4 changed files with 32 additions and 14 deletions
|
|
@ -319,17 +319,9 @@ export class Parser {
|
|||
|
||||
while (true) {
|
||||
if (this.current().kind === 'dot') {
|
||||
// Record access
|
||||
this.advance();
|
||||
const fieldToken = this.expect('ident');
|
||||
const field = (fieldToken as { value: string }).value;
|
||||
expr = { kind: 'record-access', record: expr, field };
|
||||
} else if (this.current().kind === 'open-brace') {
|
||||
if (expr.kind === 'constructor') {
|
||||
// Constructor application
|
||||
const record = this.parsePrimary();
|
||||
expr = { kind: 'apply', func: expr, args: [record] };
|
||||
} else {
|
||||
|
||||
if (this.current().kind === 'open-brace') {
|
||||
// Record update
|
||||
this.advance();
|
||||
const updates: { [key: string]: AST } = {};
|
||||
|
|
@ -349,7 +341,21 @@ export class Parser {
|
|||
|
||||
this.expect('close-brace');
|
||||
expr = { kind: 'record-update', record: expr, updates }
|
||||
|
||||
} else {
|
||||
// Record access
|
||||
const fieldToken = this.expect('ident');
|
||||
const field = (fieldToken as { value: string }).value;
|
||||
expr = { kind: 'record-access', record: expr, field };
|
||||
}
|
||||
} else if (this.current().kind === 'open-brace') {
|
||||
// if (expr.kind === 'constructor') {
|
||||
// Function / constructor application
|
||||
const record = this.parsePrimary();
|
||||
expr = { kind: 'apply', func: expr, args: [record] };
|
||||
// } else {
|
||||
// break;
|
||||
// }
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue