Question: Input will be the grammar from keyboard or from .txt file (whichever you prefer) Write C++ code which should output the list of non-terminals(symbols on

Input will be the grammar from keyboard or from .txt file (whichever you prefer)

Write C++ code which should output the list of non-terminals(symbols on the left side of arrow) followed by the list of terminals(grammar symbols that don't appear on the left side of arrow) in the order in which they appear in the grammar rules from keyboard input or .txt file that has the grammar. Need this in c++. You should use Vector containers. Make sure you test your code with the following two examples.

Input will be the grammar from keyboard or from .txt file (whichever

Example: For the input grammar decl-> idList colon ID # idList-> ID dList1 # dList 1-> # idList1-> COMMA ID dList 1 # the expected output for task 1 is: decl idList idList1 colon ID COMMA Example: Given the input grammar: decl-> idList colon ID # idList1-> # idList1-> COMMA ID idList1 # idList-> ID idList1 # the expected output for task 1 is: decl idList idList1 colon ID COMMA Note that in this example, even though the rule for idList1 is before the rule for idList, idList appears before idList1 in the grammar rules Example: For the input grammar decl-> idList colon ID # idList-> ID dList1 # dList 1-> # idList1-> COMMA ID dList 1 # the expected output for task 1 is: decl idList idList1 colon ID COMMA Example: Given the input grammar: decl-> idList colon ID # idList1-> # idList1-> COMMA ID idList1 # idList-> ID idList1 # the expected output for task 1 is: decl idList idList1 colon ID COMMA Note that in this example, even though the rule for idList1 is before the rule for idList, idList appears before idList1 in the grammar rules

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!