I'm trying to realize a Lisp-like macro mechanism in Perl to get a general and reliable extension mechanism.
I successfully hacked B::Deparse such that function calls to macros are replaced with the string returned.
This works fine when translating the body of single functions with B::Deparse::coderef2text the resulting code is evaluated afterwards to replace the body.
Now I'm looking for ideas how to this for complete files.
My current approach is to use a codefilter to wrap the whole file with
macroexpand { ... oldfile ... }
But it gets tricky when handling __DATA__ and __END__ and anyway the idea was to get rid of codefilters
So does anybody know of a way to change the op-tree just after compilation?
I'm pondering to modify B::Deparse::compile for this purpose and to call it within CHECK { ... } or UNITCHECK {...}
An other approach would be to reset the implicit DATA filehandle to reread the code just after compilation phase.
Any brain storming idea is welcome.
Cheers Rolf
In reply to Implicetely deparse, change and replace perlcode in file by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |