[antlr-interest] Problem with EOF and infinite recursion

kitu kitu k2k2e6 at yahoo.com
Mon Aug 9 15:47:26 PDT 2004


I have the following grammar and for certain large inputs, I keep on
getting stack overflow. I am assuming that it is due to left recursion
in my grammar. Also, I cannot seem to tell Antlr how to deal with the
EOF. Also DOT keeps on giving me non-determinism problem even though
the code seems to run.

-Pawan

Here is the sample grammar:

class MyParser extends Parser;

options { k=2; buildAST=true; }

wholeinput:  toklist  EOF!
		;

toklist:  Number toklist
		| floating toklist
		| ALPHA toklist
		| WS toklist
		| PUNCT toklist
		| NEWLINE toklist
		| OTHER toklist
		;

floating: Number DOT Number
		| DOT Number
	;



class GeneratedLexer extends Lexer;

options { k=2; filter=true; }


ALPHA   : ('a'..'z'|'A'..'Z')+
        ;
        
        	  
Number : ('0'..'9')+ 
	   ;
	   	           
WS     :
    (' '| '\t')+
  ;
  
NEWLINE :
	('\r' | '\n' | "\r\n" )
	;
	
OTHER :
	('\u0000'..'\u0008' | '\u000B'..'\u000C' | '\u000E'..'\u001F' |
'\u007F')+
	;
	
DOT :
	('\u002E')
		;
        
PUNCT :
	('\u0021'..'\u002D' |'\u002F' | '\u003A'..'\u0040' |
'\u005B'..'\u0060' | '\u007B'..'\u007E')
	;






 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

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



More information about the antlr-interest mailing list