All, The statement (y)+z can be parsed as casting +z to the type y, or as adding y to z. A couple of %dprecs solve this problem (I think the cast is the common case for - and a binary expression for +). However, things are more complicated for x + (y) + z, whose parse tree can be either
+ / \ x ( ) / \ y + | z or + / \ + z / \ x (y) As currently implemented the %dprec functionality does not appear to be any help here. Effectively, it will only select between two productions that consume the same number of input tokens. At the moment the only solution I can think of is to change the grammar for additive-expressions from left recursive to right recursive, ie from add-expr: mul-expr | add-expr '+' mult-expr | add-expr '-' mult-expr ; to add-expr: mul-expr | mult-expr '+' add-expr | mult-expr '-' add-expr ; I don't like rewriting grammar like this and I'm sure more complicated cases will arise (I know there are other operators that need to be handled for this example). What is needed is a get-out-of-ambiguity option. The %gooa option would take a single argument which specified the weight of a production. When two or more ambiguous parses are encountered the weights of the various productions involved would be added up and the one with the greatest weight selected. derek -- Derek M Jones tel: +44 (0) 1252 520 667 Knowledge Software Ltd mailto:[EMAIL PROTECTED] Applications Standards Conformance Testing http://www.knosof.co.uk _______________________________________________ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison