The current precedence levels used when printing seem to have some minor inconsistencies which lead to the absence or redundancy of parentheses in some places. These occur in a couple different situations:
open Nv_lang
(* a function for reprinting parsed strings *)
let f s = Printing.exp_to_string (Parser.expreof Lexer.token (Lexing.from_string s);;
(* operator function arguments are missing parentheses *)
let s = "foldNodes (fun u -> fun v -> fun acc -> assert_node u v && acc) sol true";;
f s;; (* u"foldNodes fun u~0 -> fun v~0 -> fun acc~0 -> ((assert_node~0 u~0 ) v~0 ) && acc~0 sol~0 true" *)
(* extra parentheses around function bodies *)
let t = "fun u -> fun v -> match (u,v) with | (None, None) -> false | (_, _) -> true";;
f t;; (* u"fun u~0 -> fun v~0 -> (match (u~0,v~0) with \n | (None,None) -> false\n | (_,_) -> true\n) " *)
I'd like to fix these inconsistencies but I'm not too familiar with how the precedence levels align between the printer and the parser.
The current precedence levels used when printing seem to have some minor inconsistencies which lead to the absence or redundancy of parentheses in some places. These occur in a couple different situations:
I'd like to fix these inconsistencies but I'm not too familiar with how the precedence levels align between the printer and the parser.