Question
Consider the grammar with the following rules (capital letters are nonterminals and S is the start nonterminal): S -> AB | a A -> CD
Consider the grammar with the following rules (capital letters are nonterminals and S is the start nonterminal):
S -> AB | a
A -> CD
B -> bAB |
C-> dSd | c
D -> cCD |
a) Determine each of the sets:
i) FIRST(AB)
ii) FIRST(CD)
iii) FOLLOW(S)
iv) FOLLOW(A)
v) FOLLOW(B)
vi. FOLLOW(C)
vii. FOLLOW(D)
For each element z belonging to a set FOLLOW(X) (X {S,A,B,C,D}) give a derivation starting from S where z occurs directly after X. (Similar sample derivations are not required for FIRST-sets.)
b) Does the grammar allow use of recursive-descent parsing? Justify your answer using your answers from part a.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started