in Compiler Design retagged by
518 views
1 vote
1 vote

 

$\text{ Find $\textbf{First(A)}$ and $\textbf{Follow(B)}$ }?$ 

in Compiler Design retagged by
518 views

3 Answers

2 votes
2 votes
Best answer

First and Follow calculation

First and Follow calculation of A and B respectively.

selected by

1 comment

Thanks
0
0
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}
by

4 Comments

@Dadu Totally WRONG!  

0
0
What is the answer ??
0
0

@Dadu Fi(A) = {a,b,c}, Fo(B) = { a, c, $ } 

0
0
Yeah I just realized, there was 1 silly mistake
0
0
0 votes
0 votes
First(A) = {a,b,c}

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

4 Comments

In  A → BcA, if we replace B with epsilon then first of A will be c for this case, thats why
0
0

@DextroLaev edit your solution 

instead of a,b epi  it should be a,b,c;

0
0
Done
0
0