At 07:40 4/11/2008, Ralf Hund wrote:
 >    exprOr : l=exprXor (o=opGroupOr r=exprXor -> ^(Expression $l 
$o
 >$r))*;
 >
 >However, this always results in a RewriteEmptyStreamException.

This means that one of the expressions you're trying to insert 
into the AST is an empty tree, which suggests that there's 
something optional in one of the subrules, or they're not 
producing the tree you think they are.

 >However there's no way to access $l in exprOrRight as it's in a
 >different rule(at least i'm not aware of any way to do that). Is 

 >there any simpler way to solve the problem? What am I doing 
wrong?

It's possible to pass $l into the subrule as a parameter and use 
it that way, but I doubt that's what you really want to do.  Your 
original rule above will only work properly for zero or one 
matches of the parenthetic block -- as soon as you hit two or 
more, you'll lose some of the input.  It's better to write it like 
this:

exprOr
   : (exprXor -> exprXor)
     (o=opGroupOr r=exprXor -> ^(Expression $exprOr $o $r))*
   ;

If your operator was a single token instead of a subrule 
invokation (and you wanted the operator to be the root of the 
tree, which is fairly common), you could alternatively write it 
like this:

exprOr
   : exprXor (OR^ exprXor)*
   ;

Or:

exprOr
   : exprXor ((OR1^ | OR2^) exprXor)*
   ;


List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to