[Rubygrammar-grammarians] Ruby Grammar Project

MenTaLguY mental at rydia.net
Sat Nov 26 22:27:33 EST 2005


On Sat, 2005-11-26 at 11:54 -0800, Terence Parr wrote:
> Ah.  So the AST construction treats referenced values as method  
> calls?  Interesting.  So the AST construction routine has to have  
> flow analysis to see if something is defined on the path of that  
> execution?  That doesn't sound like a very easy approach.  Imagine
> 
> if ...
> 	zort=3
> end
> blah = zort
> 
> In this case, which tree do you generate?  The flow analysis is the  
> only thing that can answer that...something usually WAY further down  
> the compilation pipe.

Actually flow analysis isn't required.  For example:

if false
  zort = 3
end
blah = zort

Will result in zort being treated as a variable (with a value of nil,
since it never gets anything assigned to it).

For a bare identifier to be treated as a variable (rather than a method
call), it's sufficient for an assignment to it to appear anywhere prior
to that point within a method body.

-mental
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://rubyforge.org/pipermail/rubygrammar-grammarians/attachments/20051126/4b6aab2c/attachment.bin


More information about the Rubygrammar-grammarians mailing list