Question: In regards to the interperter class, how should the resolve method be constructed? I'm having a hard time constructing this method.. Also, what Node paramter

In regards to the interperter class, how should the resolve method be constructed? I'm having a hard time constructing this method.. Also, what Node paramter is the interpreter taking?

Finally, we will build (the beginning of) our interpreter. Create a new

Finally, we will build (the beginning of) our interpreter. Create a new class called Interpreter. Add a method called "Resolve". It will take a Node as a parameter and return a float. For now, we will do all math as floating point. The parser handles the order of operations, so this function is very simple. It should check to see what type the Node is: For FloatNode, return the value. For IntNode, return the value, cast as float. For MathOpNode, it should call Resolve() on the left and right sides. That will give you two floats. Then look at the operation (plus, minus, times, divide) and perform the math.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres an example implementation of the Interpreter class with the Resolve method public class Interp... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!