summaryrefslogtreecommitdiffstats
path: root/syntax.sml
diff options
context:
space:
mode:
Diffstat (limited to 'syntax.sml')
-rw-r--r--syntax.sml12
1 files changed, 9 insertions, 3 deletions
diff --git a/syntax.sml b/syntax.sml
index 5ed5954..95487d7 100644
--- a/syntax.sml
+++ b/syntax.sml
@@ -17,19 +17,22 @@ struct
| EAndAlso of expr * expr
| EOrElse of expr * expr
| ELet of dec list * expr
+ | ELambda of expr
and dec = DVal of expr
(* Lambda language *)
+ type var = int
datatype primop = PExit
- datatype lexp = LApp of lexp * lexp
+ datatype lexp = LVar of var
+ | LFn of var * lexp
+ | LApp of lexp * lexp
| LInt of int
| LString of string
| LRecord of lexp list
| LPrim of primop
(* CPS *)
- type var = int
datatype value = VVar of var
| VLabel of var
| VInt of int
@@ -83,6 +86,7 @@ struct
| EAndAlso (a, b) => "EAndAlso (" ^ self a ^ ", " ^ self b ^ ")"
| EOrElse (a, b) => "EOrElse (" ^ self a ^ ", " ^ self b ^ ")"
| ELet (decs, e) => "ELet (" ^ multilineListToString decToStringI indent decs ^ ", " ^ self e ^ ")"
+ | ELambda e => "ELambda " ^ exprToStringI indent e
end
and decToStringI (indent : string) (x : dec) : string =
@@ -99,7 +103,9 @@ struct
fun lexpToString (x : lexp) : string =
case x of
- LApp (a, b) => "LApp (" ^ lexpToString a ^ ", " ^ lexpToString b ^ ")"
+ LVar v => "LVar " ^ Int.toString v
+ | LFn (arg, expr) => "LFun (" ^ Int.toString arg ^ ", " ^ lexpToString expr ^ ")"
+ | LApp (a, b) => "LApp (" ^ lexpToString a ^ ", " ^ lexpToString b ^ ")"
| LInt i => "LInt " ^ Int.toString i
| LString s => "LString " ^ quote s
| LRecord l => "LRecord " ^ listToString lexpToString l