Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Dear Sir or Madam, Hope your day is going well. I need help with the following programming assignment. I need it to be written in
Dear Sir or Madam,
Hope your day is going well. I need help with the following programming assignment. I need it to be written in Java. If you could also include comments, that would be highly appreaciated. Please followi the instructions.
The following below defines a simple language, in which a program consists of assignments and each variable is assumed to be of the integer type. For the sake of simplicity, only operators that give integer values are included. Write an interpreter for the language in a language of your choice. Your interpreter should be able to do the following for a given program:
detect syntax errors
report uninitialized variables
perform the assignments if there is no error and print out the values of all the variables after all the assignments are done.
Program:
Assignment
Assignment:
Identifier Exp;
Exp:
Exp Term Exp Term Term
Term:
Term Fact Fact
Fact:
Exp Fact Fact Literal Identifier
Identifier:
Letter Letter Digit
Letter:
azAZ
Literal:
NonZeroDigit Digit
N onZeroDigit:
Digit:
Here's the sample of inputs and outputs:
Input
x ;
Output
error
Input
x;
Output
x
Input
x
y x;
z xy;
Output
error
Input
x ;
y ;
z xyxy;
Output
x
y
z
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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