Saving glyphs

This commit is contained in:
Dustin Swan 2026-02-22 13:49:26 -07:00
parent 2e05df8035
commit f426573f96
No known key found for this signature in database
GPG key ID: 30D46587E2100467
3 changed files with 78 additions and 9 deletions

View file

@ -42,6 +42,15 @@ export class Parser {
return this.advance();
}
private expectIdent(): Token {
const token = this.current();
if (token.kind === 'ident' || token.kind === 'type-ident') {
this.advance();
return token;
}
throw this.error(`Expected identifier, got ${token.kind}`);
}
private getPos(token: Token) {
return {
line: token.line,
@ -284,7 +293,7 @@ export class Parser {
// Spread
if (this.current().kind === 'dot-dot-dot') {
this.advance();
const nameToken = this.expect('ident');
const nameToken = this.expectIdent();
spreadName = (nameToken as { value: string }).value;
break;
}
@ -440,7 +449,7 @@ export class Parser {
this.advance();
const items = this.parseCommaSeparated('close-brace', () => {
const keyToken = this.expect('ident');
const keyToken = this.expectIdent();
const key = (keyToken as { value: string }).value;
this.expect('equals');
return { key, value: this.parseExpression() };
@ -453,7 +462,7 @@ export class Parser {
} else {
// Record access
const fieldToken = this.expect('ident');
const fieldToken = this.expectIdent();
const field = (fieldToken as { value: string }).value;
expr = { kind: 'record-access', record: expr, field, ...this.getPos(token) };
}
@ -499,7 +508,7 @@ export class Parser {
this.advance();
return { kind: 'spread' as const, expr: this.parseExpression() };
}
const keyToken = this.expect('ident');
const keyToken = this.expectIdent();
const key = (keyToken as { value: string }).value;
this.expect('equals');
return { kind: 'field' as const, key, value: this.parseExpression() };