Home » Compiler Design » Compiler design miscellaneous » Question

Compiler design miscellaneous

  1. The grammar S → aSa | bS| c is
    1. LL (1) but not LR (1)
    2. LR (1) but not LL (1)
    3. Both LL (1) and LR (1)
    4. Neither LL (1) and LR (1)
Correct Option: C

S → aSa | bS | C
The above grammar is LL (1) because,
First [aSa] ∩ first [bS] = (a) ∩ (b) = φ
First [bS] ∩ first [c] = (b) ∩ (c) = φ
First [c] ∩ first [aSa] = (c) ∩ (a) = φ
As the above grammar is LL (1), also LR (1) because LL (1) grammar is always LR (1) grammar.



Your comments will be displayed only after manual approval.