[antlr-interest] Re: single line comment
William Lam <xeenman at yahoo.com>
xeenman at yahoo.com
Tue Jan 28 11:54:07 PST 2003
antlr complains about not finding the EOF rule.
adding a final ? at the end seems to take care of things
SL_COMMENT
: "//"
(~('\n'|'\r'))* ('\n'|'\r'('\n')?)?
{$setType(Token.SKIP); newline();}
;
--- In antlr-interest at yahoogroups.com, mzukowski at y... wrote:
> I believe you can explicitly match EOF in the lexer, I know you can
in the
> parser....
> Try it and see.
>
> Monty
>
> -----Original Message-----
> From: William Lam <xeenman at y...> [mailto:xeenman at y...]
> Sent: Monday, January 27, 2003 6:39 PM
> To: antlr-interest at yahoogroups.com
> Subject: [antlr-interest] single line comment
>
>
> Hi I am trying to implement a single line comment in my lexer. I
> looked at the java.g single line comment. It works great if a
> newline is at the end of the comment, but fails when an EOF is
> encountered, saying
>
> unexpected char: ?
>
> I browsed through the archives and message 4617 talks about this
> problem.
>
> SL_COMMENT
> : "//"
> (~('\n'|'\r'))* ('\n'|'\r'('\n')?)
> {$setType(Token.SKIP); newline();}
> ;
>
>
>
>
> Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list