Hi,

I hacked Dave's nodeDump to output in XML.

$cat sample.rb
name = "Ruby"
print "Hello, " + name

$ruby -rNodeXmlDump sample.rb
<?xml version="1.0"?>
<NodeXmlDump version="0.1.2">

<NODE_BLOCK>
  <NODE_NEWLINE file="/home/maki/sample.rb" nth="1">
    <NODE_LASGN cnt="2">
      <NODE_STR><![CDATA[Ruby]]>      </NODE_STR>
    </NODE_LASGN>
  </NODE_NEWLINE>
  <NODE_NEWLINE file="/home/maki/sample.rb" nth="2">
    <NODE_FCALL to="function" mid="6377" name="print">
      <parameters>
        <NODE_ARRAY size="1">
          <NODE_CALL to="method" mid="43" name="+">
            <receiver>
              <NODE_STR><![CDATA[Hello, ]]>              </NODE_STR>
            </receiver>
            <parameters>
              <NODE_ARRAY size="1">
                <NODE_LVAR cnt="2">
                </NODE_LVAR>
              </NODE_ARRAY>
            </parameters>
          </NODE_CALL>
        </NODE_ARRAY>
      </parameters>
    </NODE_FCALL>
  </NODE_NEWLINE>
</NODE_BLOCK>

</NodeXmlDump>


I think XML'ed dumped nodes like this is useful to
"Ruby in Java" and/or "Ruby in Ruby" approach. Building
internal tree from XML is easier than Building one
from Ruby's source code.


* original interpreter

            +-----original ruby interpreter-------------+
            |                                           |
 ruby code ===>  internal parsed tree  ==>   execute!   |
            |                                           |
            +-------------------------------------------+

* full Ruby in Java (or Ruby in Ruby) approach

            +-----Ruby in Java (or Ruby in Ruby) interpreter--+
            |                                                 |
 ruby code ===>  internal parsed tree  ==>   execute!         |
            |                                                 |
            +-------------------------------------------------+


* half Ruby in Java (or Ruby in Ruby) approach


            +-- original ruby parser ---+
            |                           |
 ruby code ===>  internal parsed tree  ===>  node tree in XML
            |                           |
            +---------------------------+

                   +- Ruby in Java (or Ruby in Ruby) evaluter -+
                   |                                           |
 node tree in XML ===>  internal parsed tree ===> execute!     |
                   |                                           |
                   +-------------------------------------------+

This library is not finished, but the concept of this is good for
something, I think.


Best Regards,

TAKAHASHI 'Maki' Masayoshi     E-mail: maki / open-news.com