January 2013
Intermediate to advanced
328 pages
8h 5m
English
Let’s revisit the expression grammar from Building a Calculator Using a Visitor to learn about actions. In that section, we built a calculator using a tree visitor that evaluated expressions such as the following:
| | x = 1 |
| | x |
| | x+2*3 |
Our goal here is to reproduce that same functionality, but without using a visitor and without even building a parse tree. Moreover, we’ll employ a little trick to make it interactive, meaning we get results when we hit Return, not at the end of the input. Our examples so far have scarfed up the entire input and then processed the resulting parse trees.
As we go through this section, we’re going to learn how to put generated parsers into packages, define ...
Read now
Unlock full access