Question: Write a program that does the following: 1. Reads a grammar. 2. Finds the canon ical LR (0) sets INPUT: A grammar G OUTPUT: The

 Write a program that does the following: 1. Reads a grammar.2. Finds the canon ical LR (0) sets INPUT: A grammar GOUTPUT: The list of all productions in G The canon ical LR

Write a program that does the following: 1. Reads a grammar. 2. Finds the canon ical LR (0) sets INPUT: A grammar G OUTPUT: The list of all productions in G The canon ical LR (0) collection of sets for G In addition to numbering the sets, as done in the text, identify the symbol X that generates the s et through the function GOTO(I,X) DELIVERABLES: Program source code with internal documentation Test results for grammar G419 and at least one other grammar. HINT: Modify your Lab 4 p rogram for this exercise The routines to input and print the grammar are the same and the data structure to hold the items is the same as the data structure to hold a production, with a single added data item to indicate the position of the dot in the right hand side. If you leave the routines for FIRST and FOLLOW as part of the program, even though you do not use them in this exercise, the resulting code contains most of the ingredients you need to produce an SLR parser ALGORITHMS: You will need the algorithms for CLOSURE (pg. 222) and GOTO (pg. 224) The algorithms are recursive, they start from the unique production that contains the start symbol of an extended grammar. As described in section 4.7 in the text alternately apply CLOSU and GoTO until nothing more RE can be done. Note that CLOSURE (I) fills out sets, GOTO(I,X) may add new sets of items to the collection Write a program that does the following: 1. Reads a grammar. 2. Finds the canon ical LR (0) sets INPUT: A grammar G OUTPUT: The list of all productions in G The canon ical LR (0) collection of sets for G In addition to numbering the sets, as done in the text, identify the symbol X that generates the s et through the function GOTO(I,X) DELIVERABLES: Program source code with internal documentation Test results for grammar G419 and at least one other grammar. HINT: Modify your Lab 4 p rogram for this exercise The routines to input and print the grammar are the same and the data structure to hold the items is the same as the data structure to hold a production, with a single added data item to indicate the position of the dot in the right hand side. If you leave the routines for FIRST and FOLLOW as part of the program, even though you do not use them in this exercise, the resulting code contains most of the ingredients you need to produce an SLR parser ALGORITHMS: You will need the algorithms for CLOSURE (pg. 222) and GOTO (pg. 224) The algorithms are recursive, they start from the unique production that contains the start symbol of an extended grammar. As described in section 4.7 in the text alternately apply CLOSU and GoTO until nothing more RE can be done. Note that CLOSURE (I) fills out sets, GOTO(I,X) may add new sets of items to the collection

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!