Fixing the issue that stopped this from parsing correctly: 'sum = x y \ x + y; sum 5 3'

master
Dustin Swan 5 days ago
parent f2f81b5ed6
commit 1d0f1d5423
Signed by: dustinswan
GPG Key ID: 30D46587E2100467

@ -27,7 +27,7 @@ console.log(tokenize(str));
// const tokens2 = tokenize("(x, y) => x + y"); // const tokens2 = tokenize("(x, y) => x + y");
// const tokens2 = tokenize('point { x = 3 }'); // const tokens2 = tokenize('point { x = 3 }');
// const tokens2 = tokenize('add1 = (x \\ x + 1); add1 3'); // const tokens2 = tokenize('add1 = (x \\ x + 1); add1 3');
const tokens2 = tokenize('sum = (x y \\ x + y); sum 5 3'); const tokens2 = tokenize('sum = x y \\ x + y; sum 5 3');
const p2 = new Parser(tokens2); const p2 = new Parser(tokens2);
const ast3 = p2.parse(); const ast3 = p2.parse();
console.log(ast3); console.log(ast3);

@ -122,7 +122,7 @@ export class Parser {
const nameToken = this.expect('ident'); const nameToken = this.expect('ident');
const name = (nameToken as { value: string }).value; const name = (nameToken as { value: string }).value;
this.expect('equals'); this.expect('equals');
const value = this.parseInfix(); const value = this.parseExpression();
this.expect('semicolon'); this.expect('semicolon');
const body = this.parseExpression(); const body = this.parseExpression();

Loading…
Cancel
Save