Ruby Forum IronRuby > Code Review: RubyAST

Posted by Tomas Matousek (Guest)
on 15.08.2008 18:24
Attachment: RubyAST.diff (75 KB)
(Received via mailing list)
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.

Notes:
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>).

Tomas
Posted by Oleg Tkachenko (Guest)
on 15.08.2008 18:48
(Received via mailing list)
Finalizer.cs and Initializer.cs still contain empty //TODO: comments. 
It's not obvious to me from the context what should be TODO.
Otherwise looks great.

--
Oleg
Posted by Tomas Matousek (Guest)
on 15.08.2008 18:51
(Received via mailing list)
The nodes are not implemented at all.

Tomas