[antlr-interest] Lexer Strangeness

Terence Parr parrt at cs.usfca.edu
Tue Mar 13 13:21:49 PDT 2007


On Feb 13, 2007, at 1:15 PM, Scott Fortmann-Roe wrote:

> Hi,
>
> I am having a small issue with matching line comments in the lexer.
> The following code works correctly:
>
> fragment NEWLINE
>       :       '\r'|'\n'
> ;
> LINECOMMENT
>       :       '//' (~('\r'|'\n'))* NEWLINE {$channel=HIDDEN;}
> ;
>
>
> But if I convert the line comment command to the following form ANTLR
> complains that the start state cannot be found for the rule:
>
> LINECOMMENT
>       :       '//' (~(NEWLINE))* NEWLINE {$channel=HIDDEN;}
> ;
>
> I am having a hard time seeing how these are functionally different.
> I'm a noob though so please help.

Hmm...that is a parser error not lexer.  I wonder if you are missing  
some other rules?

Ter



More information about the antlr-interest mailing list