[Ironruby-core] Code Review: RubyAST

Tomas Matousek Tomas.Matousek at microsoft.com
Fri Aug 15 12:22:25 EDT 2008

tfpt review "/shelveset:RubyAST;REDMOND\tomat"

Merges Statement with Expression in AST. Gets rid of ExpressionStatement to make ASTs smaller.
Any AST expression can be now emitted as statement (i.e. we don't need its value) by Transform method and any statement can be emitted as expression by TransformRead method.

The grammar considers a construct a syntactic statement if the grammar doesn't allow it to be read in an assignment rhs or pass it as an argument to a method call.
For example,

a = return 1
foo(return 1)
foo(1 if false)

are not valid Ruby statements, therefore 'return <expr>' and '<stmt> if <expr>' are syntactic statements.

If a statement is used in begin ... end or (...) block as the last statement its value becomes the value of the block. This way a value of some statements can be retrieved (e.g. alias foo bar, undef x, <stmt> if <expr>, <stmt> while <expr>). Most of such statements have nil value, some of them however might evaluate to a non-nil value (e.g. <stmt> if <expr>).


-------------- next part --------------
A non-text attachment was scrubbed...
Name: RubyAST.diff
Type: application/octet-stream
Size: 76771 bytes
Desc: RubyAST.diff
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20080815/3be7f7df/attachment-0001.obj>

More information about the Ironruby-core mailing list