Ruby parser ?

5 views
Skip to first unread message

Nils Haldenwang

unread,
Oct 3, 2010, 4:17:14 AM10/3/10
to fancy...@googlegroups.com
Hey guys,

as I am trying to get into ANTLR atm, I was wondering, if we perhaps
could use the
ruby-target ( http://github.com/ohboyohboyohboy/antlr3 ) to generate a
parser in Ruby,
which can run on RBX. This way we would not depend on the C++-Code anymore.
Guess it would be nice, if all one needs to run Fancy is rbx.

When my understanding on what Victor and Christopher have done on the bytecode
compiler so far is right, they just need the output of "fancy --rsexp
<file>". Should not
be that hard to get this out of an ANTLR-generated parser in Ruby.

What do you think about it ?

Regards,
Nils

Victor Hugo Borja

unread,
Oct 3, 2010, 6:15:50 AM10/3/10
to fancy...@googlegroups.com
You're right, the only thing the rbx compiler needs is a sexp using ruby literals (arrays, symbols, strings, numbers).

Regarding the parser, anything that can be used as an C extension from rubinius is fine, later we will use rubinius' FFI to interface to whatever parser we have. 

So if you start playing with an ANTLR parser, outputting the sexp would be sufficient. 

Maybe we could also try creating a Ragel based parser (I added ruby support to it some ages ago, I even added experimental rubinius asm output, and evan phoenix did a bit of work on that too, don't know if the rbx output would work with current rubinius bytecode format, but IIRC the C mode is fast as hell, so we just could try and use the better parse we can get with).

Cheers, 
--
vic

Quaerendo invenietis.

Nils Haldenwang

unread,
Oct 3, 2010, 6:45:18 AM10/3/10
to fancy...@googlegroups.com
Errr, what I meant was generating a pure Ruby parser, no C or
something in background. But yeah, that will probably not be very
fast. But is that really necessary on compile time ? I am new to this
topic and just thought it might be a good idea because I like to do as
much as possible with a dynamic language. :-)

But the mentioned antlr3 gem does not work anyway with rbx atm. I
already filled an issue @rbx on github. But it works with JRuby and
MRI 1.8.7 so far.

Ragards,
Nils

2010/10/3 Victor Hugo Borja <vbo...@apache.org>:

Christopher Bertels

unread,
Oct 3, 2010, 1:28:42 PM10/3/10
to fancy-lang
I suppose we could also check out Treetop
(http://treetop.rubyforge.org/). I've used it before for some toy
languages I implemented in Ruby. But I'm not sure about how the
performance is compared to using a c-extension. I guess using the
current parser as a C-extension for rbx would make sense and should'nt
be too hard to implement. Rubinius uses MRI's parser as a c-ext. as
well so this should be pretty similar.

Cheers,
Christopher.
--
================================
Christopher Bertels
http://www.fancy-lang.org
http://www.adztec-independent.de
GPG Key ID: 0x2345b203

Reply all
Reply to author
Forward
0 new messages