[antlr-interest] semantic differentiation

Bryan Ewbank ewbank at gmail.com
Fri Feb 10 02:03:45 PST 2006


Is it sufficient simply to set another variable (type_first) to
indicate which place generated the value of first?

Also, <query2> and <query3> (for example) look suspicious because
you've named this variable "first".  After processing, the variable
will contain the /last/ value encountered.

On 2/10/06, Ulrich Frank <Ulrich.Frank at dlr.de> wrote:
>
> query  : { first=$FIRST.toString(); } "select" query2 ;
> query2 : { first=$FIRST.toString(); } (IDENT)? query3 ;
> query3 : { first=$FIRST.toString(); } "from" query4 ;
> query4 : { first=$FIRST.toString(); } IDENT query5 ;
> query5 : { first=$FIRST.toString(); } ("where" query6)? ;
> query6 : { first=$FIRST.toString(); } IDENT query7 ;
> query7 : { first=$FIRST.toString(); } ("<" | "<=" | ">" | ">=") query8 ;
> query8 : { first=$FIRST.toString(); } IDENT ;
>
> The problem I have is that I want to distinguish the IDENT in query2 and the
> IDENT in query4. I have to do something in the parser, but what (semantic
> action, but how)?? Any idea? I need this because when I analyze $FIRST in
> another java class, I have to know if the IDENT I got from getFirst() is the
> IDENT from rule query2 or the IDENT from rule query4.


More information about the antlr-interest mailing list