Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Heres an example implementation of the Interpreter class with the Resolve method public class Interp...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started