![subject](/tpl/images/cats/informatica.png)
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
![ansver](/tpl/images/cats/User.png)
Answers: 2
![](/tpl/images/ask_question.png)
![](/tpl/images/ask_question_mob.png)
Another question on Computers and Technology
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 22.06.2019 18:10
How can i delete permalinks from a word press site?
Answers: 1
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 21:30
Examine the list below. which factors positively affect lifetime income? check all that apply.
Answers: 1
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 13:30
Type the correct answer in the box. spell all words correctly. what is the default margin width on all four sides of a document? by default, the document has a margin on all four sides.
Answers: 1
![question](/tpl/images/cats/informatica.png)
You know the right answer?
The following defines a simple language, in which a program consists of assignments and each variabl...
Questions
![question](/tpl/images/cats/istoriya.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 11.10.2019 22:30
![question](/tpl/images/cats/en.png)
English, 11.10.2019 22:30
![question](/tpl/images/cats/mat.png)
Mathematics, 11.10.2019 22:30
![question](/tpl/images/cats/biologiya.png)
![question](/tpl/images/cats/en.png)
![question](/tpl/images/cats/obshestvoznanie.png)
Social Studies, 11.10.2019 22:30
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/himiya.png)
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/fizika.png)
Physics, 11.10.2019 22:30
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/istoriya.png)
![question](/tpl/images/cats/health.png)
Health, 11.10.2019 22:30
![question](/tpl/images/cats/mat.png)
Mathematics, 11.10.2019 22:30
![question](/tpl/images/cats/biologiya.png)
Biology, 11.10.2019 22:30
![question](/tpl/images/cats/istoriya.png)
History, 11.10.2019 22:30
![question](/tpl/images/cats/mat.png)
Mathematics, 11.10.2019 22:30
![question](/tpl/images/cats/mat.png)
Mathematics, 11.10.2019 22:30