From: Robert Feldt Date: 2001-12-12T23:40:16+09:00 Subject: [ruby-talk:28345] Re: Rendering UML diagrams? On Wed, 12 Dec 2001, Pierre-Charles David wrote: > > I adopted the lexer from irb, and the top-level parser from rtags. I > > then added a recursive-descent parse for the stuff I neded. The > > combination works very well, and is about 1700 lines of Ruby. However, > > it will definitely need tidying up over time, as it carries with it > > some or its irb heritage. > > Just an idea: it seems to me that lots of projects need a Ruby parser, > but everybody is reimplementing his own (probably > incomplete/buggy/inefficient). The Ruby interpreter already does all > this work, so would not it be simpler to "open" the parser and to > provide an interface to client programs? I'm thinking of something > like 'Ruby.parse(aString)' which would return a (simplified) AST (with > comments kept to allow RubyDoc and friends). IIRC, Smalltalk has > something like this, correct? > > I have no idea how difficult it would be to implement, but it would > greatly simplify the development of all kinds of tools. If the current > interpreter structure is too complicated to hack, maybe this feature > could be included in Rite? > Yes, I agree that it would be a good thing. However, its been discussed before and Matz has said he's not willing to open up such internals. Maybe things are changing for Rite; I don't know. Before going for a full RubyInRuby parser I did Ruth which wraps the internal parse trees into Ruby objects that you can manipulate. Its in the rubyvm.sf.net CVS if you want to take a look. Have'nt touched it in a while though. Regards, Robert