Ruby and the Interpreter Pattern
This entry is from an article called “Language Design and Implementation using Ruby and the Interpreter Pattern”, written by one of our best teachers called Ariel Ortiz. 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. The framework is a Digital Subscriber Line (DSL), it uses the Ruby language and allows us to build S-Expressions (for example Clojure, LISP) by the implementation of the interpreter pattern.
The basic principle of the interpreter pattern is that some problems are solved far more easily by creating a specialized language to solve it, and then expressing the obtained solution in that language, interpreters are known to have two phases, the first phase is the one in which the parser reads in the program text, then it produces a data structure that is called an Abstract Syntax Tree (AST Tree), in the second phase the obtained AST from the previous phase is tested to confirm its usefulness.
Comentarios
Publicar un comentario