At 20:41 +0000 2005/03/03, Derek M Jones wrote:
>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 +).

The normal way to resolve this would be to let the lexer check the lookup
table to see what y is: a type or a number identifier, and then return that
type. WHy does this not work for you.

>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.

The commands %left and %right handles left and right associativity.

  Hans Aberg




_______________________________________________
Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison

Reply via email to