[antlr-interest] TreeWalker to optimize AST under certain conditions
Tilman Bender
tbender at stud.hs-heilbronn.de
Wed Apr 1 09:48:12 PDT 2009
Hi everybody,
I am trying to make a simple compiler for a language that does simple
arithmetic expression and read/write operations.
I have a parser generating an AST. Now I would like to walk that AST
an alter/rewrite it by removing superflous subtrees.
e.g:
When I get a subtree for an addition saying:
^(ADD 0 expr ) or ^(ADD expr 0) the subtree should be replaced by just
expr
The same applies to multiplications with one or zero: remove the
subtree and replace it by one of the operands or zero.
How could I achieve this with a tree-grammar?
kind regards
Tilman Bender
Student des Software Engineering
Hochschule Heilbronn
tbender at stud.hs-heilbronn.de
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090401/74958a52/attachment.html
More information about the antlr-interest
mailing list