Question: Can someone help me explain how to do this? As in psuedocode (we use C++ if that is relevant). Create a class Grammar whose required

Can someone help me explain how to do this? As in psuedocode (we use C++ if that is relevant).

Can someone help me explain how to do this? As in psuedocode

Create a class Grammar whose required public methods should become clear as you read the rest of this lab specification. I suggest you pass the file name or the already opened std::ifstream instance into the constructor. The constructor implementation will then read the grammar and store its specifications in private instance variables. When reading the grammars in the question and answer grammar files, observe the following assumptions 1. The data on the file is case sensitive. All string comparisons are to be case-sensitive. Note, for example, that FOO might be a nonterminal while Foo is a terminal symbol in a grammar 2. All symbols (terminal and non-terminal) are whitespace-delimited. 3. Each production rule appears as a separate rewrite rule. That is, there are no alternation ("I") symbols used in production rules. 4. To simplify reading and parsing of the grammar production rules, each production rule is terminated by a pound sign (anyone under 35 knows it is a hashtag ). This allows you to read production rules symbol by symbol without regard for where line breaks occur. The'#' is NOT to be considered as either a terminal or nonterminal. It must never appear in any strings from either grammar 5. The start symbol is the nonterminal in the first production rule in the file. The Executive class is to create Grammar instances for each of the two grammars. After both Grammar instances have been created, the Executive queries each Grammar instance for (i) the set of nonterminal symbols, (i) the set of terminal symbols, and (lil) the start symbol. (Hopefully needless to say, the Grammar instances must determine these algorithmically; do not just hard-wire the strings returned from these methods. We may test your programs with different grammars.) The Executive then produces a well-formatted display of this information for both grammars. Then the Executive enters a loop, prompting the user for something to do. The choices are: 1. A: The Executive asks the "question" Grammar instance to generate a question from its grammar and return it to the Executive. The question must be returned as a single std::string. The Executive then prints the question to the screen and asks the "answer" Grammar instance to generate an answer from its grammar. Again, the answer must be returned as a single std: :string, and the Executive then prints this answer. 2. o: Quit the program. Create a class Grammar whose required public methods should become clear as you read the rest of this lab specification. I suggest you pass the file name or the already opened std::ifstream instance into the constructor. The constructor implementation will then read the grammar and store its specifications in private instance variables. When reading the grammars in the question and answer grammar files, observe the following assumptions 1. The data on the file is case sensitive. All string comparisons are to be case-sensitive. Note, for example, that FOO might be a nonterminal while Foo is a terminal symbol in a grammar 2. All symbols (terminal and non-terminal) are whitespace-delimited. 3. Each production rule appears as a separate rewrite rule. That is, there are no alternation ("I") symbols used in production rules. 4. To simplify reading and parsing of the grammar production rules, each production rule is terminated by a pound sign (anyone under 35 knows it is a hashtag ). This allows you to read production rules symbol by symbol without regard for where line breaks occur. The'#' is NOT to be considered as either a terminal or nonterminal. It must never appear in any strings from either grammar 5. The start symbol is the nonterminal in the first production rule in the file. The Executive class is to create Grammar instances for each of the two grammars. After both Grammar instances have been created, the Executive queries each Grammar instance for (i) the set of nonterminal symbols, (i) the set of terminal symbols, and (lil) the start symbol. (Hopefully needless to say, the Grammar instances must determine these algorithmically; do not just hard-wire the strings returned from these methods. We may test your programs with different grammars.) The Executive then produces a well-formatted display of this information for both grammars. Then the Executive enters a loop, prompting the user for something to do. The choices are: 1. A: The Executive asks the "question" Grammar instance to generate a question from its grammar and return it to the Executive. The question must be returned as a single std::string. The Executive then prints the question to the screen and asks the "answer" Grammar instance to generate an answer from its grammar. Again, the answer must be returned as a single std: :string, and the Executive then prints this answer. 2. o: Quit the program

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!