It seems that I was right in some way since the S-Expressions come naturally at the moment of applying recursion correctly for nested functions since the parser reads relying on the context defined in Ruby as it is shown in section 2.3.
Managing contexts seems to be one of the most useful implementations within the framework, having a quick access to data outside of the function being currently parsed seems to be something that is very characteristic of Lisp-like languages. In the article it is stated that the framework is quite able to support simple functional languages using the basic functionalities such as defining, passing arguments and setting functions.
This article gave me a better understanding on why is it that S-Expressions makes parsing simpler. It is easy to see that on the Ruby code one can parse through the expression taking the first argument of the S-Expression (that is the function) and defining what to do with each of the remaining arguments treating them as simple indexes of the obtained regular expression. Things get complicated when dealing with recursion and scopes, and as the author states, there are some basic optimizations for recursion that cannot be implemented with the chosen approach.
No hay comentarios:
Publicar un comentario