Find me on Codeberg

One compiler down one to go ( 2015-11-28 )

Ok, that was surprising: I just wrote a language in two months. Parser, compiler, working binaries and all.

Then i documented it , detailed the syntax and even did some benchmarking.

So, the good news: it it works

Working means: calling works, if, while, assignment, class and method definition. The benchmarks were hello world and fibonacci, both recursive and by looping.

I even updated the whole book to be up to date. Added a Soml section, updated parfait, rewrote the register level . . .

It all clicked into place

To be fair, i don’t think anyone writes a language that isn’t a toy in 2 months, and it was only possible because a lot of the stuff was there already.

  • Parfait was pretty much there. Just consolidated it as it is all just adapter.
  • The Register abstraction (bottom) was there.
  • Using the ast library made things easier.
  • A lot of the parser could be reused.

And off course the second time around everything is easier (aka hindsight is perfect).

One of the better movie lines comes to mind, (paraphrased) “We are all just one small adjustment away from making our code work”. It was a step sideways in the head which brought a leap forward in terms of direction. Not where i was going but where i wanted to go.

Open issues

Clearly i had wobbled on the parfait front. Now it’s clear it will have to be recoded in soml, and then re-translated into ruby. But it was good to have it there in ruby all the time for the concepts to solidify.

Typing is not completely done, and negative tests for types are non existant. Also exceptions and the machinery for the returns.

I did a nice framework for testing the binaries on a remote machine, would be nice to have it on travis. But my image is over 2Gb.

And onto the next compiler

The ideas about how to compile ruby into soml have been percolating and are waiting to be put to action. The theory looks good,but one has to see it to believe it.

The first steps are quite clear though. Get the ruby parser integrated, get the compiler up, start with small tests. Work the types at the same time.

And let the adventure continue.