Now that we have the parser up and running, it's time to start working on the evaluator. We'll start with some simple expressions, such as evaluating numbers or booleans, and a few of the most basic special forms in the language.
quotetakes one argument which is returned directly (without being evaluated).atomalso takes a single argument, and returns true or false depending on whether the argument is an atom.eqreturns true if both its arguments are the same atom, and false otherwise.- The arithmetic operators (
+,-,*,/,modand>) all take two arguments, and do exactly what you would expect.
This time, your work is in the file Evaluator.java.
The following command runs the tests, stopping at the first one failed. You know the drill.
mvn -Dtest=EvaluatorTest testHead on to part 3 where the expressions we take become slightly more complex.