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

34
src/ast.ts Normal file
View file

@ -0,0 +1,34 @@
import type { Value } from './types';
export type Literal = {
kind: 'literal'
value: Value
}
export type BinaryOp = {
kind: 'binaryop'
operator: string
left: AST
right: AST
}
export type Variable = {
kind: 'variable'
name: string
}
export type Let = {
kind: 'let'
name: string
value: AST
body: AST
}
export type If = {
kind: 'if'
condition: AST
then: AST
else: AST
}
export type AST = Literal | BinaryOp | Variable | Let | If