Professional Documents
Culture Documents
TK3163 Sem2 20172018 Tutorial Eliminating and Recursive
TK3163 Sem2 20172018 Tutorial Eliminating and Recursive
1. Consider the context-free grammar (CFG) S aSbS | bSaS | and the string w = aabbab
A AAa | Bb | ab
A AB | a
Bb
S Xa |Xb
X Xc | d
Apply left factoring of the productions for S followed by left recursion elimination of the
productions for X.
ET+E|T
T int | int * T | (E)
and input w = int*int. Construct a parse tree for the input string w by using recursive descent
parsing.
E TX
T (E) | int Y
X +E |
Y *T |