On Thu, Mar 12, 2009 at 09:38:28AM +0000, Joel Reymont wrote: >> To my understanding, precendence levels correspond to the level you >> define in the grammar, in the given order : in your case, you have >> "=", "+" at the same level, with higher precendence than "And" and >> "*". > What about this quote from the camlp4 manual? > > "An entry is composed of entry precedence levels, the first one being > the least precedent and the last one the most." > > I'm assuming that my expr counts as one rule where '+' and '=' have > lesser precedence than 'and' and '*' since those follow after.
In case of doubt, it's better to refer to Camlp4RevisedParser.ml, as said before (I don't even remember where the camlp4 manual is, I just open that file routinely when I'm about to do some camlp4 hacking :). In Camlp4RevisedParser.ml, expr is defined as: expr: [ "top" RIGHTA ... | "+" LEFTA [ e1 = SELF; op = infixop2; e2 = SELF -> <:expr< $op$ $e1$ $e2$ >> ] | "*" LEFTA ... | e1 = SELF; op = infixop3; e2 = SELF -> <:expr< $op$ $e1$ $e2$ >> ] (infixop3 is *, / or %) | "**" RIGHTA ... | "unary minus" NONA [ "-"; e = SELF -> mkumin _loc "-" e | "-."; e = SELF -> mkumin _loc "-." e ] So the levels are indeed listed in increasing order of precedence. This might be of use, despite being for camlp4 pre-3.10: http://martin.jambon.free.fr/extend-ocaml-syntax.html#priorities -- Mauricio Fernandez - http://eigenclass.org _______________________________________________ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs