[antlr-interest] Comments/newlines
Sohail Somani
sohail at taggedtype.net
Sat Oct 1 09:39:18 PDT 2005
On Fri, 2005-30-09 at 14:12 +0200, Lars Heuer wrote:
> Hi Sohail,
>
> > How would you define a lexer to tokenize the following so that the
> > grammar rules use EOL?
>
> > x = y // some comment
> > // some comment
> > x = y
>
> Maybe this works:
>
> COMMENT : "//" (~('\r'|'\n'))+ {$setType(Token.SKIP);}
> ;
>
> EOL : ('\r')? '\n' {newline();}
> ;
>
Yes this works. I don't know what I was thinking when I wrote my rule
for the comments.
Thanks!
More information about the antlr-interest
mailing list