[antlr-interest] Rewriting to Flat Tree Nodes for Associative Multiary Operators
Randall R Schulz
rschulz at sonic.net
Thu Oct 2 14:23:09 PDT 2008
Hi,
Next question.
(I've been spoiled by working mostly with strictly prefix languages in
the past...)
How might I alter a rule such as this one:
op790Formula
: (op780Formula -> op780Formula)
(
Or rDisjunct = op790Formula
-> ^(Or $op790Formula $rDisjunct)
) ?
;
(parenthetically:
op780Formula
: ... // Next higher level of operator precedence (And)
;
)
which, when given input like this:
p | q | r | s
produces this sort of tree:
(Or p (Or q (Or r s)))
so that I instead get this:
(Or p q r s)
Every variation I've tried either gives me the fully nested tree or
elicits a org.antlr.runtime.tree.RewriteEmptyStreamException.
Thanks in advance (again).
Randall Schulz
More information about the antlr-interest
mailing list