0

I have been asked to convert:

S → Sa | bSb | bc 

to LL(1) so far I have:

S → bY
Y → SbF | cF
F → aF | ε

Is this LL(1)? If not would this be LL(1):

S → bY
Y → bYbF | cF
F → aF | ε

if neither of these would somebody please give me the correct answer and why thanks in advance!

kennytm
  • 510,854
  • 105
  • 1,084
  • 1,005
vezbea
  • 1
  • 1
  • What have you done so far to check whether your grammar is LL(1)? Ultimately, that's probably more valuable than just getting a binary yes/no here. – templatetypedef May 21 '16 at 04:48
  • Well it is for a past paper which had no answers available. I've derived some words from it and it seems ok and I'm pretty sure it is ll(1) I'm just unsure about the S in the Y variable and whether I would need to substitute it in or not. – vezbea May 21 '16 at 16:18

1 Answers1

0

This is what I would do:

S → Sa | bSb | bc 
  1. Remove left recursion:

    F -> aF | EPSILON```
    
  2. Now left factor:

    F -> aF | EPSILON
    X -> SbF | cF```
    
  3. Check the First and Follows:

    S: b
    X: b, c
    F: a, EPSILON```
    
    ```Follows():
    S: $, b
    X: $, b
    F: $, b```
    
    Everything checks out so it is LL(1) parsable.