-2
$\begingroup$

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?

$\endgroup$
1
  • $\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
0
$\begingroup$

This is the FOLLOW function:

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

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

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

$\endgroup$

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.