[antlr-interest] ANTLR 2: single-line comment lexing with no newline

Matt Benson gudnabrsam at yahoo.com
Thu Mar 8 11:03:19 PST 2007

I have the following lexer rules (can't remember how
much of them are copied vs. original).  My intent is,
as implied by my subject line, to recognize a
single-line comment at the end of the file--an old
problem.  I am seeing ANTLR spin forever when it hits
the comment with these rules.  Can anyone see what
might be wrong?  Rules follow.


// Single-line comments
	:	"//"
		(~('\n'|'\r'))* (NL)?

NL : ( {LA(2) == '\n'}? '\r' '\n'
       | '\r'
       | '\n'
     { newline(); }

Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! Games.

More information about the antlr-interest mailing list