Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Interpreter Design and implement an interpreter in C++ that executes the code written in LAO language (the name of our own programming language). The

C++ Interpreter

Design and implement an interpreter in C++ that executes the code written in LAO language (the name of our own programming language). The statements in LAO language are:

  • ::= REM | REM
  • ::= =
  • ::= PRINT | PRINT | PRINT | PRINT
  • ::= READ
  • ::= IF THEN
  • ::= END.

Where:

::= |

::= a-z | A-Z

::= |

::= | < unsign integer>

::= |

::= |

::=

::= .

::=

::= e | E

::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

::= + | -

::= "" | ""

::=

::= .gt. | .lt. | .eq. | .ge. | .le. | .ne.

::= .or. | .and. | .not.

::= | |

CAN PLEASE FIX IT

#include

#include

using namespace std;

void stringI(int j)

{

if(j+1)

{

cout<<"string";

}else

cout<< "Invalid input"<

}

void statement(int input)

{

switch(input)

{

case 0:

cout<<"command statement"<

break;

case 1:

cout<<"if statement"<

break;

case 2:

cout<<"then statement"<

break;

case 3:

exit;

break;

case 4:

cout<<"read statement"<

break;

case 5:

cout<<"print statement"<

break;

default:"Invalid input";

}

}

int main()

{

char input[]="";

string keyword[]={"REM","IF","THEN","END.","READ","PRINT"};

/*char lLetter[]={"a","b","c","d","e","f","g","h","i","j",

"k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};

char uLetter[]={"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O",

"P","Q","R","S","T","U","V","W","X","Y","Z"};*/

cout<<"Enter:";

cin>>input;

int size=sizeof(input);

for(int i=0;i<5;i++)

{

if(input==keyword[i])

{

statement(i);

}

}

if(input[0]== *("\"") && input[size-1]==*("\""))

{

cout<<"string";

}

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Step: 3

blur-text-image

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

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

1st Edition

1597496251, 978-1597496254

More Books

Students also viewed these Databases questions

Question

Find Io in the network shown using superposition 3 KCO 6W 2mA

Answered: 1 week ago