This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
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
 Fall '09
 Recursion, Contextfree grammar, Left recursion, FOLLOW sets, id  num, FOLLOW Sets Removing

Click to edit the document details