Question: Write the C++ driver that implements the parenthesis matching algorithm in order to read the file name from the user and parse it to generate

Write the C++ driver that implements the parenthesis matching algorithm in order to read the file name from the user and parse it to generate compilation errors related to the parentheses.

This is how the program should work :

If addNums.cpp contains the following text:

  1. #include
  2. #include
  3. using namespace std;
  4. int main() {
  5. int x = 20;
  6. int y = 30;
  7. int x1[ = {1,2,3;
  8. if (x > y)
  9. cout<<"X is greater than Y";
  10. else
  11. cout<<" Y is greater than X";
  12. return 0;
  13. }

Run:

Enter file name: addNums.cpp

Parser Results:

1. ERROR-4: EXPECTED } TO MATCH {

2. ERROR-6: EXPECTED ] TO MATCH [

2 errors generated.

BUILD FAILED

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 Databases Questions!