[antlr-interest] Lexer problem

Terence Parr parrt at jguru.com
Thu Dec 27 22:40:10 PST 2001


On Thursday, December 27, 2001, at 09:40  PM, manfredlotz wrote:

> Using the definiton shown below the lexer has a problem to recognize
> tokens if they arrive in a certain order.
>
> E.g.,  ".a.a.b$" or ".ac$" work fine, however ".a.b$" does not.
>
> Any idea what I have to change to make it working. I know it has to do
> with the fact that ".a" is a substring of ".a.a" but I don't know how
> to improve the t.g file.
>
> Manfred
> _____________________
>
> class TLexer extends Lexer;
> options {
>         k=4;
>         filter=IGNORE;
> }
>
> MYENDTOKEN   : '$' ;
>
> A       :   ( ".a" | ".a.a" | ".b" | 'a' | 'c' )  ;
>
> protected
> IGNORE  : ( "\r\n" | '\r' | '\n'  ) { _ttype = Token.SKIP; };

Looks ok to me.  Can you be more specific about what it says?  Try using 
-traceLexer on antlr cmd-line and then compile and run it.  See where 
it's going.

Ter
--
Chief Scientist & Co-founder, http://www.jguru.com
Creator, ANTLR Parser Generator: http://www.antlr.org


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list