Professional Documents
Culture Documents
Compiler Design Assignment-1: Submitted by
Compiler Design Assignment-1: Submitted by
Assignment-1
Submitted by-
Md Shakir Alam 2k18/CO/194
Que-1 E-->E+T/T
T-->T*F/F
F-->
(E)/id
Calculate first , follow then remove left recursion from the above grammar
and again calculate first and follow from updated grammar?
Sol-1 We have-
● The given grammar is left recursive.
● So, we first remove left recursion from the given grammar.
E → TE’
E’ → + TE’ / ∈
T → FT’
T’ → x FT’ / ∈
F → (E) / id
Follow Functions-
● Follow(E) = { $ , ) }
● Follow(E’) = Follow(E) = { $ , ) }
● Follow(T) = { First(E’) – ∈ } ∪ Follow(E) ∪ Follow(E’) = { + , $ , ) }
● Follow(T’) = Follow(T) = { + , $ , ) }
● Follow(F) = { First(T’) – ∈ } ∪ Follow(T) ∪ Follow(T’) = { x , + , $ , ) }