[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.

Thanks,
Matt

// Single-line comments
SL_COMMENT
	:	"//"
		(~('\n'|'\r'))* (NL)?
		{$setType(Token.SKIP);}
	;

protected
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.
http://videogames.yahoo.com/platform?platform=120121


More information about the antlr-interest mailing list