Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please finish this Table Driven LL(1) parser c++ program _______________________________________________________ These are the rules S 0 A 0 $ S 1 A 1 $ A

Please finish this Table Driven LL(1) parser c++ program

_______________________________________________________

These are the rules

S 0 A 0 $ S 1 A 1 $ A 0 0 $ A 1 1 $

_____________________________________________

c++ program

______________________________________________________

#include #include #include #include #include using namespace std;

// ** Complete look for ** // use vectors

vector M[3][5]; // the table of rules

void readrules() { ifstream fin ("rules", ios::in); // ** read in the rules info M, make sure $ is not stored // ** display the table

}

void addtostack(vector V) { cout << "Adding rhs of a rule to the stack" << endl; // ** push V contents to the stack - be careful of the order }

int main() { readrules();

string ss; cout << "Enter a string made of 0's and/or 1's: "; cin >> ss;

// ** push 'S' onto the stack to start cout << "Stack"; // ** display the stack vertically

int i = 0; while (ss[i] != '\0') // for each char of ss { // ** based on the current character, update the stack // ** note that mismatches will cause immediate failure }

// ** check for success for failure based on stack empty or not

}

_____________________________________________________________

Example output

____________________________________

./LL1.out row S col S : row S col A : row S col B : row S col 0 : 0 A 0 row S col 1 : 1 A 1 row A col S : row A col A : row A col B : row A col 0 : 0 0 row A col 1 : 1 1 row B col S : row B col A : row B col B : row B col 0 : row B col 1 :

_________________________________________

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

Oracle Databases On The Web Learn To Create Web Pages That Interface With Database Engines

Authors: Robert Papaj, Donald Burleson

11th Edition

1576100995, 978-1576100998

More Books

Students also viewed these Databases questions

Question

Use a customer presentation card.

Answered: 1 week ago