retagged by
526 views

3 Answers

Best answer
2 votes
2 votes

First and Follow calculation

First and Follow calculation of A and B respectively.

selected by
0 votes
0 votes
S → bA | aB

A → AaS | BcA | a

B → bS | ε

FIRST (S) = FIRST(bA) U FIRST (aB)

                = {b,a}
 

FIRST (A) = FIRST(AaS)  U  FIRST(BcA) U  FIRST(a)   ------------ {FIRST(AaS) We will not consider this beacuse of recurssion}

                  = FIRST(B)-{ε}  U {a}

                  ={b,ε}-{ε}  U {a}

FIRST (A) = {b, a}

FOLLOW(A) = {a}  U  FOLLOW (A) U FOLLOW(S)

                     ={ a, $}

FOLLOW(B) = {c} U FOLLOW(S)

                                    S → aB

FOLLOW(B) ={$,c}

FOLLOW (S) = {$} U FOLLOW(S) U FOLLOW(S)

                                    A → AaS             B → bS

                       ={$} U FOLLOW(A) U FOLLOW(B)

                       ={$} U { a, $} U {$,c}
FOLLOW (S)  = { $, a, c}
0 votes
0 votes
First(A) = {a,b,c}

Follow(B) = { $,c, a}
edited by

Related questions

1 votes
1 votes
1 answer
3
vinay chauhan asked Dec 30, 2018
1,316 views
Consider the following grammar G shown Below :S → abS | ScS | d | cThe number of terminals in follow set of non-terminal S is ___________________ Is “$” symbol cons...