[antlr-interest] Re: single line comment

mzukowski at yci.com mzukowski at yci.com
Tue Jan 28 11:58:26 PST 2003


I can't think of a situation that would break that, let us know if you ever
find a problem with it.

Monty

-----Original Message-----
From: William Lam <xeenman at yahoo.com> [mailto:xeenman at yahoo.com]
Sent: Tuesday, January 28, 2003 11:54 AM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] Re: single line comment


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/ 


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list