Pages

2014-09-21

Goruby revisited

Almost a month ago, I wrote about the idea of GoRuby. So, what's the progress now?

What I have:

- I found the BNF of Ruby 2.1.0 at http://docs.ruby-lang.org/ja/2.1.0/doc/spec=2fbnf.html
- I found a Golang Compiler Compiler at https://code.google.com/p/gocc/
- I transformed the BNF into the format gocc expects
- I tried the parser and it terribly failed

So, what's the problem?

As I found out, after having a failing parser, the grammar ruby uses is a LALR one, whereas gocc only generates a LR(1).

- At that point I have to admit that I've never studied Computer Science and had never the 'fun' of writing any compiler, so at the point of creating the idea of GoRuby I had no idea of all those different types of parsers and so on -

So, what now?

Well, as I want to have a working prototype of the AST for getting started there are several options. I could write my own LALR parser to get the missing Go code. Sounds hard, especially if you have only rudimentary knowledge of these things. Or I could search for another compiler compiler that outputs Go code. Sounds less hard, but has the implication that the input format, which is now a pure EBNF, could have to be transformed into another format.

We'll see what the right answer will be.

For any updates visit this blog and look for changes at https://www.github.com/goruby/goruby

2014-08-29

Writing yet another Ruby implementation in Go

Well, let's face the truth: writing a complete implementation of Ruby is very hard, independent of the language used for it. And then: why another implementation which differs only in the language used to write it into?

I love Ruby, and I love Go. But you can't use both at the same time, especially not without tradeoffs or "workarounds".

But why writing the whole language anew in Go? To tell the truth, I am doing this just for fun. And also because Brian Shirai created a remarkable tool to assist with just that, RubySpec.
So, maybe it's only a proof of concept if it is possible to create another implementation guided by the specs.

If you're interested in the project and its progress, check out the sources at github. I will also report about my progress here. So stay tuned.