ew :(
This commit is contained in:
parent
edb1219070
commit
34cffe1661
1 changed files with 13 additions and 6 deletions
|
@ -204,7 +204,8 @@ let translate (p : S.t) env =
|
||||||
| S.RecFunctions fdefs ->
|
| S.RecFunctions fdefs ->
|
||||||
let fs, defs = define_recursive_functions fdefs in
|
let fs, defs = define_recursive_functions fdefs in
|
||||||
fs @ List.map (fun (x, e) -> T.DefineValue (x, e)) defs
|
fs @ List.map (fun (x, e) -> T.DefineValue (x, e)) defs
|
||||||
and define_recursive_functions rdefs = failwith "Students! This is your job!"
|
and define_recursive_functions rdefs =
|
||||||
|
failwith "Students! This is your job (define_recursive_functions)!"
|
||||||
and expression env = function
|
and expression env = function
|
||||||
| S.Literal l -> [], T.Literal (literal l)
|
| S.Literal l -> [], T.Literal (literal l)
|
||||||
| S.While (cond, e) ->
|
| S.While (cond, e) ->
|
||||||
|
@ -218,14 +219,20 @@ let translate (p : S.t) env =
|
||||||
| Some e -> e
|
| Some e -> e
|
||||||
in
|
in
|
||||||
[], xc
|
[], xc
|
||||||
| S.Define (vdef, a) -> failwith "Students! This is your job!"
|
| S.Define (vdef, a) ->
|
||||||
| S.Apply (a, bs) -> failwith "Students! This is your job!"
|
let afs, a = expression env a in
|
||||||
|
(match vdef with
|
||||||
|
| S.SimpleValue (id, b) ->
|
||||||
|
let bfs, b = expression env b in
|
||||||
|
afs @ bfs, T.Define (identifier id, a, b)
|
||||||
|
| S.RecFunctions _ -> failwith "Students! This is your job (S.RecFunctions)!")
|
||||||
|
| S.Apply (a, bs) -> failwith "Students! This is your job (S.Apply)!"
|
||||||
| S.IfThenElse (a, b, c) ->
|
| S.IfThenElse (a, b, c) ->
|
||||||
let afs, a = expression env a in
|
let afs, a = expression env a in
|
||||||
let bfs, b = expression env b in
|
let bfs, b = expression env b in
|
||||||
let cfs, c = expression env c in
|
let cfs, c = expression env c in
|
||||||
afs @ bfs @ cfs, T.IfThenElse (a, b, c)
|
afs @ bfs @ cfs, T.IfThenElse (a, b, c)
|
||||||
| S.Fun (x, e) -> failwith "Students! This is your job!"
|
| S.Fun (x, e) -> failwith "Students! This is your job (S.Fun)!"
|
||||||
| S.AllocateBlock a ->
|
| S.AllocateBlock a ->
|
||||||
let afs, a = expression env a in
|
let afs, a = expression env a in
|
||||||
afs, allocate_block a
|
afs, allocate_block a
|
||||||
|
|
Reference in a new issue