[antlr-interest] Bison-> Antlr 3 help
Mike Aubury
antlr at aubit.com
Fri Oct 20 09:14:27 PDT 2006
What I need is for BEFORE to only be the BEFORE token when its valid as a
token at that point in the grammar.
If its not valid - that I'd want it to be an identifier - I'm not sure that
the keyword stuff below would do that ?
FWIW - I spent weeks getting a lexer to only allow tokens that were allowed at
that state for use with bison (basically had to decipher the generated
y.output = major pain)..
If possible - I'd really like to avoid having to do that again!
On Friday 20 October 2006 17:06, Jim Idle wrote:
> You would need an identifier rule and a keyword_id rule, you might also
> want to use hoisted predicates if there are places where the keywords are
> not identifiers such as where an identifier is optional and can be
> logically followed by some keyword, but basically something akin to:
>
> identifier: ID | ( options {k=1;} : (keyword_id)=>keyword_id) ;
>
> keyword_id: KEYWORD1 | KEYWORD2 |KEYWORD3 ....
>
> This won't work for everything though, your own grammar requirements will
> have to be built in to it of course to avoid all the ensuing ambiguities.
>
> Jim
--
Mike Aubury
More information about the antlr-interest
mailing list