|
|
|
|
@ -114,7 +114,7 @@ export class Parser {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Let
|
|
|
|
|
if (this.current().kind === 'ident' && this.peek().kind === 'equals') {
|
|
|
|
|
if ((this.current().kind === 'ident' || this.current().kind === 'underscore') && this.peek().kind === 'equals') {
|
|
|
|
|
return this.parseLet();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -278,8 +278,20 @@ export class Parser {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private parseLet(): AST {
|
|
|
|
|
const nameToken = this.expect('ident');
|
|
|
|
|
const name = (nameToken as { value: string }).value;
|
|
|
|
|
const nameToken = this.current();
|
|
|
|
|
let name: string;
|
|
|
|
|
|
|
|
|
|
if (nameToken.kind === 'underscore') {
|
|
|
|
|
name = '_';
|
|
|
|
|
this.advance();
|
|
|
|
|
} else if (nameToken.kind === 'ident') {
|
|
|
|
|
name = (nameToken as { value: string }).value;
|
|
|
|
|
this.advance();
|
|
|
|
|
} else {
|
|
|
|
|
throw new Error(`Expected ident or underscore, got ${nameToken.kind}`);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.expect('equals');
|
|
|
|
|
const value = this.parseExpressionNoMatch();
|
|
|
|
|
this.expect('semicolon');
|
|
|
|
|
|