lambdas and application now in AST, types and interpreter
This commit is contained in:
parent
d60e5aa29f
commit
920151f49c
4 changed files with 102 additions and 4 deletions
16
src/ast.ts
16
src/ast.ts
|
|
@ -1,4 +1,4 @@
|
|||
import type { Value } from './types';
|
||||
import type { Value, Closure } from './types';
|
||||
|
||||
export type Literal = {
|
||||
kind: 'literal'
|
||||
|
|
@ -31,4 +31,16 @@ export type If = {
|
|||
else: AST
|
||||
}
|
||||
|
||||
export type AST = Literal | BinaryOp | Variable | Let | If
|
||||
export type Lambda = {
|
||||
kind: 'lambda'
|
||||
params: string[]
|
||||
body: AST
|
||||
}
|
||||
|
||||
export type Apply = {
|
||||
kind: 'apply'
|
||||
func: AST
|
||||
args: AST[]
|
||||
}
|
||||
|
||||
export type AST = Literal | BinaryOp | Variable | Let | If | Lambda | Apply
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue