

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


This assignment asks you to prepare written answers to questions on LL and LR parsers. Each of the questions has a short answer. You may discuss this assignment with other students and work on the problems together. However, your write-up should be your own individual work.
Please print your name and email address on your homework! We need this information so that we can give you credit for the assignment and so that we can return it to you.
(a)
E โ E + T | T | E! T โ int | (E)
(b)
L โ X | L, X X โ int | string | (L)
(c)
P โ P H 4 U | p H โ h U โ u | u P
P ROT O โ http P ROT O โ f tp HOST โ id I I โ I โ. HOST F ILE โ id G G โ G โ. F ILE G โ / F ILE
The nonterminals are U RL, P ROT O, HOST , I, F ILE and G.
(a) Left-factor this grammar. (b) Give the First and Follow sets for each nonterminal in the gram- mar obtained in part (a). (c) Using this information, construct an LL parsing table for the grammar obtained in part (a). (d) Suppose we generated an LL parser for the grammar using the table you constructed. What would go wrong if it tried to parse the following input string?
f tp : //id.id/id./id..id (That is, when we get an error, how much of the input string has been consumed, and what is the parser trying to do?)
A โ A + A | B + + (Each โ+โ is a separate token.) B โ y