2-3: Ruby and the Interpreter Pattern

It is important to have in mind the following things when we talk about the S-Expression Interpreter Framework (SIF). First, the SIF follows the lisp-like notation, this means, that in order to write programs you need to have a little knowledge of how to write programs in Lisp (that is why Ariel Ortiz taught this topic in the last 4 weeks of the course, in order to be familiarized with all the topics that were covered in this paper). Another thing you need to have in mind is that SIF is written in Ruby programming language (many classmates mention me that Ruby it’s like Python but in steroids).

Know, let's analyze how SIF works in the backstage. If you want to implement a totally knew special form, you will need to do it a certain way in order to let the compiler do his job and do it right. So, in the case that is covered in the paper (the if special form), you need to define a new class that NEEDS to be a Node in order to be used as a node for the interpreter pattern tree, also it needs to have a initialize method, a special form name and the interpret method that will tell the compiler the behavior of the special form if.

In this paper, Ariel Ortiz makes it look very simple how to extend a simple compiler core in something bigger, but I think is not that easy how it looks like, I do not know if it is because we still do not see it in class or because it is actually that easy. In these early phases of the compiler I have been having a bit of trouble doing them so, taking a core that little and extend it I found it very challenging but I am sure that at the end of the course I will be able to do something like this or more challenging.

Comentarios

Entradas populares de este blog

1-2: Making Compiler Design Relevant for Students

2-2: Mother of Compilers

1-3:“The Hundred-Year Language”