1. ITM UNIVERSITY REVIEW DATE: 5th Jan’12
School/ Department: Department of CSE Tutorial Sheet No.5
Subject Name :Principles of Compiler Design Issue Date: Pages:
Subject Code : CSL 306
Faculty : Semester:
Unit/Title: LR Parsers Niharika 6th
Garg
Q1. Explain in detail LR Parsers.
Q2. Explain the algorithm for the construction of SLR parsing table.
Q3. Construct SLR parser table for grammar:
E’ E
E E + T/T
T T * F/F
F (E)/id
Is the Grammar ambiguous? Give reasons.
Q4.Write LR Parsing algorithm? Construct LR parsing table for the grammar:
E E+T
E T
T T * F
T F
f (E)
T id
Q5. Following is an LL(1) grammar for regular expression over alphabet {a,b} with +
standing for union operator (1) and E for symbol €.
E TE’
E’+E/€
TFT’
T’ T/€
F PF’
F’ *F’/€
P (E)/a/b/€
(a) Compute FIRST and FOLLOW for each non-terminal of above grammar.
(b) Show that grammar is LL (1).
(c) Construct the predictive parsing table for grammar.
(d) Construct a recursive descent parser for the grammar.