Compare commits
No commits in common. "b0cd872baf9dbf0638382ef4c6c988a204fb45eb" and "63f8b6b61a848c49a6aab3c28e04bc542bff0df1" have entirely different histories.
b0cd872baf
...
63f8b6b61a
3 changed files with 2 additions and 10 deletions
|
@ -3,8 +3,7 @@ module S = Lambda
|
||||||
(* The target calculus. *)
|
(* The target calculus. *)
|
||||||
module T = Tail
|
module T = Tail
|
||||||
|
|
||||||
exception NotValue of S.term
|
exception NotValue (** <- Raised when trying to use a non-value term as such *)
|
||||||
(** ^ Raised when trying to use a non-value term as such *)
|
|
||||||
|
|
||||||
let freshId =
|
let freshId =
|
||||||
(** Generates a fresh variable name string *)
|
(** Generates a fresh variable name string *)
|
||||||
|
@ -31,7 +30,7 @@ let rec cps_value (t: S.term) : T.value = match t with
|
||||||
| S.Var v -> T.VVar v
|
| S.Var v -> T.VVar v
|
||||||
| S.Lit v -> T.VLit v
|
| S.Lit v -> T.VLit v
|
||||||
| S.BinOp (l, op, r) -> T.VBinOp (cps_value l, op, cps_value r)
|
| S.BinOp (l, op, r) -> T.VBinOp (cps_value l, op, cps_value r)
|
||||||
| S.Let _ | S.Lam _ | S.App _ | S.Print _ | S.IfZero _ -> raise (NotValue t)
|
| S.Let _ | S.Lam _ | S.App _ | S.Print _ | S.IfZero _ -> raise NotValue
|
||||||
|
|
||||||
let cps_value_as_term (t: S.term) (cont: T.variable): T.term =
|
let cps_value_as_term (t: S.term) (cont: T.variable): T.term =
|
||||||
T.TailCall(T.vvar cont, [cps_value t])
|
T.TailCall(T.vvar cont, [cps_value t])
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
42
|
|
|
@ -1,6 +0,0 @@
|
||||||
let increase = fun x -> x + 1 in
|
|
||||||
let increase = fun x ->
|
|
||||||
let lop = (increase x) in
|
|
||||||
lop + 1 in
|
|
||||||
|
|
||||||
print (increase 40)
|
|
Loading…
Reference in a new issue