-
Book Overview & Buying
-
Table Of Contents
Building Programming Language Interpreters
By :
For the purpose of this exercise, I am not creating as many unit tests as would probably be advised. (I haven’t gone into the details of unit tests in the text, but you can check them out in the repository.) This is just a simplification of the fact that this interpreter is not meant for actual production use. A project building a real interpreter should definitely have significantly more unit tests than what I’m writing here.
That being said, in addition to unit tests, it’s also important to create test cases that exercise the integration of those operations in a more complex environment. That’s what I will focus on now.
The first step is to lay out the OpTree for the code I want to test. This is essentially the data structure that represents what the compiler for the interpreter will have to do. This will be done directly in C++.
I used this approach before when implementing the factorial example in the previous chapter...