-
Book Overview & Buying
-
Table Of Contents
Building Programming Language Interpreters
By :
Different parsing libraries will provide different approaches here. In some cases, you have more control, and in some cases less. With the grammar engine that I built for the project, however, it gives me complete control to assemble the parse tree in the way that makes the most sense to me.
In the previous section, I introduced a few initial parts of the grammar, building IdentifierReference. The code also included the literals and the data type declarations.
There is a reason why I started that way. You always want to build the grammar, as with the tree objects, from the inside out, since the outer syntactical elements need to reference the inner ones.
The process, from this point forward, is a simple matter of expanding the grammar and writing tests until the entire grammar is complete.
For that, I will start with the data section of the message, which needs first the pair defining the name of a variable and its type:
param: int;
...
Change the font size
Change margin width
Change background colour