From: Charles Thornton <ceo@hawthorne-press.com>
To: ruby-core@ruby-lang.org
Subject: Re: IRHG -- Dumping T-Nodes
Date: Sun, 10 Feb 2008 04:27:00 +0900 [thread overview]
Message-ID: <47ADFEEA.5000704@hawthorne-press.com> (raw)
In-Reply-To: <47ADEDA3.7070106@gmail.com>
Thanks,
I will study your info,
Chuck T.
Phlip wrote:
> Charles Thornton wrote:
>
>> I have been looking a 'rubynode' .
>>
>> The problem is I don't have a clear idea of the
>> actual structure of the AST.
>>
>> I assume that their is a tree structure of Nodes
>
> Yep. For some, the tree is simply a transliteration of the input. 'if
> x then y end' turns into an 'if' node with leaves containing a
> condition, a 'then' node, and an 'else' node. (So does ? : , by the way!)
>
> For others Ruby statements, the tree is deep and sick. For example,
> all the arguments of a function, and some of its local variables, are
> packed up into a node called "scope", where they don't exactly match
> their location in the source.
>
> Pull down these files and play with them:
>
> http://phlip.svnrepository.com/svn/yar_wiki/lib/assert_2_0.rb
> http://phlip.svnrepository.com/svn/yar_wiki/lib/ruby_reflector.rb
> http://phlip.svnrepository.com/svn/yar_wiki/test/assert_2_0_test.rb
> http://phlip.svnrepository.com/svn/yar_wiki/test/ruby_reflector_test.rb
>
> They should, roughly, how to disassemble a transformed list of
> RubyNode objects back into a rough form of Ruby source. To see a tree
> of nodes in action, add pp node to any of the functions like def _if,
> and run all the tests.
>
prev parent reply other threads:[~2008-02-09 19:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-09 8:03 IRHG -- Dumping T-Nodes Charles Thornton
2008-02-09 9:04 ` Eric Hodel
2008-02-09 10:18 ` Charles Thornton
2008-02-09 18:14 ` Phlip
2008-02-09 19:27 ` Charles Thornton [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47ADFEEA.5000704@hawthorne-press.com \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).