summaryrefslogtreecommitdiff
path: root/src/pretty_print_sail2.ml
diff options
context:
space:
mode:
authorThomas Bauereiss2017-11-02 13:46:13 +0000
committerThomas Bauereiss2017-11-02 13:46:13 +0000
commitaa35f90fe4e7da4a6bbbe1396c23f9a5795b6909 (patch)
tree3c2253799750b91d66dd767e3c4303baf57e63f1 /src/pretty_print_sail2.ml
parent9ea44b8b441eb394ffdd85d0b356167002ad7fdd (diff)
Fix a few AST and parsing-related bugs
Diffstat (limited to 'src/pretty_print_sail2.ml')
-rw-r--r--src/pretty_print_sail2.ml9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/pretty_print_sail2.ml b/src/pretty_print_sail2.ml
index 5662fe1a..39fc25d3 100644
--- a/src/pretty_print_sail2.ml
+++ b/src/pretty_print_sail2.ml
@@ -300,6 +300,10 @@ let doc_dec (DEC_aux (reg,_)) =
let doc_field (typ, id) =
separate space [doc_id id; colon; doc_typ typ]
+let doc_union (Tu_aux (tu, l)) = match tu with
+ | Tu_id id -> doc_id id
+ | Tu_ty_id (typ, id) -> separate space [doc_id id; colon; doc_typ typ]
+
let doc_typdef (TD_aux(td,_)) = match td with
| TD_abbrev (id, _, typschm) ->
begin
@@ -316,6 +320,11 @@ let doc_typdef (TD_aux(td,_)) = match td with
| TD_record (id, _, TypQ_aux (TypQ_tq qs, _), fields, _) ->
separate space [string "struct"; doc_id id; doc_quants qs; equals;
surround 2 0 lbrace (separate_map (comma ^^ break 1) doc_field fields) rbrace]
+ | TD_variant (id, _, TypQ_aux (TypQ_no_forall, _), unions, _) | TD_variant (id, _, TypQ_aux (TypQ_tq [], _), unions, _) ->
+ separate space [string "union"; doc_id id; equals; surround 2 0 lbrace (separate_map (comma ^^ break 1) doc_union unions) rbrace]
+ | TD_variant (id, _, TypQ_aux (TypQ_tq qs, _), unions, _) ->
+ separate space [string "union"; doc_id id; doc_quants qs; equals;
+ surround 2 0 lbrace (separate_map (comma ^^ break 1) doc_union unions) rbrace]
| _ -> string "TYPEDEF"
let doc_spec (VS_aux(v,_)) =