in Compiler Design
195 views
0 votes
0 votes
FIRST and FOLLOW for the postfix grammar after removing left recusrion  S → S S + | S S * | a
in Compiler Design
by
195 views

2 Answers

1 vote
1 vote
(after removing left recursion)

S->S’

S’->S+S’/S*S’/a/∈

 

FIRST(S)={a,∈}

FIRST(S’)={a,∈}

FOLLOW(S)={ +,*}

FOLLOW(S’)={ +,* }
0 votes
0 votes
Given grammar :

S->SS+| SS*| a

Remove left recursion :

S ->aS’

S’->ε|S+S’|S*S’

FIRST(S) ={a}

FIRST(S’) = {ε,a}

FOLLOW(S) = {$,+,*}

FOLLOW(S’) = {$,+,*}