edited by
874 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

0 votes
0 votes
1 answer
1
Subhrangsu asked Apr 15, 2022
2,212 views
Compute FIRST and FOLLOW sets:S→ aAC | bBA→ Abc| Abd | eB→ f | gC→ h | i
0 votes
0 votes
1 answer
2
saumya mishra asked Jun 3, 2018
3,264 views
Find first and follow of the given grammar?S->ABA->BS/a/€B->AS/b
3 votes
3 votes
1 answer
3
LavTheRawkstar asked Jun 25, 2016
1,518 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.
0 votes
0 votes
1 answer
4