[antlr-interest] org.antlr.runtime.tree.RewriteEmptyStreamException

David Maier David.Maier at ingres.com
Wed Jul 7 09:19:18 PDT 2010


Hello,


I am getting the following error message as Output of a tree generating grammar which I am currently writing. 

Exception in thread "main" org.antlr.runtime.tree.RewriteEmptyStreamException: rule sp_decls
        at org.antlr.runtime.tree.RewriteRuleElementStream._next(RewriteRuleElementStream.java:158)
	at org.antlr.runtime.tree.RewriteRuleElementStream.nextTree(RewriteRuleElementStream.java:145)
	at com.ingres.antlr.idiom.mysql.MySQLASTGenParser.sp_block_content(MySQLASTGenParser.java:10730)
	at com.ingres.antlr.idiom.mysql.MySQLASTGenParser.sp_unlabeled_block(MySQLASTGenParser.java:9691)
	at com.ingres.antlr.idiom.mysql.MySQLASTGenParser.sp_proc_stmt(MySQLASTGenParser.java:8577)
	at com.ingres.antlr.idiom.mysql.MySQLASTGenParser.sp_tail(MySQLASTGenParser.java:1691)
	at com.ingres.antlr.idiom.mysql.MySQLASTGenParser.no_definer_tail(MySQLASTGenParser.java:1541)
	at com.ingres.antlr.idiom.mysql.MySQLASTGenParser.view_or_trigger_or_sp_or_event(MySQLASTGenParser.java:1401)
	at com.ingres.antlr.idiom.mysql.MySQLASTGenParser.create(MySQLASTGenParser.java:1260)
	at com.ingres.antlr.idiom.mysql.MySQLASTGenParser.stmt(MySQLASTGenParser.java:1186)
	at com.ingres.antlr.idiom.mysql.MySQLASTGenParser.prog(MySQLASTGenParser.java:1117)
	at __Test__.main(__Test__.java:16)

So the last rules are looking as the following:

sp_unlabeled_block:
          
          sp_block_content
          
        ;

sp_block_content:
          BEGIN_SYM
          
          sp_decls
          sp_proc_stmts
          END  -> sp_decls sp_proc_stmts //To ignore the BEGIN and END
        ;

sp_decls:  (sp_decl ';')* -> (sp_decl)*;

sp_decl:
	          DECLARE_SYM sp_decl_idents
	          
	          type
	          (sp_opt_default)? -> ^(TN_DECLARE ^(TN_PARAMS  sp_decl_idents type) ^(TN_TODO sp_opt_default)?)
	        
	          
	        | DECLARE_SYM ident CURSOR_SYM FOR_SYM sp_cursor_stmt ->  ^(TN_DECLARE ^(TN_NAME ident) ^(TN_SELECT sp_cursor_stmt))
	          
	        ;


There is a TN_CODE token type which I want to use as the root node of the subtree which will then have this TN_DECLARE nodes as child nodes. So I only did rewrite the rules 'between' TN_CODE and TN_DECLARE to remove unnecessary information like the ';' or the BEGIN and END keywords.
 
So I guess that the error occurs because my test input does not have a DECLARE section, but this is OK because of the rule 'sp_decls:  (sp_decl ';')* -> (sp_decl)*;
' which says that there could be even no one (*=0 or multiple). So has anybody an answer what is causing the issue and how to solve it?


BTW: Further information about the project is available here: http://community.ingres.com/wiki/Ingres_Migration_Tool_Set_Idiom_MySQL


Regards, David


--
David Maier
Senior Software Engineer

Ingres Germany GmbH
Weimarer Straße 1a
D-98693 Ilmenau

PHONE:  +49.3677.6785-59
FAX:    +49.3677.6785-23
MAIL:   david.maier at ingres.com

This transmission is confidential and intended solely for the use of the recipient named above. It may contain confidential, proprietary, or legally privileged information. If you are not the intended recipient, you are hereby notified that any unauthorized review, use, disclosure or distribution is strictly prohibited. If you have received this transmission in error, please contact the sender by reply e-mail and delete the original transmission and all copies from your system.



More information about the antlr-interest mailing list