Answered step by step
Verified Expert Solution
Link Copied!

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?

image

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... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Ethical Obligations And Decision Making In Accounting Text And Cases

Authors: Steven Mintz

6th Edition

1264135947, 9781264135943

More Books

Students also viewed these Programming questions

Question

When is a context - free grammar ( CFG ) unambiguous?

Answered: 1 week ago