Copyright © 2006 Gradiance Corporation.
Top-Down Parsing
Predictive and LL parsing.
1.
Create a predictive parsing table for the following grammar with productions numbered 1-6.
Indicate which of the following statements is true about one of the entries of your table. Note: we use the notation T(X,c) to represent (by its number) the production used to expand variable X when c is the lookahead. $ is the lookahead that represents the end of the input. T(X,c) = error means there is no correct choice of expansion.
a)
T(B,$) = 5
b)
T(A,b) = 3
c)
T(S,a) = both 1 and 2
d)
T(A,a) = 3
2.
Construct the predictive parsing table for this LL(1) grammar:
S → ABCDE
A → a
B → b | ε
C → c | ε
D → d
E → e | ε
Then, identify the correct table entry from the list below. Note, T(X,Y) is the production with which variable X will be expanded, when the lookahead symbol is Y. Also, "T(X,Y) = error" means that there is no production with which to expand X on lookahead Y.
T(C,d) = error
T(B,b) = B → b
T(A,b) = A → a
T(D,e) = D → d
3.
C → c
D → d | ε
T(E,e) = E → e
T(B,c) = error
T(D,$) = error
T(B,$) = B → ε