Compute First and Follow sets for the nonterminals of the following gramar:
1) S --> aSe
2) S --> B
3) B --> b B e
4) B --> C
5) C --> cC e
6) C --> d
Solution:
Explanation:
Calculating first of S:
=>first(S) = {first(aSe), first(B)}
=>first(S) = {a, b, c, d}
Calculating first of B:
=>first(B) = {first(bBe), first(C)}
=>first(B) = {b, c, d}
Calculating first of C:
=>first(C) = {first(cCe), first(d)}
=>first(C) = {c, d}
Calculating follow of S:
=>follow(S) = {$, first(e)}
=>follow(S) = {$, e}
Calculating follow of B:
=>follow(B) = {follow(S), first(e)}
=>follow(B) = {$, e, e}
=>follow(B) = {$, e}
Calculating follow of C:
=>follow(C) = {follow(B), first(e)}
=>follow(C) = {$, e, e}
=>follow(C) = {$, e}
I have explained each and every part with the help of statements attached to the answer above.
Get Answers For Free
Most questions answered within 1 hours.