in Compiler Design retagged by
1,124 views
2 votes
2 votes
Trailing symbols of E

E -> E + T | T

T -> T * F | F

F -> (E) | id
in Compiler Design retagged by
by
1.1k views

4 Comments

Thanku so much. . @Shivam Chauhan
0
0
I think FOLLOW(E) = {$, +, )}
0
0

3 Answers

1 vote
1 vote
edited by

1 comment

but id is also given as the solution
0
0
0 votes
0 votes
Terminal first follow
E (,id $,+,)
T (,id $,+,),*
F (,id $,+,),*

2 Comments

yes this is correct
0
0
0 votes
0 votes

 Trail : Any terminal which is present at the last of a right sentential form (and not the sentence) which is derived from a non-terminal is the trailing of that non-terminal.

Trail(E) :

E→E+   --In this the trailing is '+'

E→E+TF [using T→T∗F] -- Here trailing is '∗'

E→E+T∗(E) [using F→(E)Here trailing is ')'

(from E+T∗F) →E+T∗id [using F→id] -- Here trailing is 'id'

therefore

trail(E) = {+,∗,),id}

Similarly for T={ * , id, )}

E→ E+T

       E+T*F     or  E→E+T*id

       E+T*(E)

 for F={ id, )}

E→ E+T

       E+T*F

       E+T*(E      or   E+T*id

edited by