[antlr-interest] Problem using predicates in V3

Terence Parr parrt at cs.usfca.edu
Sun Feb 11 12:38:55 PST 2007


On Feb 11, 2007, at 12:26 PM, Dr. Hartmut Kocher wrote:

> I know that this is ambiguous. That's why I tried to solve it with a
> predicate. I need both definitions. In other places in the grammar  
> I have
> identifiers like "t123a". Still 'abc' must always be parsed as  
> 'abc' never
> as identifier. That means 'abc2' must be parsed as 'abc' INT even  
> though it
> matches the definition of the ID token.
>
> So I need to force the lexer to never parse 'abc' as ID.

Oh, you have a context-sensitivity problem.  First thing.  Try not to  
do that.  Either redesign your language or send hate mail to the  
designer. ;)  Now, it might be a simple problem.  Just match ID w/o  
digits and then put back together later using the context from the  
parser.

identifierInSomeCase : IDENT INT? {put backtogether} ;

Ter



More information about the antlr-interest mailing list