Tilman Bender wrote: > 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? Download the examples on the download page and use the polydiff example as a guide. This isn't your homework is it?
Jim List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to il-antlr-interest@googlegroups.com To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~----------~----~----~----~------~----~------~--~---