[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: x + (y) + z

From: Hans Aberg
Subject: Re: x + (y) + z
Date: Fri, 04 Mar 2005 19:07:52 +0100
User-agent: Microsoft-Outlook-Express-Macintosh-Edition/5.0.6

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
>               +
>              /   \
>            +     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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]