Possible improvements include:
- Desugar Boolean operators and unary minus in concrete syntax
In the original version of the exercise, the | and & operators and the unary minus operator are desugared in abstract syntax (i.e., using explicit instantiations of AST nodes). Using
TigerInput, you can desugar using Tiger’s concrete syntax instead. This second solution is advised.
- Introduce an Error class
When syntactic errors are caught, a valid AST must be built anyway, hence a critical question is: what value should be given to the missing bits? If your error recovery is not compatible with what the user meant, you are likely to create artificial type errors with your invented value.
While this behavior is compliant with the assignment, you may improve this by introducing an
Errorclass (one?), which will never trigger type checking errors.
- Using Generic Visitors
Andrei Alexandrescu has done a very interesting work on generic implementation of Visitors, see Modern C++ Design. It does require advanced C++ skills, since it is based on type lists, which requires heavy use of templates.
- Using Visitor Combinators
Going even further that Andrei Alexandrescu, Nicolas Tisserand proposes an implementation of Visitor combinators, see Generic Visitors in C++.