[antlr-interest] semantic differentiation
Ulrich Frank
Ulrich.Frank at dlr.de
Fri Feb 10 02:35:20 PST 2006
The variable is called first because it represents the $FIRST-set.
And therefore it is correct, that it contains the last value
encountered - explicit. I need this construct because of that: the
input is a string, f.e. "select from ttt where sss" and then I push
CTRL-space. Then, a popup goes up and shows me all posibilities which
are correct at this position of the grammar. In the example above:
<=, <, >=, >. I get these posibilities by looking at $FIRST and
therefore $FIRST should always be saved in the variable first because
then I only have to look what first consists of and can show it in
the popup.
The problem I have now is, that IDENT after select and IDENT after
from cannot be differentiated, so the user can't decide, which should
come next. In the former one there should be an object (OQL not SQL)
in the latter one an attribute of this object.
Any ideas??
-----
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20060210/6d4487f3/attachment.html
More information about the antlr-interest
mailing list