[Rubygrammar-grammarians] Ruby Grammar Project
MenTaLguY
mental at rydia.net
Fri Nov 25 19:44:57 EST 2005
On Fri, 2005-11-25 at 15:19 -0800, Terence Parr wrote:
> Kewl. If I knew ruby syntax, we'd be done with the grammar now. :
> ( I just finished my first script to build and test my v3 ANTLR
> examples. Works great! Amazing...Java collections seem so bare in
> comparison now. Back to closure blocks...oh smalltalk how I missed
> you! ;))
Ah, you're just scratching the surface. I'll warn you -- from here on
it can get addictive. :)
> If I had a canonical list of constructs including tricky examples, it
> would really help.
Hmm, I'm hoping some of the grammarian-newcomers can help out with that,
but to start off here are some bits with method calls:
First:
foo bar baz
(where foo and bar are method names) parses the same as:
foo( bar( baz ) )
Note that omitting the parenthesis for more than one function in the
"stack" is deprecated, however.
Next:
def foo
zort = 3 # assign to variable
blah = zort # assign to variable from variable
...
end
versus:
def foo
blah = zort # assign to variable from method result
zort = 3 # assign to variable
...
end
I am not sure that 'blah = zort' is parsed differently in these cases,
however; that subtree may look the same in the AST and simply get
interpreted differently.
Next:
foo 1, 2, 3 # ok
foo(1, 2, 3) # ok
bar(1, 2, 3) { ... } # ok
bar 1, 2, 3 { ... } # parse error
bar 1, 2, baz { ... } # parses as bar(1, 2, baz { ... })
-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/20051125/a93f96f9/attachment.bin
More information about the Rubygrammar-grammarians
mailing list