[antlr-interest] Rewriting Rule Problem
Ralf Hund
rhund at rumms.uni-mannheim.de
Mon Nov 3 10:40:36 PST 2008
Hello everyone,
I started working with ANTLR a few days ago and ran into a problem with
certain rewriting rules. Basically, there is the following rule:
exprOr : exprXor (opGroupOr exprXor)*;
I want an AST node to be created everytime the parentheses* *matches. My
first solution was to apply the following rewrite rule:
exprOr : l=exprXor (o=opGroupOr r=exprXor -> ^(Expression $l $o $r))*;
However, this always results in a RewriteEmptyStreamException. Which is
kind of strange since the following rules work perfectly:
exprOrRight : opGroupOr exprXor -> ^(Expression opGroupOr exprXor);
exprOr : l=exprXor (exprOrRight)*;
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?
Cheers,
Ralf Hund
More information about the antlr-interest
mailing list