Question
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:
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
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