[antlr-interest] $FIRST $FOLLOW
Ulrich Frank
Ulrich.Frank at dlr.de
Tue Feb 7 06:10:55 PST 2006
Hello InterestGroup.
I've the following problem and perhaps you can help me. I hope so. I
have to build an application which should recognice some kind of OQL
(Object Query Language) grammar. Ok, thats not the problem. I wrote an
appopriate grammar. If I parse a sample String like "select attr from
obj" I get the information if the String respects the OQL grammar or not.
But what i want to do is the following: When I write the String "Select
sdf" and push then CTRL-Space there shoult be a context menu which shows
me all the posibilities which are correct at this position (just like in
Eclipse f.e.). In this case only "from" should be shown. If I write
something like "select" and push CTRL-Space, the shown list should
include 'ATTR_ID' and 'from', whereas ATTR_ID is the Token (Symbol) for
an attribute at this position in the grammar. The rule looks like "query
: "select" (ATTR_ID)? "from" OBJ_ID ("where" ...)?.
So how can I realize this?? I know I have to access $FIRST and $FOLLOW
respectively which is accessible in the grammar file. But I firstly need
this information in the main java class where i create a parser object
and my gui and secondly I do not need the BitSet (=$FIRST,$FOLLOW) but
the names of the Tokens (Symbols), ATTR_ID f.e. When I'm right, i can
get the last thing by matching it with the entries in the
...TokenTypes.txt file but isn't there a better/faster way?
Thanks,
Ulrich Frank
More information about the antlr-interest
mailing list