From: Ryan Davis Date: 2010-08-19T07:26:17+09:00 Subject: Re: Ruby Code Parsing On Aug 18, 2010, at 13:31 , Jonathan Bale wrote: > I have a Perl friend asking me questions about how ruby parses its code. > Things like, how does it know where a statement ends and where can you > and can't you put new lines -- basically trying to understand how Ruby > differs from Perl and from Python in regard to parsing Ruby code. > > I have a good /practical/ understanding of how it works, but have > difficulty delineating in one e-mail all the rules of how it works. Is > there a particular document (please give specific section) on the > Internet that I could link him to that explains all the rules? Well... You can look at ruby_parser.y in the ruby_parser gem. It is "only" ~1800 lines long. I wouldn't recommend it tho, except as evidence that it is statically parseable. The long and the short of it is that it is somewhere between perl (which basically can't be statically parsed) and python (which I can't mentally parse (because of things like list comprehensions are anything but comprehensible to me), but which is highly regular).