This
** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*
**Unformatted text preview: **RHS of productions. The algorithm is based on computing nullable nonterminals and then setting systems of equations. FIRST sets can be calculated for all strings over a given alphabet. FIRST sets include terminals and epsilon. Input: a CFG G Output: FIRST sets for nonterminals (they can be used to compute FIRST for RHS) If X is a terminal, then FIRST(X) is X. If X derives the empty string then add epsilon to FIRST(X). If X is nonterminal and X --> Y_1Y_2 . .. Y_k is a production, then add FIRST(Y_1) . .. FIRST(Y_{i+1}) to FIRST(X) if FIRST(Y_1 . .. FIRST(Y_i) contain the empty string epsilon. If i = k then add the empty string epsilon to FIRST(X).-------An additional handout for the FIRST and FOLLOW sets has been distributed in class. Please request a copy if you do not have one. Pending assignments:- PA 1 (due this Friday) and hw3 (due 9/23) and hw4 (due 9/28)...

View
Full
Document