Any chance of rlcodegen outputting pure-ruby

Victor Hugo Borja vhbo... at
Wed Jan 10 10:19:25 UTC 2007


I'm also interested on getting Ragel to output ruby, today I've been
working on this.
Following Adrian's advice, I decided to start by porting a simple
generated parser from c to ruby.
Once the ruby parser was working as expected (used continuations
instead of c' gotos), I started to work on the backend for ragel,
code generation is working now (with awful code indentation atm). the
generated parsers are still somewhat buggy, so I'd appreciate if anyone
could help with tests  for this.

my work up to now is on,
check the rbtmp directory if you want to see the ported parser.

I expect to have some time this weekend to fix the generated parsers,
and commit a working patch to Adrian.

Victor Hugo Borja.
v... at

On Jan 8, 10:06 pm, Adrian Thurston <thurs... at> wrote:
> Hi Matt, it wouldn't be too much work to add a Ruby backend. I can't
> commit much time to it right now (school is very busy). But I'd be happy
> to help out anyone that wants to try it.
> I don't know Ruby all that well so there may be issues which crop up.
> Some things to consider:
> Table-based parses will be the easiest to port. Start with the generated
> C code (or maybe Java) for some working parser, then port it to Ruby and
> get it working. You should be able to then just rip out the driver code
> and stick it into rlcodegen.
> The fastest code generated by Ragel is directly executable. This relies
> on having a goto. A lack of goto is also a problem for Ragel+Java. Colin
> Fleming discussed generating Java byte code directly to get around this
> issue. The same might be an option for Ruby.
> Some changes will need to be made to the frontend. Ruby comments and
> literals will need to be supported and the ruby integral types
> represented. I'm currently in the middle of rewriting the Ragel frontend
> parser. When that's done it will be a better time to add a scanner for
> Ruby which can properly separate Ragel code from Ruby code.
> Cheers,
>   Adrian
> Matt Mower wrote:
> > Hi,
> > I realise that wrapping the C code generated by Ragel into a Ruby
> > extension is a reasonably simple exercise but I really think it would
> > help with adoption if Ragel could directly generate Ruby source code.
> > Is there any likelyhood of that happening? Or does it need someone
> > from the Ruby side to pitch in? And how hard might that be?
> > Regards,
> > Matt

More information about the ragel-users mailing list