You are on page 1of 2

Assignment#02

Instructions:

 You can help each other but do not copy assignment. In case of PLAGIARISM,
assignment of both the students will be marked as ZERO. 
 Deadline for assignment submission is Thursday 16, 2019 11:59 AM. NO
 ASSIGNMENT WILL BE ACCEPTED AFTER DEADLINE. 

1. Perform the leftmost & rightmost derivation for the following Grammars, also construct
their parse tree.

a. Even Language with the given alphabet Σ = {a, b}, string: aabaab

b. E  E op E

E  id

E  num

op  + | - | * | /

string: x-2*y

c. S  aS

S  aSbS

S

String: aaabaab

d. S  aB | bA

A  a | aS | bAA

B  b | bS | aBB

String: aaabbabbba

2. Remove the left recursion from the following given grammars:

a. X → XSb / Sa / b
S → Sb / Xa / a
b. S → Aa / b
A → Ac / Sd / ∈

Compiler Construction CSC373 Ms. Eisha


c. A  Ac | Aad | xy |

3. Compute First and FOLLOW


a. S  ABC

A  a | cb |

B  C | dA |
Ce|f
b. S’  S $
S w
S a C b

C
C S x C
4. Compute all steps of LL(1) parser
a. S  (L) | a
L  L,S | S
b. S  aB | aC | Sd | S e
B  bBC | f
Cg
c. S  S a S b | c | Q q

QQm|

Compiler Construction CSC373 Ms. Eisha

You might also like