I've been having a hard time wrapping my mind around the LR parsing table. Say I have the following table

enter image description here

given the input action of id+id*id$

how does Stack 0E1+6T9*7F10 given input *$ iproduce action of R3?

  • $\begingroup$ You're in state 10 and the input is $. Looking across the chart in the row 10 until we find the column $, we see R3. Why is that confusing? $\endgroup$ – rici Mar 4 '16 at 22:22
  • $\begingroup$ okay, I was looking through the whole trace, what I didn't get was that for stack 0id5 with the input of +id * id$, and action R6(use GOTO[0,F]). then the next stack becomes 0F3. How is GOTO [0,F] used here? I can update the question if needed. $\endgroup$ – please rekt me Mar 4 '16 at 22:41
  • $\begingroup$ GOTO(0,F) is 3, again from looking at the table) which is the new state. $\endgroup$ – rici Mar 4 '16 at 23:03
  • $\begingroup$ but how does r6 know which goto to pick? it is just arbitrary? $\endgroup$ – please rekt me Mar 4 '16 at 23:20
  • $\begingroup$ It uses the non-terminal the reduction creates, and the state on top of the stack after the reduction's right-hand side has been popped. So you need to know what production is being reduced; in this case, production number 6. $\endgroup$ – rici Mar 5 '16 at 0:11

Your Answer

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

Browse other questions tagged or ask your own question.