[antlr-interest] Lexer Strangeness
Shmuel Siegel
ssiegel at finjan.com
Wed Feb 14 02:10:15 PST 2007
The way I look at this is:
In the lexer, '~' is a set operator. It says to use all of the other
symbols from the vocabulary. NEWLINE is neither a character nor a set of
characters; hence, set complement doesn't have any meaning.
Hope that this works for you.
-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Scott
Fortmann-Roe
Sent: Tuesday, February 13, 2007 11:15 PM
To: antlr-interest at antlr.org
Subject: [antlr-interest] Lexer Strangeness
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.
Thanks, Scott
More information about the antlr-interest
mailing list