[antlr-interest] Comments/newlines

Lars Heuer heuer at semagia.com
Fri Sep 30 05:12:16 PDT 2005


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();}
      ;

Best regards,
Lars
-- 
http://semagia.com



More information about the antlr-interest mailing list