This entry
is to talk about the article “Language Design and Implementation using Ruby and
the Interpreter Pattern” written by our professor Ariel Ortiz. Int his article
we read about the SIF, which means S-Expression Interpreter Framework and it is
used to demonstrate advanced language concepts and also to demonstrate programming
styles. It is a tool for teaching language design and implementation. It is an
interpreter based on the Interpreter design pattern.
It is so
simple to use, it allows integers, symbols, lists and procedures. Also, we have
to mention that Ruby has power and flexibility of dynamic languages, so it is
easier to understand. This pattern allows us to write interpreters that can be
studied with basic build blocks that this pattern provide us. We can see the
different behaviors of trees after being interpreted, and this is called a functional
program.
Using an
interpreter, the syntax is implemented in the initialize method, it receives an
array with all the arguments. Then, validates the syntax and constructs the
substrees that corresponds. Also with this method we can analyze the semantic
analysis. Here, this method receives a context as a parameter and is called recursively
for some or all the child nodes.
One
difference that can be noticed is that a compiler generates intermediate code,
while an interpreter is a reduced version of a compiler. The Design of patterns
is very important to be considered in the process of designing a compiler.
No hay comentarios.:
Publicar un comentario