diff options
| author | Gabriel Kerneis | 2014-05-15 14:27:13 +0100 |
|---|---|---|
| committer | Gabriel Kerneis | 2014-05-15 14:27:13 +0100 |
| commit | 4f2783c25141accdeb2afc26cc5a3657f705e7d8 (patch) | |
| tree | a7f79be75e1a645cd09bd251688f49a0c2068df2 | |
| parent | 952038a6be7a267fb8440d055e2f2ff299f782e4 (diff) | |
Exhaustive check of app_infix operators for precedence
| -rw-r--r-- | src/pretty_print.ml | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/pretty_print.ml b/src/pretty_print.ml index bc438eb2..d10a124b 100644 --- a/src/pretty_print.ml +++ b/src/pretty_print.ml @@ -1122,11 +1122,28 @@ and doc_exp e = | E_let(leb,e) -> doc_let leb ^/^ string "in" ^/^ exp e (* adding parens and loop for lower precedence *) | E_app (_, _)|E_vector_access (_, _)|E_vector_subrange (_, _, _) - | E_cons (_, _)|E_field (_, _)|E_assign (_, _) -> + | E_cons (_, _)|E_field (_, _)|E_assign (_, _) + | E_app_infix (_, + (* for every app_infix operator caught at a higher precedence, + * we need to wrap around with parens *) + (Id_aux(Id("|" | "||" + | "&" | "&&" + | "=" | "==" | "!=" + | ">=" | ">=_s" | ">=_u" | ">" | ">_s" | ">_u" + | "<=" | "<=_s" | "<" | "<_s" | "<_si" | "<_u" + | "@" | "^^" | "^" | "~^" + | ":" + | ">>" | ">>>" | "<<" | "<<<" + | "+" | "-" + | "*" | "/" + | "div" | "quot" | "rem" | "mod" + | "*_s" | "*_si" | "*_u" | "*_ui" + | "**"), _)) + , _) -> group (parens (exp expr)) (* XXX default precedence for app_infix? *) | E_app_infix(l,op,r) -> - failwith ("unexpected app_infix operator" ^ (pp_format_id op)) + failwith ("unexpected app_infix operator " ^ (pp_format_id op)) (* doc_op (doc_id op) (exp l) (exp r) *) (* XXX missing case *) | E_internal_cast ((_, Overload (_, _)), _) | E_internal_exp _ -> assert false |
