Computers and Technology, 21.12.2019 02:31 leezas1101
The following 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 c++ or java. your interpreter should be able to do the following for a given program:
(1) detect syntax errors;
(2) report uninitialized variables; and
(3) 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:
a||z|a||z|_
literal:
0 | nonzerodigit digit*
nonzerodigit:
1||9
digit:
0|1||9
sample inputs and outputs
input 1
x = 001;
output 1
error
input 2
x_2 = 0;
output 2
x_2 = 0
input 3
x = 0
y = x;
z = +y);
output 3
error
input 4
x = 1;
y = 2;
z = +y)*(x+-y);
output 4
x = 1
y = 2
z = 3
Answers: 2
Computers and Technology, 23.06.2019 20:00
What software programs are used to to create professional publication? a.) graphics programs b.) word processors c.) page layout programs d.) spreadsheet programs
Answers: 2
Computers and Technology, 23.06.2019 23:00
How do you know if the website is secure if you make a purchase
Answers: 2
Computers and Technology, 24.06.2019 14:00
Text or graphics that print at the bottom of every page are called footings footers headers headings
Answers: 1
Computers and Technology, 24.06.2019 15:00
When a presentation is being planned, it is important to ensure that it covers all available information. appeals to the audience. uses multimedia tools. entertains the audience.
Answers: 1
The following defines a simple language, in which a program consists of assignments and each variabl...
Mathematics, 09.04.2021 14:00
Geography, 09.04.2021 14:00
Social Studies, 09.04.2021 14:00
Mathematics, 09.04.2021 14:00
Mathematics, 09.04.2021 14:00
Chemistry, 09.04.2021 14:00
Physics, 09.04.2021 14:00
Physics, 09.04.2021 14:00
Mathematics, 09.04.2021 14:00
Physics, 09.04.2021 14:00
Mathematics, 09.04.2021 14:00
Mathematics, 09.04.2021 14:00
Advanced Placement (AP), 09.04.2021 14:00
Mathematics, 09.04.2021 14:00
Biology, 09.04.2021 14:00