First commit for CG

This commit is contained in:
Dustin Swan 2026-01-29 22:39:33 -07:00
commit d60e5aa29f
No known key found for this signature in database
GPG key ID: 30D46587E2100467
11 changed files with 1397 additions and 0 deletions

30
src/main.ts Normal file
View file

@ -0,0 +1,30 @@
import { evaluate } from './interpreter'
import type { AST } from './ast'
import type { Env } from './env'
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 res = evaluate(ast, env);
console.log(res);