More articles tagged 'compiler-in-Ruby-bottom-up'

2008-10-26
Writing a compiler in Ruby bottom up - step 12

At this point it's worth looking briefly at what is required to implement something more "serious" without a lot of excessive pain. It's really quite easy:

  1. We really want variable length arguments
  2. We want primitives that allow us to create and access arrays. Lets call them "array" and "index", ...

2008-09-28
Writing a compiler in Ruby bottom up - step 11

It's been a long time, and but I finally have a little bit of time again, and it's time to continue.

At this point the next step is some re-factoring. As it stands the compiler is very tightly tied to x86, and before it gets bigger it's worth starting to redress ...

2008-07-10
Writing a compiler in Ruby bottom up - step 10

Uh, yeah. So much for posting the next part in a few days. I think I'll stop trying to second guess when I'll next have time (but sine I'm going off to Norway for vacation for a week, it's a safe bet the next part won't show up until later than ...

2008-07-10
Writing a compiler in Ruby bottom up - step 9

As we've seen, 'while' can be implemented fairly easily in terms of a quite basic language. We could streamline it even more by reducing the verbiage needed to pass anonymous functions or by adding a Lisp style macro facility, but there are complications, so I'm biting the bullet and adding a built in "while" construct for now.

2008-06-01
Writing a compiler in Ruby bottom up - step 8

Last time we looked at an improved way of handling loops etc. using anonymous functions. But most of that is relatively limited if there's no way of modifying variables. Sure, you can get away with recursion and not allow mutation or even other side effects at all. It might satisfy some ...

2008-05-16
Writing a compiler in Ruby bottom up - step 7

I've combined two of the planned parts this time, what was in the list from last time as parts 7 and 8.

Making use of lambda / call

We can implement loops using recursion "manually", but adding lambda's now should make it possible to create a slightly cleaner version by actually ...

2008-05-03
Writing a compiler in Ruby bottom up - step 6

Since we established last time that I'm going to blatantly steal stuff from Lisp, Scheme and friends (as well as from all over the place - I feel no need to be original with this project... Not until we're much further along, anyway), now is the right time to start introducing ...

2008-04-28
Writing a compiler in Ruby bottom up - step 5

Last time I promised to post these more frequently, and blatantly failed to find the time... In return, I've taken the time to combine what would have been parts 5, 6 and 7, that by themselves would've been annoyingly short. Here goes:

Handle number literals

So far our program have only ...

2008-04-17
Writing a compiler in Ruby bottom up - step 4

Sorry for the long delay since the last part, I've simply been too caught up in other stuff. As the list from last time indicated, this part will cover defining functions and adding support for building a simple "runtime library".

Defining functions

A programming language without either functions or methods isn't ...