【正文】
– S). 2. State i is determined from Ii. The parsing actions for the state are determined as follows: a) If [A – u?, a] is in Ii then set Action[i,a] to reduce A – u (note A may not be S39。). b) If S39。 – S? is in Ii then set action[i,] to accept. c) If A – u?av is in Ii and GO(Ii, a) = Ij, then set action[i,a] to shift j (a is a terminal). 3. The goto transitions for state i are constructed for all nonterminals A using the rule: If GO(Ii, A) = Ij, then goto [i, A] = j. 4. All entries not defined by rules 2 and 3 are errors. 5. The initial state is the one constructed from the configurating set containing S39。). b) If [S39。 (augmented by adding the special production S39。. 2. State i is determined from Ii. The parsing actions for the state are determined as follows: a) If A – u? is in Ii then set action[i,a] to reduce A – u for all input. (A not equal to S39。 – ?S. LR(0) grammar A grammar is LR(0) if the following two conditions hold for each configurating set: 1. For any configurating set containing the item A – u?xv there is no plete item B – w? in that set. In the tables, this translates to no shiftreduce conflict on any state. 2. There is at most one plete item A – u? in each configurating set. This translates to no reducereduce conflict on any state. SLR(1) SLR(1) where the S is for Simple. SLR(1) parser uses the same LR(0) configurating sets and has the same table structure and parser operation, . The difference es in assigning table actions, where we are going to use a token of lookahead to help arbitrate among the conflicts. If the string on top of the stack could be reduced to the nonterminal A, what tokens do we expect to find as the next input? What tokens would tell us that the reduction is not appropriate? Answer is to use Follow(A). SLR(1) table construction 1. Construct F = {I0, I1, ... In}, the collection of LR(0) configurating sets for G39。 – S?, $] is in Ii then set Action[i,$] to accept. c) If [A – u?av , b] is in Ii and succ(Ii, a) = Ij, then set Action[i,a] to shift j (a must be a terminal). 3. The goto transitions for state i are constructed for all nonterminals A using the rule: If succ(Ii, A) = Ij, then Goto [i, A] = j. 4. All entries not defined b