[antlr-interest] Non-local optimizations with treewalker?

Sohail Somani sohail at taggedtype.net
Fri Sep 14 13:07:07 PDT 2007


Hi,

Is it feasible/intelligent to do non-local optimizations with an antlr
(2.7.6) treewalker? I specify 2.7.6 because the readme for antlr3 says
that it might crash on syntax errors!

For example, assuming immutable variables and no side-effects:

v = f(x)
...
w = f(x)

I'd like to transform into:

temp = f(x)
v = temp
...
w = temp

I think it isn't the smartest thing to use treewalkers for this but I'd
like to be wrong, preferably with a verbose beat down as to why.

Thanks,

Sohail


More information about the antlr-interest mailing list