Compiler Design and Construction - Old Questions
3. Find first and follow of all the non terminals in the following grammar.
6 marks
|
Asked in 2073
The given grammar is;
Now, the FIRST and FOLLOW of given non-terminals are:
FIRST(A) = FIRST(T) = FIRST(X) = {(, a}
FIRST(E) = {+, ∈}
FIRST(Y) = {*, ∈}
FOLLOW(A) = {), $}
FOLLOW(E) = {), $}
FOLLOW(T) = {), +, $}
FOLLOW(Y) = {), +, $}
FOLLOW(X) = {*, +, ), $}
Non-terminals |
FIRST() |
FOLLOW() |
A |
{(, a} |
{), $} |
E |
{+, ∈} |
{), $} |
T |
{(, a} |
{), +, $} |
Y |
{*, ∈} |
{), +, $} |
X |
{(, a} |
{*, +, ), $} |