summaryrefslogtreecommitdiff
path: root/src/pretty_print.ml
diff options
context:
space:
mode:
authorKathy Gray2016-02-23 15:13:55 +0000
committerKathy Gray2016-02-23 15:19:53 +0000
commit941cfeba96830e8716a49a6f24755f68f1de2197 (patch)
tree1f2cf6bec99552d5ad7266c034988083a47dedfe /src/pretty_print.ml
parent91cfc8b9a4d54a438f3f6dd4aa78c8a5264b90cd (diff)
Several fixes
Improve printing for asl to sail readability; Add -o option for selecting the name of file generation; Add additional initial check module for turning generated ast nodes into ready-to-type-check ast nodes
Diffstat (limited to 'src/pretty_print.ml')
-rw-r--r--src/pretty_print.ml15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/pretty_print.ml b/src/pretty_print.ml
index 2a93bef7..5f0990d1 100644
--- a/src/pretty_print.ml
+++ b/src/pretty_print.ml
@@ -639,6 +639,9 @@ let squarebarbars = enclose lsquarebarbar rsquarebarbar
let lsquarecolon = string "[:"
let rsquarecolon = string ":]"
let squarecolons = enclose lsquarecolon rsquarecolon
+let lcomment = string "(*"
+let rcomment = string "*)"
+let comment = enclose lcomment rcomment
let string_lit = enclose dquote dquote
let spaces op = enclose space space op
let semi_sp = semi ^^ space
@@ -912,7 +915,7 @@ let doc_exp, doc_let =
| _ -> group (parens (exp expr))
and app_exp ((E_aux(e,_)) as expr) = match e with
| E_app(f,args) ->
- doc_unop (doc_id f) (parens (separate_map comma exp args))
+ (doc_id f) ^^ (parens (separate_map comma exp args))
| _ -> vaccess_exp expr
and vaccess_exp ((E_aux(e,_)) as expr) = match e with
| E_vector_access(v,e) ->
@@ -988,7 +991,7 @@ let doc_exp, doc_let =
let cases = separate_map (break 1) doc_case pexps in
surround 2 1 opening cases rbrace
| E_exit e ->
- separate space [string "exit"; exp e;]
+ separate space [string "exit"; atomic_exp e;]
| E_assert(c,m) ->
separate space [string "assert"; parens (separate comma [exp c; exp m])]
(* adding parens and loop for lower precedence *)
@@ -1016,7 +1019,9 @@ let doc_exp, doc_let =
(* XXX default precedence for app_infix? *)
| E_app_infix(l,op,r) ->
failwith ("unexpected app_infix operator " ^ (pp_format_id op))
- (* doc_op (doc_id op) (exp l) (exp r) *)
+ (* doc_op (doc_id op) (exp l) (exp r) *)
+ | E_comment s -> comment (string s)
+ | E_comment_struc e -> comment (exp e)
| E_internal_exp((l, Base((_,t),_,_,_,_,bindings))) -> (*TODO use bindings, and other params*)
(match t.t with
| Tapp("register",[TA_typ {t=Tapp("vector",[TA_nexp _;TA_nexp r;_;_])}])
@@ -1197,7 +1202,7 @@ let doc_scattered (SD_aux (sdef, _)) = match sdef with
string "member"; doc_type_union tu]
| SD_scattered_end id -> string "end" ^^ space ^^ doc_id id
-let doc_def def = group (match def with
+let rec doc_def def = group (match def with
| DEF_default df -> doc_default df
| DEF_spec v_spec -> doc_spec v_spec
| DEF_type t_def -> doc_typdef t_def
@@ -1205,6 +1210,8 @@ let doc_def def = group (match def with
| DEF_val lbind -> doc_let lbind
| DEF_reg_dec dec -> doc_dec dec
| DEF_scattered sdef -> doc_scattered sdef
+ | DEF_comm (DC_comm s) -> comment (string s)
+ | DEF_comm (DC_comm_struct d) -> comment (doc_def d)
) ^^ hardline
let doc_defs (Defs(defs)) =