Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Fakulti Teknologi dan Sains Maklumat

TK3163: Tutorial Eliminating and Recursive Descent Parsing

1. Consider the context-free grammar (CFG) S  aSbS | bSaS |  and the string w = aabbab

Eliminate the ambiguous.

2. Consider the grammar

A  AAa | Bb | ab

Eliminate the ambiguous.

3. Consider the CFG S  S + S| SS | (S) | S* | a


Clean the grammar with eliminating the ambiguous, left recursion or left factoring if any.

4. Eliminate left recursion from the following grammar.

A  AB | a
Bb

5. Consider the following grammar G = ({a, b, c, d}, {S,X}, P, S), with P:

S  Xa |Xb
X  Xc | d

Apply left factoring of the productions for S followed by left recursion elimination of the
productions for X.

6. Consider the grammar

ET+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.

7. Consider the grammar

E  TX
T  (E) | int Y
X  +E | 
Y  *T | 

and input w = int*int.


a) Construct a parse tree by using recursive descent parsing.
8. Consider the grammar S  aSa | aa. Show that this recursive descent parser recognizes aaaa
but not aaaaaa.

You might also like