[antlr-interest] a range as single token?

Bart Kiers bkiers at gmail.com
Sat Jan 15 04:35:53 PST 2011


On Sat, Jan 15, 2011 at 1:23 PM, fikin <nikolai.fiikov at gmail.com> wrote:

> right. is there a way to make the lexer provide "line" content as
> single token as opposing to a container of "char" tokens?
>

Sure, like this:

lines   :       CHARS (NEWLINE CHARS)*;
NEWLINE :       '\r'? '\n';
CHARS   :       '\u0020'..'\u007F'+;


And if there can be empty lines, do:

lines   :       CHARS? (NEWLINE CHARS?)*;


Regards,

Bart.


More information about the antlr-interest mailing list