in Compiler Design retagged by
1,463 views
3 votes
3 votes

Consider the Following Grammar

P - > S

S  - > A | A ;S 

A - > id = E

E - > E+E | E-E | E*E | E/E | (E) | T

T - > id | num

Calculate FIRST and FOLLOW for each non terminal. 

in Compiler Design retagged by
1.5k views

1 Answer

3 votes
3 votes
Best answer

First(P)={id}                                            Follow(P)={$}

First(S)={id}                                            Follow(S)={ $}

First(A)={id}                                            Follow(A)={ ; , $}

First(E)={  ( , id ,num }                           Follow(E)={ + , - , * , / , ) , ; , $ }

First(T) ={id , num}                                 Follow(T)={ + , - , * , / , ) , ; , $ }

edited by

4 Comments

No u are wrong
0
0
Your first (A) is wrong.. first (A) =id.. therefore first (A) is not equal to first(E)
0
0
First we need to convert the E production to non left recursive grammar?

Isn't it??
0
0