My take would be to use precedence where the reader would generally expect it. The only example I can think of this is expressions. People know that expression syntax has precedence, and that precedence is generally fairly uniform across languages. Also the use of precedence here can dramatically reduce the number of rules.
I would avoid using precedence rules to disambiguate in other cases, as the reader would probably not be expecting the use of precedence and not know to look at the head of the file for the precedence rules. Also, you will probably only save one or two rules in other cases. -Bruce On Wed, Feb 10, 2010 at 2:46 PM, Paul Melis <[email protected]> wrote: > Hello, > > Does anybody have any insights on the relative merits of using > precedence values versus explicit precedence encoding using a larger > number of rules. To make the latter more concrete, take this excerpt > from the Python grammar description at > http://www.python.org/doc/2.5.2/ref/grammar.txt: > > power ::= primary ["**" u_expr] > > u_expr ::= power | "-" u_expr | "+" u_expr | "\~" u_expr > > m_expr ::= u_expr > | m_expr "*" u_expr > | m_expr "//" u_expr > | m_expr "/" u_expr > | m_expr "\%" u_expr > > a_expr ::= m_expr | a_expr "+" m_expr | a_expr "-" m_expr > > shift_expr ::= a_expr | shift_expr ( "<<" | ">>" ) a_expr > > Thanks in advance, > Paul > > -- > You received this message because you are subscribed to the Google Groups > "ply-hack" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<ply-hack%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/ply-hack?hl=en. > > -- You received this message because you are subscribed to the Google Groups "ply-hack" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/ply-hack?hl=en.
