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