You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1012 B
TypeScript
37 lines
1012 B
TypeScript
import { evaluate } from './interpreter'
|
|
// import type { AST } from './ast'
|
|
import type { Env } from './env'
|
|
import { tokenize } from './lexer'
|
|
import { Parser } from './parser'
|
|
import { prettyPrint } from './ast';
|
|
|
|
// const env: Env = new Map();
|
|
|
|
// const res = evaluate(ast, env);
|
|
|
|
// console.log(res);
|
|
|
|
const str = `
|
|
# This is a comment
|
|
double = x \\ x * 2
|
|
read_line! : Unit \\ String
|
|
`;
|
|
console.log(tokenize(str));
|
|
|
|
// const tokens = tokenize("x");
|
|
// const p = new Parser(tokens);
|
|
// console.log(p.parse());
|
|
|
|
// 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('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(evaluate(ast3, env3));
|