[antlr-interest] Tree pattern won't rewrite AST C#

DJB MASTER DJBall05 at hotmail.co.uk
Tue Jul 12 20:37:59 PDT 2011


Hey, I'm trying to apply simple tree patterns that can remove redundancy in
multiplication expressions, such as x*0 -> 0. However I can't get it to
rewrite my AST I feed in.

I'm using again >>>
http://media.pragprog.com/titles/tpdsl/code/IR/Vec/VecMathAST.g 

and I'm using this as my simplifier >>
http://media.pragprog.com/titles/tpdsl/code/walking/patterns/Simplify.g.

I'm getting a correct AST because it's identical to what Terrance gets in
the LP book.

I'm using this code to call my simplifier...

CommonTree AST = (CommonTree)parser.statlist().Tree;        

CommonTreeNodeStream nodes = new CommonTreeNodeStream(AST);
nodes.TokenStream = tokens;

Simplifier simplifier = new Simplifier(nodes);
CommonTree AST = (CommonTree)simplifier.Downup(AST, true);

But it seems to do nothing.

--
View this message in context: http://antlr.1301665.n2.nabble.com/Tree-pattern-won-t-rewrite-AST-C-tp6577614p6577614.html
Sent from the ANTLR mailing list archive at Nabble.com.


More information about the antlr-interest mailing list