From: Charles Oliver Nutter Date: 2007-11-16T17:26:47+09:00 Subject: Re: Alternative Ruby grammar Markus Liedl wrote: > I have spent the last months to write an alternative Ruby grammar now > registered at rubyforge.org under the name "Ruby top down grammar". > > The grammar is hosting language neutral. It must be interpreted or > translated to be run, i.e. to parse something. Currently there are two > translators, one to Emacs Lisp, the other to C. Both produce recursive > descent parsers. I would be interested in hearing more about the translation process, and the possibility of producing RDPs in Ruby and Java. > Without being sure, I'd like to claim the grammar is close to cover > 100% of the Ruby language. It does, for example, parse Ruby stdlib > completely. I'm not sure how much a measure that is; a parser could parse every token as a literal "1" and it would parse everything, but it wouldn't mean it's correct. Perhaps it's possible to roundtrip from the parsed result back to Ruby code and see whether the result is roughly the same as the original? > On the bad side parsers using this grammar work slower. Even the > faster of both implementations is many times slower than the MRI > parser. Do you expect this can be improved? If there's a performance hit for using this parser it will substantially limit adoption. > Also, the abstract syntax trees produced by this grammar have a > different structure than the ones produced by MRI parser. No big deal for JRuby at least; I don't expect it would take more than a few days to write a new interpreter based on the new AST. The compiler might take a few more days beyond that. What's your goal with this? At the moment, I don't like that there's only two "mostly correct" parsers in existence: Ruby's Bison-based parser and JRuby's Jay-based parser. They're both pretty painful to work with and evolve. - Charlie