cleaning up interpreter. adding more types. fixing function application, handling infix binary ops, added currying
This commit is contained in:
parent
b6f7e63e49
commit
f2f81b5ed6
4 changed files with 82 additions and 41 deletions
13
src/main.ts
13
src/main.ts
|
|
@ -1,6 +1,6 @@
|
|||
// import { evaluate } from './interpreter'
|
||||
import { evaluate } from './interpreter'
|
||||
// import type { AST } from './ast'
|
||||
// import type { Env } from './env'
|
||||
import type { Env } from './env'
|
||||
import { tokenize } from './lexer'
|
||||
import { Parser } from './parser'
|
||||
import { prettyPrint } from './ast';
|
||||
|
|
@ -25,11 +25,12 @@ 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('point { x = 3 }');
|
||||
// const tokens2 = tokenize('point { x = 3 }');
|
||||
// const tokens2 = tokenize('add1 = (x \\ x + 1); add1 3');
|
||||
const tokens2 = tokenize('sum = (x y \\ x + y); sum 5 3');
|
||||
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));
|
||||
const env3: Env = new Map();
|
||||
console.log(evaluate(ast3, env3));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue