summaryrefslogtreecommitdiff
path: root/src/pretty_print_sail.ml
diff options
context:
space:
mode:
authorAlasdair Armstrong2018-02-05 22:58:22 +0000
committerAlasdair Armstrong2018-02-05 22:58:22 +0000
commit17265a95407c62e78bb850c0e6ffb0876c85c5cb (patch)
tree91eb1aba10472c88aefc45c1e62f19250626ddcb /src/pretty_print_sail.ml
parent61290ddac2c50e5e0888c555eb7e355326b86d17 (diff)
Add typ patterns for destructuring existentials
Diffstat (limited to 'src/pretty_print_sail.ml')
-rw-r--r--src/pretty_print_sail.ml9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/pretty_print_sail.ml b/src/pretty_print_sail.ml
index b55448fa..8d9b12d1 100644
--- a/src/pretty_print_sail.ml
+++ b/src/pretty_print_sail.ml
@@ -70,6 +70,11 @@ let doc_ord (Ord_aux(o,_)) = match o with
| Ord_inc -> string "inc"
| Ord_dec -> string "dec"
+let rec doc_typ_pat = function
+ | TP_wild -> string "_"
+ | TP_var kid -> doc_kid kid
+ | TP_app (f, tpats) -> doc_id f ^^ parens (separate_map (comma ^^ space) doc_typ_pat tpats)
+
let rec doc_nexp =
let rec atomic_nexp (Nexp_aux (n_aux, _) as nexp) =
match n_aux with
@@ -216,9 +221,9 @@ let rec doc_pat (P_aux (p_aux, _) as pat) =
| P_typ (typ, pat) -> separate space [doc_pat pat; colon; doc_typ typ]
| P_lit lit -> doc_lit lit
(* P_var short form sugar *)
- | P_var (P_aux (P_id id, _), kid) when Id.compare (id_of_kid kid) id == 0 ->
+ | P_var (P_aux (P_id id, _), TP_var kid) when Id.compare (id_of_kid kid) id == 0 ->
doc_kid kid
- | P_var (pat, kid) -> separate space [doc_pat pat; string "as"; doc_kid kid]
+ | P_var (pat, tpat) -> separate space [doc_pat pat; string "as"; doc_typ_pat tpat]
| P_vector pats -> brackets (separate_map (comma ^^ space) doc_pat pats)
| P_vector_concat pats -> separate_map (space ^^ string "@" ^^ space) doc_pat pats
| P_wild -> string "_"