First commit for CG
This commit is contained in:
commit
d60e5aa29f
11 changed files with 1397 additions and 0 deletions
30
src/main.ts
Normal file
30
src/main.ts
Normal 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);
|
||||
Loading…
Add table
Add a link
Reference in a new issue