[antlr-interest] Lexer problem: distinguish between TIC and CHAR_LITERAL

"Daniel Zuberbühler" dzubi at users.sourceforge.net
Tue Sep 13 05:23:53 PDT 2005


Hi 

I have a problem with the Ada Grammer.
In some cases the Lexer matches a CHARACTER_LITERAL instead of a single
TIC. These are the two rules:

TIC : { LA(3)!='\'' }? '\'' ;

CHARACTER_LITERAL : { LA(3)=='\'' }? "'" . "'" ;

The character literal is defined as two tics with one character in between.
To decide if a tic is a TIC or the beginning of a CHARACTER_LITERAL, we
check if at LA(3) follows another tic or not.
This works generally quite fine, but not with the following code fragment: 

new String'('b' & Second_Char);

here we have a TIC followed by a parenthesis and a CHARACTER_LITERAL.
Obviously the Lexer can't recognize that.

I'd be grateful for any pointer how to solve this problem.

Thanks and cheers,
Daniel



More information about the antlr-interest mailing list