[antlr-interest] Lexer rule SL_COMMENT (any java grammar)
Alexey Demakov
demakov at ispras.ru
Wed Nov 16 07:31:52 PST 2005
Hi,
I use the following rule for single line comments:
SL_COMMENT : "//"
( ~( '\n' | '\r' ) )*
/*
* single line comment may not
* be followed by new line
* at the end of file
*/
( NL )?
;
NL : ( {LA(2) == '\n'}? '\r' '\n'
| '\r'
| '\n'
)
{ newline(); }
;
Regards,
Alexey
-----
Alexey Demakov
TreeDL: Tree Description Language: http://treedl.sourceforge.net
RedVerst Group: http://www.unitesk.com
----- Original Message -----
From: "Thomas N." <thn-d at gmx.de>
To: <antlr-interest at antlr.org>
Sent: Wednesday, November 16, 2005 4:40 PM
Subject: [antlr-interest] Lexer rule SL_COMMENT (any java grammar)
> Hi,
>
> the lexer rule (found in any java grammar)
>
> SL_COMMENT
> : "//"
> (~('\n'|'\r'))* ('\n'|'\r'('\n')?)
> { $setType(Token.SKIP); newline(); }
> ;
>
> loops if the single line comment is at the end of the .java file and does
> not end with a newline. Unfortunately, the java compiler allows such
> comments. How can this bug be fixed (by consifering EOF)?
>
> Regards,
> Thomas N.
>
> --
> 10 GB Mailbox, 100 FreeSMS/Monat http://www.gmx.net/de/go/topmail
> +++ GMX - die erste Adresse für Mail, Message, More +++
>
More information about the antlr-interest
mailing list