Given the following grammar with terminals $VT=\{[,],a,b,c,+,-\}:$

$S \rightarrow [SX]|a$

$X \rightarrow +SY|Yb|\epsilon$

$Y \rightarrow -SXc|\epsilon$

This should be the FIRST function:

$first(S) = \{[,a\}$

$first(X) = \{\epsilon,+,-,b\}$

$first(Y) = \{\epsilon,-\}$

What would the FOLLOW function be?

  • $\begingroup$ There is an algorithm for computing the FOLLOW function. All you have to do is run it, manually or on a computer. It is even likely that people have already programmed this, and you can use their code. $\endgroup$ – Yuval Filmus May 16 '20 at 10:43

This is the FOLLOW function:

$follow(S) = \{\$,+,-,b,],c\}$

$follow(X) = \{],c\}$

$follow(Y) = \{b,],c\}$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.