[antlr-interest] Re: Problems with EOF

Xue Yong Zhi seclib at seclib.com
Thu Jan 5 09:44:50 PST 2006


Please explain your problem in a better way. I do not understand what do 
you mean by "the parser stay on cycle and do nothing". I think the 
parser will terminate anyway if it meets EOF. Can you give the shortest 
grammar which can duplicate your problem? For example, something like this:

program:
	:	(SL_COMMENT	|	ML_COMMENT)	EOF
	;

RamosD.External at infineon.com wrote:
> I have problems with my parsers...
> 
> If I have the end of file in last line of script, the parser stay on
> cycle and do nothing.
> 
> Please help me,  I cant understand this problem.
> 
> MY CODE:
> 
> // Single-line comments
> SL_COMMENT
> 	:	"//"
> 		(~('\n'|'\r'))* ('\n'|'\r'('\n')?)?
> 		{$setType(Token.SKIP); newline();}
> 	;
> 
> // multiple-line comments
> ML_COMMENT
> 	:	"/*"
> 		(	
> 			options {
> 				generateAmbigWarnings=false;
> 			}
> 		:
> 			{ LA(2)!='/' }? '*'
> 		|	'\r' '\n'		{newline();}
> 		|	'\r'			{newline();}
> 		|	'\n'			{newline();}
> 		|	~('*'|'\n'|'\r')
> 		)*
> 		"*/"
> 		{$setType(Token.SKIP);newline();}
> 	;
> THANKS,
> 
> Daniel Ramos
> 


-- 
Xue Yong Zhi
http://seclib.blogspot.com



More information about the antlr-interest mailing list