cardinal-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Cardinal-dev] Parsers


From: Phil Tomson
Subject: Re: [Cardinal-dev] Parsers
Date: Thu, 14 Nov 2002 09:53:42 -0800 (PST)

On Wed, 13 Nov 2002, David Robins wrote:

> On Wed, 13 Nov 2002, Dan Sugalski wrote:
>
> > >I'd love to use a parser understanding EBNF as a basis instead of the
> > >parsers currently available wich interact directly with bison/yacc.
>
> Rockit purports to understand EBNF, but unfortunately it looks to be very
> early alpha and hasn't been updated for a while.
>
> > You might want to take a look at the yacc parser in the parrot tree
> > now. Granted it's in perl, and we won't go into arguments about that
> > now, but it does produce a parser for ruby, and might be a good place
> > to start.
>
> Doesn't seem to be finished: of the tests in languages/ruby/t, 01 fails
> after test 14, 02 after 1; in languages/ruby/Yacc, all fail after 1.
>
> If there is a parser that can generate an AST - whatever its language
> (except INTERCAL, but it scoffs at data structures anyway) - that would be
> nice to know.  Could someone that's been around parrot/ruby longer than I
> have perhaps post a list of any _working_ Ruby parsers here?  Or see if we
> can persuade whoever was working on the current code in languages/ruby to
> return to it and finish it?
>

I believe both ripper and ruth are 'working' ruby parsers.  Ruth can
produce an AST - there are some node types that still need definition.
Both of them rely on Matz's Ruby parse.y (yacc) file (or modified
parse.y).  The advantage of this is that they're 100% compliant with
whatever version of Ruby they were written for.  The disadvantage is that
if Matz changes the parse.y for future versions of Ruby they won't be 100%
compliant.

There is also a Ruby parser in the Ruby CVS tree under a directory called
ruby-parser.  The goal of this one is to produce a pure ruby
implementation by using racc on a modified version of Matz's parse.y file
(there's the yacc grammar again).  I haven't tried this one out.
Here's a blurb from the README:

"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 use a customized version of it. The
translation to the matju's current version will happen later.

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. "

I also know that Bob Calco is working on a Ruby parser extension (not
written in Ruby) that will be usable from Ruby (or from C apparently, it's
a C library).  However, I'm not sure how far along he is - I've pinged him
a few times over the last month and still have not seen any code.

Phil






reply via email to

[Prev in Thread] Current Thread [Next in Thread]