[antlr-interest] In-place rewrites
swalton
swalton at cs.utah.edu
Tue Jun 1 10:14:11 PDT 2010
I am trying to do some "in-place" rewrites where the tree parser is
modified as it is parsed. There are six loci where I desire to add a
procedure call:
1) Before a procedure call -- Create a block that calls method_new after
method_org
(call method_org (params_org))
=>
(block (call method_new (params_new)) (call method_org (params_org)))
2) After a procedure call -- Create a block that calls method_new after
method_org
(call method_org (params_org))
=>
(block (call method_org (params_new)) (call method_new (params_new)))
3) Around a procedure call -- Replace call with a "call_through" which
permits a call pointer inside method_new
(call method_org (params_org))
=>
(call_through method_new (params_new) method_org (params_org))
4) Before a procedure execution -- Place a call to method_new at beginning
of block
(proc name (block ...))
=>
(proc (block (call method_new params_new) ...))
5) After a procedure execution -- Place a call to method_new at end and at
every "return" command
(proc name (block ... (return) ...))
=>
(proc name (block ... (block (call method_new params_new) (return))
... (call method_new params_new)))
6) Around a procedure execution -- Detach proc declaration into a delegate
and place a call in its stead
(proc name_org (params_org) (block ...))
=>
(declarations ... (proc name_org (block (call_through method_new
(params_new) method_org (params_org)))) ... (proc delegate (params_org)
(block ...))
Can anyone help?
-Sean Walton
PhD Student
School of Computing
University of Utah
More information about the antlr-interest
mailing list