summaryrefslogtreecommitdiff
path: root/src/pretty_print_sail2.ml
diff options
context:
space:
mode:
authorBrian Campbell2017-12-07 11:10:50 +0000
committerBrian Campbell2017-12-07 11:10:50 +0000
commit691efa994a72d0e9cdbcdfcc4d6a9b1976d91e2b (patch)
tree5f5a31d4d6632e1283c3916b403de6adacc3e701 /src/pretty_print_sail2.ml
parente36e7e0e5068abc31b69831d98138ee5d1e541da (diff)
Resolve function clause guard parsing ambiguity by requiring parentheses
Diffstat (limited to 'src/pretty_print_sail2.ml')
-rw-r--r--src/pretty_print_sail2.ml16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/pretty_print_sail2.ml b/src/pretty_print_sail2.ml
index 4d05e04d..0c531301 100644
--- a/src/pretty_print_sail2.ml
+++ b/src/pretty_print_sail2.ml
@@ -394,12 +394,12 @@ and doc_atomic_lexp (LEXP_aux (l_aux, _) as lexp) =
| LEXP_vector_range (lexp, exp1, exp2) -> doc_atomic_lexp lexp ^^ brackets (separate space [doc_exp exp1; string ".."; doc_exp exp2])
| LEXP_memory (id, exps) -> doc_id id ^^ parens (separate_map (comma ^^ space) doc_exp exps)
| _ -> parens (doc_lexp lexp)
-and doc_pexps pexps = surround 2 0 lbrace (separate_map (comma ^^ hardline) (doc_pexp "=>") pexps) rbrace
-and doc_pexp sym (Pat_aux (pat_aux, _)) =
+and doc_pexps pexps = surround 2 0 lbrace (separate_map (comma ^^ hardline) doc_pexp pexps) rbrace
+and doc_pexp (Pat_aux (pat_aux, _)) =
match pat_aux with
- | Pat_exp (pat, exp) -> separate space [doc_pat pat; string sym; doc_exp exp]
+ | Pat_exp (pat, exp) -> separate space [doc_pat pat; string "=>"; doc_exp exp]
| Pat_when (pat, wh, exp) ->
- separate space [doc_pat pat; string "if"; doc_exp wh; string sym; doc_exp exp]
+ separate space [doc_pat pat; string "if"; doc_exp wh; string "=>"; doc_exp exp]
and doc_letbind (LB_aux (lb_aux, _)) =
match lb_aux with
| LB_val (pat, exp) ->
@@ -407,8 +407,12 @@ and doc_letbind (LB_aux (lb_aux, _)) =
let doc_funcl funcl = string "FUNCL"
-let doc_funcl (FCL_aux (FCL_Funcl (id, pexp), _)) =
- group (separate space [doc_id id; doc_pexp "=" pexp])
+let doc_funcl (FCL_aux (FCL_Funcl (id, Pat_aux (pexp,_)), _)) =
+ match pexp with
+ | Pat_exp (pat,exp) ->
+ group (separate space [doc_id id; doc_pat pat; equals; doc_exp exp])
+ | Pat_when (pat,wh,exp) ->
+ group (separate space [doc_id id; parens (separate space [doc_pat pat; string "if"; doc_exp wh]); string "="; doc_exp exp])
let doc_default (DT_aux(df,_)) = match df with
| DT_kind(bk,v) -> string "DT_kind" (* separate space [string "default"; doc_bkind bk; doc_var v] *)