Daniel Ribeiro
Daniel Ribeiro

Reputation: 3119

Ruby (MRI) Syntax Tree nodes documentation

The meaning of most nodes from mri's syntax tree can be easily infered. However the list is quite long (source: bin/parse_tree_abc):

:attrasgn, :attrset, :dasgn_curr, :iasgn, :lasgn, :masgn,
:and, :case, :else, :if, :iter, :or, :rescue, :until, :when, :while,
:call, :fcall, :super, :vcall, :yield,
:args, :argscat, :array, :begin, :block, :block_arg, :block_pass, :bool,
:cfunc, :colon2, :const, :cvar, :defined, :defn, :dregx, :dstr, :dvar,
:dxstr, :ensure, :false, :fbody, :gvar, :hash, :ivar, :lit, :long, :lvar,
:match2, :match3, :nil, :not, :nth_ref, :return, :scope, :self, :str,
:splat, :to_ary, :true, :unknown, :value, :void, :zarray, :zarray,
:zclass, :zsuper

Since Python's AST manipulation is a builtin library, its documentation is far better. Is there a place where all nodes from parse tree's syntax tree is documented?

Upvotes: 1

Views: 483

Answers (1)

Jörg W Mittag
Jörg W Mittag

Reputation: 369458

There is no such thing as a Ruby AST, therefore there is no documentation for it. Every implementation has its own AST, which might or might not be documented.

Besides, what you are talking about is not the abstract syntax tree but the parse tree (aka concrete syntax tree), which is, by definition, closely tied to the specific parser used to construct it. Different parsers might construct very different parse trees for the same code and the same syntax.

What you show there looks like the parse tree from either MRI or YARV, both of which are notoriously badly documented.

Upvotes: 1

Related Questions