Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

completing the C++ parser program // CS4303 Programming Language Concepts// Lab exercise - Parser//// Name ______________________ ID _____________________//// A simple parser for C/C++-style variable declarations.//

completing the C++ parser program

// CS4303 Programming Language Concepts// Lab exercise - Parser//// Name ______________________ ID _____________________//// A simple parser for C/C++-style variable declarations.// THe grammar is as follows://// ::= ; | = ;// ::= int | float// ::= A | B | C | D | E// ::= | // ::= | // ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9// ::= . // // Input is entered at the keyboard.// If the input is correct, the program should print// "no error found", otherwise, it should print the type// of error and terminate its execution. There are four// possible errors:// // "unrecognizable type"// "illegal variable name"// "unexpected number"// "; expected"//// Error message is printed out by calling function // "error". An error code ranging from 0 to 4 can be// passed as an argument to the function indicating what// message is to be printed. The mapping from the error// code to the message can be found by looking at the// definition of function "error".//// The following are some sample input and the response// from the program://// Please enter a declaration in format [= number] ;// int A;// no error found//// Please enter a declaration in format [= number] ;// int a;// illegal variable name//// Please enter a declaration in format [= number] ;// short B;// unrecognizable type// // Please enter a declaration in format [= number] ;// float C = 0.5;// no error found// // Please enter a declaration in format [= number] ;// int A = 10,// unexpected token#include #include using namespace std;string token;string GetToken();void error(int);int main() { cout [= number] ;" token = GetToken(); // Write the code here error(0); return 0;}string GetToken() {// Write the code here}void error(int code) { switch (code) { case 0: cout case 1: cout case 2: cout case 3: cout case 4: cout } return;}

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_2

Step: 3

blur-text-image_3

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

Pro Android Graphics

Authors: Wallace Jackson

1st Edition

1430257857, 978-1430257851

More Books

Students also viewed these Programming questions