[antlr-interest] grammar for single-line comments
Mark Volkmann
r.mark.volkmann at gmail.com
Wed Oct 10 13:08:32 PDT 2007
I'm having trouble adding support for single-line comments to my grammar.
It's probably a simple mistake, but I don't see it.
Here's the part of my grammar that deals with comments.
COMMENT_LINE:
'#'
(options { greedy = false; } : .)*
(NEWLINE | EOF)
{ $channel = HIDDEN; };
NEWLINE: '\r'? '\n' { $channel = HIDDEN; };
My sample input is just a single comment line with no NEWLINE at the end.
# This is a comment.
I get these error messages from the generated parser.
line 1:1 mismatched character ' ' expecting '<EOF>'
line 1:19 no viable alternative at character '.'
--
R. Mark Volkmann
Object Computing, Inc.
More information about the antlr-interest
mailing list