[antlr-interest] ANTLR 3.1 gives RewriteEmptyStreamException, ANTLR3.0.1 does not ?

Jim Idle jimi at temporal-wave.com
Mon Sep 29 13:56:05 PDT 2008


On Tue, 2008-09-30 at 09:44 +1300, David Pearce wrote:

> Hi Terence,
> 
> > Yes.  you must use
> > 
> >> list : '(' listBody ')' -> ^(LIST listBody?)
> > 
> > not
> > 
> >> list : '(' listBody ')' -> ^(LIST listBody)
> > 
> > clearly listBody can be optional, right?
> 
> Yes, in this case it is definitely optional.  But, in the Java grammar 
> case it is not:


The annotation of the grammar is not required to be the same, and is not
always the same, as the annotation of the rewrite.

Your grammar rule may not be optional, but it may or may not produce a
tree. Hence the rewrite rules needs to be told that the tree produced by
that rule may or may not be there, and you just use ->^(BLAH BLHA rule?)

Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080929/0f765879/attachment.html 


More information about the antlr-interest mailing list