more CG syntax. parsing the easy stuff

This commit is contained in:
Dustin Swan 2026-02-01 00:03:32 -07:00
parent 71237d0307
commit 1ed325e98b
No known key found for this signature in database
GPG key ID: 30D46587E2100467
3 changed files with 204 additions and 82 deletions

View file

@ -1,31 +1,10 @@
import { evaluate } from './interpreter'
import type { AST } from './ast'
import type { Env } from './env'
// import { evaluate } from './interpreter'
// import type { AST } from './ast'
// import type { Env } from './env'
import { tokenize } from './lexer'
import { Parser } from './parser'
const ast: AST = {
kind: 'binaryop',
operator: '+',
left: {
kind: 'literal',
value: { kind: 'int', value: 1 }
},
right: {
kind: 'binaryop',
operator: '*',
left: {
kind: 'literal',
value: { kind: 'int', value: 2 }
},
right: {
kind: 'literal',
value: { kind: 'int', value: 3 }
}
}
};
const env: Env = new Map();
// const env: Env = new Map();
// const res = evaluate(ast, env);
@ -42,13 +21,13 @@ console.log(tokenize(str));
// 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 = (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('[1, 2, 3]');
const p2 = new Parser(tokens2);
const ast3 = p2.parse();
const env3: Env = new Map();
console.log(ast3);
console.log(evaluate(ast3, env3));
*/
// const env3: Env = new Map();
// console.log(ast3);
// console.log(evaluate(ast3, env3));