edited by
1,021 views

2 Answers

Best answer
3 votes
3 votes
$First(E) = First(T)$

$First(T) = First(F)$

$First(F) = \left \{ a,b \right \}$

$First(E) = First(T) = First(F) = \left \{ a,b \right \}$

$Follow(E) = \left \{ +,\$ \right \}$

$Follow(T) = First(F) \bigcup Follow(E) = \left \{ a , b,+,\$ \right \}$

$Follow(F) = \begin{Bmatrix} * \end{Bmatrix} \bigcup Follow(T) = \left \{ * , a , b,+,\$ \right \}$
selected by
1 votes
1 votes

For FIRST

FIRST(a) = Set of those terminals with which the strings derivable from a start
If a = XYZ, then FIRST(a) is computed as follows:
FIRST(a) = FIRST(XYZ) = { X } if X is terminal.
Otherwise,
FIRST(a) = FIRST(XYZ) = FIRST(X) if X does not derive to an empty string; that is, if
FIRST(X) does not contain ε.
If FIRST(X) contains ε, then
FIRST(a) = FIRST(XYZ) = FIRST(X) - { ε } U FIRST(YZ)
FIRST(YZ) is computed in an identical manner:
FIRST(YZ) = { Y } if Y is terminal.
Otherwise,
FIRST(YZ) = FIRST(Y) if Y does not derive to an empty string (i.e., if FIRST(Y) does not contain ε). If FIRST(Y)
contains ε , then
FIRST(YZ) = FIRST(Y) - { ε } U FIRST(Z)

For FOLLOW

FOLLOW(A) = Set of terminals that immediately follow A in any string occurring on the right side of productions of the
grammar
For example, if A->aBβ is a production, then FOLLOW(B) can be computed using A->aBb, as shown below:
FOLLOW(B) = FIRST(β) if FIRST(β) does not contain ε

FOLLOW(B) = FIRST(β) - { ε } U FOLLOW(A)  if FIRST(β) contains ε

----------------------------------------------------------------------------------------------------------

First(E)=First(T)

First(E)=First(T)

First(T)=First(F)

First(T)=First(F)

First(F)={a,b}

First(E)=First(T)=First(F)={a,b}

Follow(E)={+,$}

Follow(T)=First(F)⋃Follow(E)={a,b,+,$}

Follow(F)={∗}⋃Follow(T)={∗,a,b,+,$}

Related questions

2.6k
views
1 answers
0 votes
Subhrangsu asked Apr 15, 2022
2,577 views
Compute FIRST and FOLLOW sets:S→ aAC | bBA→ Abc| Abd | eB→ f | gC→ h | i
3.5k
views
1 answers
1 votes
saumya mishra asked Jun 3, 2018
3,548 views
Find first and follow of the given grammar?S->ABA->BS/a/€B->AS/b
1.7k
views
1 answers
3 votes
LavTheRawkstar asked Jun 25, 2016
1,688 views
Consider the Following GrammarP - > SS - > A | A ;S A - > id = EE - > E+E | E-E | E*E | E/E | (E) | TT - > id | numCalculate FIRST and FOLLOW for each non terminal.
265
views
2 answers
0 votes
Ana_101 asked Apr 19
265 views
S -> A BA -> f S fA -> b b B dB -> ƐB -> cFirst(S) =First(A) =First(B) =Follow(S) =Follow(A) =Follow(B) =