Parsing bindings. adding AST pretty printer
This commit is contained in:
parent
1fc116f2fe
commit
0f0371461d
4 changed files with 64 additions and 42 deletions
|
|
@ -3,6 +3,7 @@
|
|||
// import type { Env } from './env'
|
||||
import { tokenize } from './lexer'
|
||||
import { Parser } from './parser'
|
||||
import { prettyPrint } from './ast';
|
||||
|
||||
// const env: Env = new Map();
|
||||
|
||||
|
|
@ -24,10 +25,11 @@ console.log(tokenize(str));
|
|||
// const tokens2 = tokenize("let x = (y) => 5 + y in x(3)");
|
||||
// const tokens2 = tokenize("let x = 5 in x * 4");
|
||||
// const tokens2 = tokenize("(x, y) => x + y");
|
||||
const tokens2 = tokenize('map double [1, 2, 3]');
|
||||
const tokens2 = tokenize('x = (y = 1; y + 1); x * 2');
|
||||
const p2 = new Parser(tokens2);
|
||||
const ast3 = p2.parse();
|
||||
console.log(ast3);
|
||||
console.log(prettyPrint(ast3));
|
||||
// const env3: Env = new Map();
|
||||
// console.log(ast3);
|
||||
// console.log(evaluate(ast3, env3));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue