[antlr-interest] semantic differentiation
Ulrich Frank
Ulrich.Frank at dlr.de
Fri Feb 10 01:04:50 PST 2006
Hello,
I've a new question: when I define something like
IDENT : ( 'a'..'z' | '0'..'9' )*
in my lexer and then I have rules in my grammar like
{
private String first = "first";
public String getFirst() { return first; }
}
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.
Greets, Uli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20060210/ff8d4a15/attachment-0001.html
More information about the antlr-interest
mailing list