From: Robert Feldt Date: 2001-02-25T17:13:28+09:00 Subject: [ruby-talk:11517] Re: RFC: RubyVM (long) On Mon, 19 Feb 2001, Mathieu Bouchard wrote: > > I'll tell you what I've done so far on this parser gen: > > > > * Specified a grammar for grammars (its similar to SableCC's format, but > > even simpler with Ruby RegExp'sfor the tokens) > > * Hand-coded this grammar > > * Implemented the LALR(1)-gen algs in Dragon book > > * A really simple lexer gen that simply applies the token regexps in > > order until a match is found (This may not give good enough performance > > but we can do a more traditional DFA-based gen later...) > > * Generated a grammar parser from the handcoded grammar > > Could you send me that? > It's been a busy week but I'll try to pack it up and send it in the coming days. > > Next is extensive testing (Ok, in the name of pragmatism I wrote > > some tests prior to implementation but sadly they dont cover > > everything... ;-) > > Don't forget peer review. Automated tests are not sufficient. They never > cover everything. They are there to ensure that you've got a minimum of > things working. > Yeah, you're right but I don't even have tests to show the minimum is working... ;-) > > Next step is getting a Ruby parser by converting parse.y to the grammar > > format of the parser gen. > > Oh. I thought you had started doing this as well. This would be a good > thing to do soon. Whatever. What I recommend is that you publish what you > have ASAP. =) > Yeah, I'll pack it up and then start working on the Ruby parser. > > > Actually, a strict subset of Ruby syntax, in such a way that the Ruby > > > parser class can inherit from the Ruby-- parser class. > > The Grammar class I've used supports this kind of "merging" of grammars > > (and thus of parsers). > > Yippee!!! nau zat iz kewl! > > (sorry for this burst of enthusiasm) > Wel,, don't expect too much; I simply add the productions of one grammar to the ones of another. No checking that the merge is possible or that they "connect" (through a nonterminal or whatever). Do you know a "right"/better/more useful way to merge grammars? > > Basically, Ruby-- would lack at least: > > > * for, case..when > > > * flip-flop operator > > > * reversed form of if, unless, while, until > > > * multiple assignment > > > * yield (use & declarator and .call() instead) > > > Why these? I guess yield and the flip-flop may not be straightforward to > > translate to C but IMHO the other ones should be possible? > > It's possible that people reimplement all the features of Array#[], > Array#[]= for their own class; it's possible, but it's not funny. > > Look at the amount of code that was necessary to write BitArray (sample > usage of MetaRuby). This supports most of Array's features. > I agree, its both beautiful, cool and important. Keep up the good work! Minor comment on ArrayMixin: (I haven't checked it thoroughly so maybe you already do this) Wouldn't it be better if put_many and get_many wasn't part of the Interface but was defined in ArrayMixin in terms of put/get. Then if people want better performance they can override these default version by defining their own and faster ones? > I see no reason why the language itself should not have a restricted > version and a full version. The pattern is exactly the same. > I see your point and now agrees. > > I think excluding yield would be a major hindrance since it is > > frequently used in iterators. > > Well it's not a hindrance at all for me. I just use the & declarator to > pick up the special parameter, and then perform a .call on it where i > could do yield. > You're right; that should be sufficient. > > I've translated gc.c (not all of it but doing a OO design > > based on the existing stuff) so far. > > This will be interesting to see. > I'll post it. Aleksi mentioned maybe this should go into a cvs some place. Whats the eval criteria for being allowed to sit on the ruby cvs? How do you get "listed"? > > memory. I think it would not be natural for a Ruby developer to use > > something different than an iterator for this => yield is needed in > > RootSet implementation => yield is needed in sRuby/Ruby--. > > Ok, see above. "Iterators" are a library feature. "yield" is just > sugar. As long as we have closures (and the & declarator) I don't think > we've got a problem. > I agree. Regards, Robert