summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Pulte2015-09-28 17:00:22 +0100
committerChristopher Pulte2015-09-28 17:00:22 +0100
commit9e3cddcb6d3c46182496b91dfec6ab0305ba88dc (patch)
tree66b8994044e76e758ff2bd8838f1e977ec330eb4
parente3e38f6408a673091b591976fe5147a706a5e003 (diff)
completed pp for E_for expressions, necessary OCaml foreach_inc and foreach_dec declarations in comment
-rw-r--r--src/pretty_print.ml18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/pretty_print.ml b/src/pretty_print.ml
index 9e050ba0..fa1b60f1 100644
--- a/src/pretty_print.ml
+++ b/src/pretty_print.ml
@@ -1322,7 +1322,7 @@ let doc_exp_ocaml, doc_let_ocaml =
string "if" ^^ space ^^ string "toBool" ^^ group (exp c) ^/^
string "then" ^^ space ^^ group (exp t) ^/^
string "else" ^^ space ^^ group (exp e)
- | E_for(id,exp1,exp2,(E_aux(exp3, (l3,annot3))),(Ord_aux(order,_)),exp4) ->
+ | E_for(id,exp1,exp2,((E_aux(exp3, (l3,annot3))) as full_exp3),(Ord_aux(order,_)),exp4) ->
(match exp3 with
| E_lit (L_aux( (L_num 1), _)) ->
string "for" ^^ space ^^
@@ -1332,7 +1332,21 @@ let doc_exp_ocaml, doc_let_ocaml =
| _ -> (group (string "downto" ^^ space ^^ (exp exp2)))) ^^
string "do" ^/^
exp exp4 ^/^ string "done"
- | _ -> string "make a while loop")
+ | _ ->
+ let forL = if order = Ord_inc then string "foreach_inc" else string "foreach_dec" in
+ forL ^^ space ^^ (group (exp exp1)) ^^ (group (exp exp2)) ^^ (group (exp full_exp3)) ^/^
+ group ((string "fun") ^^ space ^^ (doc_id id) ^^ space ^^ arrow ^/^ (exp exp4))
+
+ (* this requires the following OCaml declarations first
+
+ let rec foreach_inc i stop by body =
+ if i <= stop then (body i; foreach_inc (i + by) stop by body) else ()
+
+ let rec foreach_dec i stop by body =
+ if i >= stop then (body i; foreach_dec (i - by) stop by body) else ()
+
+ *)
+ )
| E_let(leb,e) -> doc_op (string "in") (let_exp leb) (exp e)
| E_app(f,args) ->
let call = match annot with