From: Benoit Cerrina Date: 2001-12-30T20:18:17+09:00 Subject: [ruby-talk:29718] Re: Ruby parsers in Ruby "Phil Tomson" wrote in message news:qJyX7.1428$Xe4.1226@news.webusenet.com... > Wouldn't it be cool to have Ruby playing with Parrot before Python or even > perhaps Perl? That could be a real coup. > > Dan Sugalski has suggested that it would be very helpful if we had a Ruby > parser written in Ruby. It would initially need to spit out Parrot > bytecode, but eventually we could give him an AST. > > Now, it seems to me that we have at least a couple of projects where we > parse Ruby in Ruby (actually, three that I know of): > 1) Markus Liedl's Ruby parser - it was announced a while back on > Rubygarden that it was recently imported into the CVS tree (I think that > means Ruby's CVS tree). > 2) JRuby - It must have a frontend parser written in Ruby and then emits > Java bytecode, right? Wrong, this wouldn't work well since it would need ruby first and in any case we are not yet emitting java bytecode. It started like a translation of the c ruby interpreter in java and is being refactored to enable it to emit java bytecode. So it has a java ruby parser which builds an AST which is intepreted. > 3) Matju's AST - which produces an abstract syntax tree of a Ruby program. > > Is there any possibility that efforts can be merged in this area? It > seems that we have three options available and there must be a pretty good > amount of code out there already for a Ruby parser written in pure Ruby, > so instead of maintaining three different code bases perhaps we could > create one Ruby in Ruby parser frontend (based on picking the best > elements of the above three) and then create different 'backends'. > The frontend would create an AST which could be fed to the different > backends: > JRuby - emits Java bytecode > PRuby - emits Parrot bytecode > RRuby - emits Ruby bytecode for upcomeing Rite VM This would be nice, however as far as JRuby is concerned this would be like starting from scratch, the code we are writing is all in java and the Java bytecode will be emited by a java library. Of course we could use our Ruby java interop layer to call in the java library from Ruby but in this case only jruby would be able to interpret the JRuby backend and we have a chicken and egg problem. > > While competition has it merits, I think this is an area where we as a > community could benefit from joining forces instead of duplicating effort. > > Can anyone involved in the above three projects (or any other similar ones > I might have missed) comment on the status of these projects and the > feasability of merging them? > > Phil > Benoit one of the JRuby developers