Question: In c + + programming, help me make a lexical analyzer of a toy compiler that can turn the following sample input: int x; real

In c++ programming, help me make a lexical analyzer of a toy compiler that can turn the following sample input:
int x;
real y;
x =5;
y = x *3+2.1;
if (x 1) then x =1; else x =2;
while (x 5){
x = x +1;
}
x =10;
Into the following sample output:
MOVI 5,,x
MULTI x,3,t1
CONVR t1,,t2
ADDR t2,2.1,t3
MOVR t3,,y
LTI x,1,t4
JMPF t4,,10
MOVI 1,,x
JMP ,,11
MOVI 2,,x
LTI x,5,t5
JMPF t5,,16
ADDI x,1,t6
MOVI t6,,x
JMP ,,11
MOVI 10,,x
In the image is the information that my teacher gave me, however, I only need to complete the lexical analyzer section of this toy compiler:
In c + + programming, help me make a lexical

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!