[antlr-interest] RewriteEmptyStreamException when changing from quoted string to token?

Ola Bini ola.bini at gmail.com
Fri Jan 4 11:06:52 PST 2008


Jon Schewe wrote:
> I have the following parser rule and lexer rule (others exist as well). 
> I'm using antlr 3.0.1.  If I change '*' in multExpr to PRODUCT then at
> runtime I get an exception.  If I leave it at '*', all is fine.  What am
> I doing wrong here?
>    [junit] token PRODUCT
>     [junit] org.antlr.runtime.tree.RewriteEmptyStreamException: token
> PRODUCT
>     [junit]     at
> org.antlr.runtime.tree.RewriteRuleElementStream._next(RewriteRuleElementStream.java:158)
>     [junit]     at
> org.antlr.runtime.tree.RewriteRuleTokenStream.next(RewriteRuleTokenStream.java:57)
>  
>
> /**
>  * @param negate if true, negate all expressions by multiplying by -1
>  */   
> multExpr[boolean negate]
>     :   atom ('*' atom)* -> {negate}? ^(PRODUCT ^(NUMBER DOUBLE["-1"])
> atom+)
>                              ->           ^(PRODUCT atom+)
>     ;
>
> PRODUCT         :   '*'     ;
>   
I have seen the same problem, and have no idea why this happens.

-- 
 Ola Bini (http://ola-bini.blogspot.com) 
 JRuby Core Developer
 Developer, ThoughtWorks Studios (http://studios.thoughtworks.com)
 Practical JRuby on Rails (http://apress.com/book/view/9781590598818)

 "Yields falsehood when quined" yields falsehood when quined.




More information about the antlr-interest mailing list