5,525 views

Consider the following grammar

E → E+T/T

T → T*F/F

F → id/(E)

Calculate Lead and Last for every Non terminal.

from where u got this ???
Please solve it it is very important and basic question i know tht but i m having confuse. i beg you please solve i m very poor guy and i havent done coaching like you all guys over here.

No gate question or any other questions will be in this way

### Subscribe to GO Classes for GATE CSE 2022

Lead :- Lead is a list of all those terminals symbols("operators") which can appear first on any right hand side of a production.

For each non-terminal i.e. left hand side,a Lead list containing the first terminal in each production for that non-terminal.Where a non-terminal is the first symbol on the right hand side, include both it and the first terminal following.e.g. for

X $\rightarrow$ a.... / Bc

includes a,c and B in X's Lead List.

Trail:- Trail or Last is a similar list of those terminals which can appear Last.

For each non-terminal i.e. left hand side,a Last or trail list containing the last terminal in each production for that non terminal.Where a non-terminal is the last symbol on the right hand side, include both it and the last terminal .e.g. for

Y $\rightarrow$ ....u / ....vW

includes u,v and W in Last or Trail list.

Now for the given Grammar

Lead(E) ={ + , * , id , (   }               Last={ + , * ,  id , )  }

Lead(T) ={ * , id , (   }                    Last={ * , id , )   }

Lead(F)={ id , ( }                            Last={ id , ) }

### 1 comment

edited
@shivani did u got answer or shud i tell...this is not gate type question...but it can appear in ISRO exam....///@sharma ji it wud have been ..better if you wud have explained step by step...for evry non-terminal plz update it

Lead(E) ={ ( +,*,id}                  Last(E) ={ +,*id, ) }

Lead(T) = { *,id,( }                Last(T) ={ *,id, ) }

Lead(F) = { id,( }                 Last(F) ={ id, ) }

@alok Are My dear , we r not scolding. But here we r to guide each other in a better way, right?. So, if one not getting the answer , other could find the way, if one do some mistake ,other could take in a right way. So, be happy - we all are for each other .

edited

alokthebranded without posting the answer how she did know that her answer was right or wrong .but you selected it and she thinks she was right and other users will also think the same that selected answer is right.

alokthebranded are itna preshan hone ki jaroorat nhi h.be cool be happy

yes rt @Leen

1
147 views