diff --git a/camlp4/etc/pa_o.ml b/camlp4/etc/pa_o.ml index c67650386..ff01b3ca0 100644 --- a/camlp4/etc/pa_o.ml +++ b/camlp4/etc/pa_o.ml @@ -521,8 +521,10 @@ EXTEND | "try"; e = SELF; "with"; OPT "|"; l = LIST1 match_case SEP "|" -> <:expr< try $e$ with [ $list:l$ ] >> | "if"; e1 = SELF; "then"; e2 = expr LEVEL "expr1"; - e3 = [ "else"; e = expr LEVEL "expr1" -> e | -> <:expr< () >> ] -> + "else"; e3 = expr LEVEL "expr1" -> <:expr< if $e1$ then $e2$ else $e3$ >> + | "if"; e1 = SELF; "then"; e2 = expr LEVEL "expr1" -> + <:expr< if $e1$ then $e2$ else () >> | "for"; i = LIDENT; "="; e1 = SELF; df = direction_flag; e2 = SELF; "do"; e = SELF; "done" -> <:expr< for $i$ = $e1$ $to:df$ $e2$ do { $list:get_seq e$ } >> diff --git a/camlp4/meta/pa_r.ml b/camlp4/meta/pa_r.ml index dbf6fc555..181d97504 100644 --- a/camlp4/meta/pa_r.ml +++ b/camlp4/meta/pa_r.ml @@ -262,14 +262,14 @@ EXTEND | "fun"; "["; l = LIST0 match_case SEP "|"; "]" -> <:expr< fun [ $list:l$ ] >> | "fun"; p = ipatt; e = fun_def -> <:expr< fun $p$ -> $e$ >> - | "match"; x = SELF; "with"; "["; l = LIST0 match_case SEP "|"; "]" -> - <:expr< match $x$ with [ $list:l$ ] >> - | "match"; x = SELF; "with"; p = ipatt; "->"; e = SELF -> - <:expr< match $x$ with $p$ -> $e$ >> - | "try"; x = SELF; "with"; "["; l = LIST0 match_case SEP "|"; "]" -> - <:expr< try $x$ with [ $list:l$ ] >> - | "try"; x = SELF; "with"; p = ipatt; "->"; e = SELF -> - <:expr< try $x$ with $p$ -> $e$ >> + | "match"; e = SELF; "with"; "["; l = LIST0 match_case SEP "|"; "]" -> + <:expr< match $e$ with [ $list:l$ ] >> + | "match"; e = SELF; "with"; p1 = ipatt; "->"; e1 = SELF -> + <:expr< match $e$ with $p1$ -> $e1$ >> + | "try"; e = SELF; "with"; "["; l = LIST0 match_case SEP "|"; "]" -> + <:expr< try $e$ with [ $list:l$ ] >> + | "try"; e = SELF; "with"; p1 = ipatt; "->"; e1 = SELF -> + <:expr< try $e$ with $p1$ -> $e1$ >> | "if"; e1 = SELF; "then"; e2 = SELF; "else"; e3 = SELF -> <:expr< if $e1$ then $e2$ else $e3$ >> | "do"; "{"; seq = sequence; "}" ->