Sunday, March 10, 2019

Ruby and the Interpreter Pattern

Ruby and the Interpreter Pattern

After reading the technical article “Language Design and Implementation using Ruby and the Interpreter Pattern”, written by our teacher Ariel Ortiz, I can't help but feel sad because I couldn't have the chance to use the SIF tool he describes in his article in my subject of Programming Languages. The article talks about an implementation he made to evaluate different LISP expressions that are given as strings using a framework called S-Expression Interpreter Framework, and gives some examples with Ruby code to demonstrate how it works.
The principle for the interpreter pattern is that it's easier to solve some problems by creating a specialized language to understand it, and then express the results in that same language. This is all involved in both the syntactic, but more importantly the semantic analysis of compilers (the phase we are currently working in in our project). It involves a data structure that is called Abstract Syntax Tree (AST Tree), where the different operands and hierarchy of functions are organized in order to create a logic and order to the thinking and executing processes of the machine.

After the creation of the AST Tree, the framework reads a source which will be turned into a string, containing all the info of the tree. The regex API is then used to scan the string which will turn the S-Expression into their equivalent values in Ruby. Finally, the AST will be built. 
I would have liked pretty much to have the opportunity to implement and mess around with the framework in my Programming Languages course, as I mentioned at the beginning of this post. I guess it would have been interesting and could have given more context on symbol expressions and their uses. However, I do think the content of this article will be very helpful for the next phase of development for our project, and the course itself.

No comments:

Post a Comment

The Hitchhiker's Guide To The Galaxy

The Hitchhiker's Guide To The Galaxy Reading this comedy and science-fiction comedy from Douglas Adams was actually pretty funny and ...