Hello MetaRuby-Folk,

I would like to release a pre-alpha version of my RubyInRubyParser. It's a
direct translation of matz' one into Ruby code. It's already quite complete,
but still missing are:

  lots of type-checking for the produced AST ( try 'self = myself' )

  definition of singleton methods

  strings, re, %q %Q %w %r

  flipflop

  BEGIN/END-block

  reverse rescue

  proc


find it at the cvs-repository

http://sourceforge.net/projects/rubyvm/




--------------------------------------- README:


RubyInRubyParser 0.1-pre-alpha.



If you are not interested in building a VM for Ruby or Syntax
highlighting for your favourite Editor, then - probably - this is not
especially interesting for you.


The parser translates Ruby code from a string to an abstract syntax
tree. Thats nothing special, because the Ruby interpreter does it each
time when it should execute a script. What turns the RubyInRubyParser
into something special, is, that it's written in Ruby and that all the
objects the AST is made of are Ruby objects.

The structures of these objects are defined in RubySchema.rb from
matju's MetaRuby effort. I've contacted matju, asking for
incorporating my changes into MetaRuby. Probably this will happen
later and his files will disappear here.


It's a translation of matz' parse.y (CVS 1.112), but now get's
compiled with Racc. I've used Racc 1.3.8 and '1.3.11-2 unstable', both
work fine. 

lexer.rb is not paradis-like code. I tried to let the control-flows
stay the same, so, later it will be easier to keep in sync with matz'
parse.y. 

also parse.y: The productions are exactly the same, (and in same
order); except the addition of the token tSVAR, for Special
Variables. 



The structure of the produced AST will change in future releases. At
first the 'ok' from matju is still missing, and I don't want to get in
a dead end...

Especially, I'm not sure how to represent Attributes. The code 'a.o=9'
is parsed to 

  Ruby::Assign[ Ruby::A[ Ruby::LVar[:a], :o], Ruby::LAtom[9] ]

where this would also be nice:

  Ruby::M[ Ruby::LVar[:a], :o=, [Ruby::LAtom[9]], nil, nil]]]

and this would be an other option:

  Ruby::Assign[ Ruby::A[ Ruby::LVar[:a], :o=], Ruby::LAtom[9] ]

But then there is a problem with block_var, since it can not be
reformated this way. Would be one inconsistency more. 



Thanks...

  to matz for Ruby.

  to matju for MetaRuby and the type-checking AST. It helps.

  to Minero Aoki for Racc (and for respecting yacc)


You can find links to MetaRuby and Racc in the RAA.







The current state:

Look at ParserTest.rb, call it with `make`, or `make debug`


The code:

You will find masses of untranslated C code from matz. It will step by
step disappear during the approach to v1.0.


Schroedinger's cat:

Tokens that can be local variables or method calls are parsed to
LVar[] elements. A running interpreter can decide it. It may be
better, to use a separate Type for this case, but i've no clear
ideas at the moment.



Missing:

  lots of type-checking for the produced AST ( try 'self = myself' )

  definition of singleton methods

  strings, re, %q %Q %w %r

  flipflop

  BEGIN/END-block

  reverse rescue

  proc



-- 
-------------------------------------------------