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

Keine Kommentare: