From: ptkwt@...1.aracnet.com (Phil Tomson) Date: 2002-10-24T02:41:07+09:00 Subject: Re: NODE tree introspection In article <86fzuxuppd.fsf@squash.oucs.ox.ac.uk>, Simon Cozens wrote: > >I've been considering writing something for Ruby similar to the Perl >B.pm module; this is a module which provides Perl-level access to the >bytecode op tree, so that other modules can walk the op tree in >various interesting ways. This is the way the Perl to C compiler was >implemented. (however unsuccessfully...) > >It seems reasonably easy to do in Ruby, just by wrapping the NODE* >structures as Ruby objects. Has anyone already done this or tried >working on it? > Hmmmm.... interesting idea. So basically what you're proposing would be able to walk the AST of the currently running program (or any arbitrary snippet that you send off to eval?)? I actually have some use for this kind of thing so if you do it please keep us informed. I don't think anyone has approached the problem in the way you propose. Can you give some more details of how you're thinking of doing it? I know that Bob Calco is working on a Ruby parser based on Matz' Ruby yacc file and he intends it to be a Ruby extension (on second thought, maybe what he is doing is similar to what you're thinking of doing). Phil