You are on page 1of 2

Consider the grammar:

S → aA | bA | AB

A → aA | b | S

B → Ba | b

a) Give LMD (Left Most Derivation) and RMD for the string “abba” [3 M]

LMD

S → aA
→aS
→aAB
→abB
→ abBa
→ abba

RMD

S → aA

→aS
→aAB
→aABa
→ aAba
→ abba

b) Construct the parse tree for the string.

Consider the grammar:

S → aB | ε

B → bC| ε

C → cS | ε

S→ε

Following S= Following C= Following B= Following S=$


Non terminal Frist Non terminal follow

S a S $
B b B $
C c C $

Non terminal Input symbol

a b c $
S S → aB S→ε
B B → bC B→ε
C C → cS C→ε

It is contain one entry for one production So the grammar is LL(1)

You might also like