
Explanation of Solution
a.
Parse tree for the string foo (a, b):
Explanation of Solution
b.
Canonical (rightmost) derivation:
- Canonical derivation is a leftmost or rightmost derivations that may not be unique but they allow describing a derivation by the sequence of production rules taken.
- In the rightmost derivation, the rightmost nonterminal on the right hand side of a rule is replaced by a suitable rule.
- The complete derivation in this case is processed in the rightmost way.
Explanation of Solution
c.
Proof:
The EPS, FIRST, and FELLOW sets table for the above grammar:
Terminals and non-terminals | EPS | FIRST | FELLOW |
stmt | False | id | empty |
assignment | False | id | empty |
subr_call | False | id | empty |
expr | False | id, ( | ‘,’, ) |
expr_tail | True | +, -, *, / | ‘,’, ) |
primary | False | id, ( | +, -, *, / |
op | False | +, -, *, / | id, ( |
arg_list | False | id, ( | ) |
args_tail | True | ‘,’ | ) |
Now add the predict sets to the grammar above:
Parse table for the above grammar:
Id | := | ( | + | - | * | / | , | ) | |
stmt | 1, 2 | ||||||||
assignment | 3 | ||||||||
subr_call | 4 | ||||||||
expr | 5 | 5 | |||||||
expr_tail | - | 6 | 6 | 6 | 6 | 7 | 7 | ||
primary | 8, 9 | 10 | |||||||
op | - | 11 | 11 | 11 | 11 | ||||
arg_list | 12 | 12 | |||||||
args_tail | - | 13 | 14 |
- The entries in the above table indicates the production of predict. The “-” means an error.
- If the top-of-stack is terminal, the appropriate action is always to match it against an incoming token from the scanner.
The given grammar can’t be LL (1) because of confusion with “stmt” and “id”.
Explanation of Solution
d.
Modified grammar to make it is LL (1):
Factor out “id” from productions with “stmt” and “expr”.
Want to see more full solutions like this?
Chapter 2 Solutions
Programming Language Pragmatics, Fourth Edition
- A(n) ____ cannot be selected as the document type in the Mail Merge task pane. Question 9Select one: a. Letter b. Directory c. Fax d. E-mail messagearrow_forwardConsider a Superstore Database which consists of 3 tables, Orders, Returns, and Managers. The CSV files have been provided along with this DOC file in the Midterm 2 Link in the Moodle. Answer the questions as below: Use the created table as in the provided SQL query file, solve the problems as mentioned below. You will have to import the respective CSV files of the above created tables as without them, it is impossible to solve the questions below. If you are not able to upload the files successfully, do not leave the query questions. Just write the query to the best of your knowledge. Do not copy. To be graded for the screenshot answer, you must upload the CSV properly and paste the resulting screenshot of the queries as asked. Write Query to Find out which Product Sub-Category has a sum of Shipping Cost to sum of Sales ratio > 0.03.arrow_forwardI need to render an image of a car continuously for a smooth visual experience in C# WinForms. It gets the location array (that has all the x,y of the tiles it should visit) from another function - assume it is already written.arrow_forward
- write c program with features: Register a Bunny: Store the bunny's name, poem, and initialize the egg count to 0. Modify an Entry: Change the bunny's poem or update the egg count. Delete a Bunny: Remove a registered bunny from the list. List All Bunnies: Display all registered bunnies and their details. Save & Load Data: Store bunny data in a file to persist between runs. Use a struct to represent a bunny contestant. Store data in a binary file (bunnies.dat) for persistence. Use file I/O functions (fopen, fwrite, fread, etc.) to manage data. Implement a menu-driven interface for user interaction.arrow_forwardHelp, how do I write the pseudocode for the findMean function and flowchart for this?arrow_forwardNeed help drawing a flowchart for the findMax function herearrow_forward
- Need help writing the pseudocode for the findMin function with attachedarrow_forwardCreate a static function in C# where poachers appear and attempt to hunt animals. It gets the location of the closest animal to itself. Take account of that the animal also move too, so it should update the closest location (x, y) everytime it moves to a new location. Use winforms to show the movements of poachers.arrow_forwardCreate a static function in C# where poachers appear and attempt to hunt animals. It gets the location of the closest animal to itself. Take account of that the animal also moves too, so it should update the closest location (x, y) everytime it moves to a new location. Use winforms to show to movementsarrow_forward
- I have to develop an efficient parallel numerical integration program on a 2-D mesh but I'm struggling. And it has to be in Cstararrow_forwardAn employee is departing from the company you work for. Explain why it could be best practice not to delete their user account but to lock it instead.arrow_forwardthe nagle algorithm, built into most tcp implementations, requires the sender to hold a partial segment's worth of data (even if pushed) until either a full segment accumulates or the most recent outstanding ack arrives. (a) suppose the letters abcdefghi are sent, one per second, over a tcp connection with an rtt of 4.1 seconds. draw a timeline indicating when each packet is sent and what it contains.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





