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

Jon Schewe jpschewe at mtu.net
Mon Jan 14 15:40:10 PST 2008


David Holroyd wrote:
> On Mon, Jan 14, 2008 at 02:26:26PM -0600, Jon Schewe wrote:
>   
>> I just got time to get back to this project, been stuck on a different 
>> one.  I tried your suggestion of gathering everything up in a variable 
>> and that didn't help.  Still the same error. 
>>
>> /**
>> * @param negate if true, negate all expressions by multiplying by -1
>> */   
>> multExpr[boolean negate]
>>    :   a+=atom (PRODUCT a+=atom)* -> {negate}? ^(PRODUCT ^(NUMBER DOUBLE["-1"]) $a)
>>                                   ->           ^(PRODUCT $a)
>>    ;
>>
>>    [junit]     Caused an ERROR
>>    [junit] token PRODUCT
>>    [junit] org.antlr.runtime.tree.RewriteEmptyStreamException: token PRODUCT
>>     
>
> You can't fix just by writing PRODUCT* on the r.h.s., as a tree with
> zero-or-more root nodes doesn't make sense.
>
> Also, do you really always want to create a tree with PRODUCT as the
> root here, even if PRODUCT is not in the input?  I would have thought
> that if no PRODUCT is present, you'd just want 'atom'?
>
>   
Yes, I really want to always have PRODUCT, at least that's how my tree
walker is setup right now.  It makes for a more regular tree.  Is the
problem that antlr can't figure out which PRODUCT token to use?

-- 
Jon Schewe | http://mtu.net/~jpschewe
If you see an attachment named signature.asc, this is my digital
signature.
See http://www.gnupg.org for more information.

For I am convinced that neither death nor life, neither angels 
nor demons, neither the present nor the future, nor any 
powers, neither height nor depth, nor anything else in all 
creation, will be able to separate us from the love of God that 
is in Christ Jesus our Lord. - Romans 8:38-39



More information about the antlr-interest mailing list