parsing pattern matching
This commit is contained in:
parent
d81318333e
commit
7f94cfe8cd
4 changed files with 176 additions and 11 deletions
|
|
@ -5,11 +5,15 @@ import { Parser } from './parser'
|
|||
import { prettyPrint } from './ast';
|
||||
|
||||
function e(str: string) {
|
||||
console.log(str);
|
||||
const tokens = tokenize(str);
|
||||
console.log(tokens);
|
||||
const p = new Parser(tokens);
|
||||
const ast = p.parse();
|
||||
console.log(ast);
|
||||
console.log(prettyPrint(ast));
|
||||
const env: Env = new Map();
|
||||
console.log(str, tokens, prettyPrint(ast), evaluate(ast, env));
|
||||
// console.log(evaluate(ast, env));
|
||||
}
|
||||
|
||||
e('add1 = (x \\ x + 1); add1 3');
|
||||
|
|
@ -21,3 +25,6 @@ e('rec = { a = 3, b = 5 }; rec{ a = 10 }');
|
|||
e('add1 = (x \\ x + 1); 3 > add1');
|
||||
e('[1, 2] & [3, 4]');
|
||||
e('"abc" & "def"');
|
||||
// e('n | 0 \\ 1 | _ \\ 99');
|
||||
e('m | Some x \\ 1 | None \\ 0');
|
||||
e('head = list \\ list | [x, _] \\ Some x | [] \\ None; head');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue