[antlr-interest] Tree Rewrite Rule Problem

DJB MASTER DJBall05 at hotmail.co.uk
Tue Nov 6 07:33:22 PST 2012


I'm trying to convert this tree...

<http://antlr.1301665.n2.nabble.com/file/n7579128/listTree.jpg> 

...into this tree...

<http://antlr.1301665.n2.nabble.com/file/n7579128/semanticTree.jpg> 

I'm using a Tree Grammar with pattern matching and this is the rule I've
tried...

*findInfix : ^(MROW (lefts=.*) left=.  MO right=. (rights=.*)) -> ^(MROW
$lefts* ^(MO $left $right) $rights*);*

In the tree *+* is represented by the *MO* token.

On running the tree grammar rewriter I get the following rewrite...

*(mrow (mi a) + (mi b) + (mi c)) -> (mrow + (+ (mi b) (mi c)))*

I don't know which part of my rule is wrong, because it is leaving out the
'lefts' part of the tree in the rewrite.

Here is a Eclipse project showing the erroneous rewrite...

https://dl.dropbox.com/u/46743877/MathML.zip
<https://dl.dropbox.com/u/46743877/MathML.zip>  

Thanks for any help.



--
View this message in context: http://antlr.1301665.n2.nabble.com/Tree-Rewrite-Rule-Problem-tp7579128.html
Sent from the ANTLR mailing list archive at Nabble.com.


More information about the antlr-interest mailing list