[antlr-interest] handling single-line comments
Mark Volkmann
r.mark.volkmann at gmail.com
Wed Dec 12 08:10:05 PST 2007
Here's a grammar containing just three lexer rules.
grammar BadLexer;
COMMENT: '#' (~'\n')* NEWLINE { $channel = HIDDEN; };
NEWLINE: ('\r'? '\n')+ { $channel = HIDDEN; };
WHITESPACE: (' '|'\t')+ { $channel = HIDDEN; };
When I run Grammar ... Check Grammar on it in ANTLRWorks I get the
following warning.
warning(200): BadLexer.g:3:20: Decision can match input such as
"{'\u0000'..'\t', '\u000B'..'\uFFFE'}" using multiple alternatives: 1,
2
As a result, alternative(s) 2 were disabled for that input
There must be a better way to write the COMMENT rule. Suggestions
would be appreciated.
--
R. Mark Volkmann
Object Computing, Inc.
More information about the antlr-interest
mailing list