Extended calculator
The code for this exercise is here
In the extended calculator, the Antlr grammar has been extended with statements to also handle simple expressions comparing values.
stmt : IF (comparison) THEN expression else expression |
comparison | expr ;
The else-statement can be optional. Comparisons can the for normal binary operators.
Understanding the parser
Take 5 minutes to talk with a fellow student about what is needed to make this extension. You are welcome to try to implement it before looking at our implementation.
Traversing the parsing tree
THe file Interpreter.java` traverses the tree from Anltr.
In the method visitCompareStmt
I have forgotten a couples of cases. Which are these? Add these to the file.
Look also at the visitStmt
method and understand what it traverses.
Implementing execution
I have forgot to implement the execution of two of the binary operators. Implement these.
Testing
What will a good test look like. Extend the one there exists.