* 07/16/96 Plan for Today Shift-reduce parsing The problem with - - PowerPoint PPT Presentation

07 16 96
SMART_READER_LITE
LIVE PREVIEW

* 07/16/96 Plan for Today Shift-reduce parsing The problem with - - PowerPoint PPT Presentation

* 07/16/96 Plan for Today Shift-reduce parsing The problem with predictive top down parsing CS453 : Shift Reduce Parsing LR parsing: bottom up Unambiguous Grammars LR(0) and SLR Parse Tables Performs a right-most derivation in


slide-1
SLIDE 1

* 07/16/96 1

CS453 : Shift Reduce Parsing Unambiguous Grammars LR(0) and SLR Parse Tables

CS453 Shift-reduce Parsing 1 CS453 Shift-reduce Parsing 2

Plan for Today

Shift-reduce parsing

– The problem with predictive top down parsing – LR parsing: bottom up – Performs a right-most derivation in reverse – Parsing unambiguous grammars – LR parsing table and parsing algorithm

LL ¡vs ¡LR ¡

  • LL(k) must predict which production to use when seeing k

tokens of the rhs: S à SS | (S) | ε is it S à SS or (S) when I see ((((……. ? produces the parse tree TOP DOWN

  • LR(k) postpones the decision until all tokens of the rhs plus k

more tokens have been seen. It therefore is more powerful.

  • It does this by parsing BOTTOM UP

CS453 Shift-reduce Parsing 3

Shift-reduce parsing in an LR parser

LR(k) parser – Left-to-right parse – Right-most derivation – K-token look ahead LR parsing algorithm – Performs a shift-reduce parse – Look at state at top of stack and input symbol to find action in table – shift(n): advance input, push state n on stack – reduce(k): pop rhs of grammar rule k, look up state on top of stack and lhs for goto n, push lhs(k) and n onto stack – accept: stop and success – error: stop and fail

CS453 Shift-reduce Parsing 4

slide-2
SLIDE 2

* 07/16/96 2 Example ¡LR ¡parse ¡

  • S à AB Aà Aa | a B à Bb | b S’ à S $

aaabb$ßAaabb$ßAabb$ßAbb$ß ABb$ ßAB$ßS$ßS’ Notice that this is the rightmost derivation S’àS$àAB$àABb$àAbb$àAabb$àAaabb$àaaabb$ in reverse! LR(k) parsing scans the input Left to right and produces the Rightmost derivation (looking k tokens ahead) in reverse.

CS453 Shift-reduce Parsing 5

LR ¡parsing ¡engine ¡

  • The LR parsing engine uses an Explicit Stack (as opposed to

the implicit stack of LL) and the input token string and performs two kinds of actions

  • Shift push input token onto the stack
  • Reduce pop a rhs off the stack and push the corresponding lhs
  • n the stack

It accepts the string of tokens when the input is empty or $ (eof) and the stack contains the start symbol

CS453 Shift-reduce Parsing 6

Simplified ¡example ¡LR ¡parsing ¡engine ¡ac5ons ¡

S à à AB Aà à Aa | a B à à Bb | b S’ à à S $ Stack input action aaabb$ S a aabb$ R : Aà àa A aabb$ S Aa abb$ R: Aà àAa A abb$ S Aa bb$ R: Aà àAa A bb$ S Ab b$ R: Bà àb AB b$ S ABb $ R: Bà àBb AB $ R: Sà àAB S $ accept

CS453 Shift-reduce Parsing 7 CS453 Shift-reduce Parsing 8

Shift reduce parsing applied to unambiguous grammars

[0] S à ( S ) [1] S‘ à S $ [2] S à ID

Single parentheses nest Start symbol is S’ Stack input action ((ID))$ S ( (ID))$ S (( ID))$ S ((ID ))$ R: SàId ((S ))$ S ((S) )$ R: Sà(S) (S )$ S (S) $ R: Sà(S) S $ accept

slide-3
SLIDE 3

* 07/16/96 3 Table ¡driven ¡LR ¡parse ¡algorithm ¡

The stack contains grammar symbols and states: after a symbol is pushed, the next state is pushed The actions can now be formulated as:

– Sn: push input token; push n (ie goto state n) – Rk: rule k: lhs à rhs pop rhs of rule k off the stack, this exposes a state s look up in row s and column lhs the next state gn to goto push lhs; push n (ie goto state n) – a: stop parsing, report success – _: stop parsing, report error

CS453 Shift-reduce Parsing 9

LR(0) SLR LALR LR(k) Given the shift reduce machinery described, there are various algorithms for creating the parse table. These algorithms get more and more sophisticated, starting from simple LR(0) Parser generators such as java-cup use the more sophisticated LALR parse table creation algorithm

CS453 Shift-reduce Parsing 10 CS453 Shift-reduce Parsing 11

Example LR(0) Parse Table, Single Parentheses Nest

[0] S -> ( S ) [1] S’ -> S $ [2] S -> ID

Action Goto State ( ) $ ID S s3 s1 2 1 r2 r2 r2 r2 2 accept 3 s3 s1 4 4 s5 5 r0 r0 r0 r0

In LR(0) parse tables, reduce actions happen for all terminals, as the parser does not look ahead.

Table ¡Driven ¡LR ¡Parsing ¡

The ¡parsing ¡engine ¡is ¡a ¡DFA ¡plus ¡a ¡stack: ¡a ¡determinis7c ¡ pushdown ¡automaton. ¡The ¡DFA ¡is ¡described ¡by ¡a ¡transi7on ¡table: ¡ ¡Rows ¡are ¡states ¡ ¡Columns ¡are ¡Grammar ¡symbols ¡(terminals, ¡non-­‑terminals) ¡ ¡ ¡ ¡terminals: ¡ ¡shiD ¡or ¡reduce ¡and ¡go ¡to ¡next ¡state ¡ ¡ ¡ ¡non-­‑terminals: ¡decide ¡which ¡state ¡to ¡go ¡to ¡aDer ¡a ¡reduc7on ¡ ¡ ¡So ¡there ¡are ¡five ¡kinds ¡of ¡ac7ons ¡ ¡ ¡ ¡ ¡sn: ¡ ¡ ¡shiD ¡input ¡and ¡go ¡to ¡state ¡ ¡n ¡ ¡ ¡ ¡ ¡rk: ¡ ¡ ¡reduce ¡according ¡to ¡rule ¡k, ¡then ¡gn: ¡go ¡to ¡state ¡n ¡ ¡ ¡ ¡ ¡ ¡ ¡a: ¡ ¡accept ¡ ¡ ¡ ¡ ¡ ¡ ¡_: ¡ ¡error ¡ ¡(indicated ¡by ¡blank ¡state) ¡

CS453 Shift-reduce Parsing 12

slide-4
SLIDE 4

* 07/16/96 4

LR(0) table construction

Example grammar for Lists: 0: S’ à à S$ 1: Sà à( L ) 2: Sà àx 3: Là àS 4: Là àL , S We start with an empty stack and with a complete S$ sentence on input We indicate this as follows: S’à à. S$ this (a rule with a dot in it) is called an item, it indicates what is in the stack (left of .) and what is to be expected on input (right of .) The input can start with anything S can start with, eg an x or a ( We indicate this as follows: S’à à.S$ (we are making a DFA Sà à.x throug another closure Sà à.(S) remember the NFA à à DFA) We call this a state: state 0, the start state with an empty prefix (V[ε])

CS453 Shift-reduce Parsing 13

Shift, reduce, goto actions in LR(0) table construction

CS453 Shift-reduce Parsing 14

S’à.S$ S à .x Sà.(L) 0:V[ε] shift action: In state 0 we can shift an x

  • r shift a (

S à x. 1:V[x] Sà(.L) Là.L,S Là.S S à .x Sà.(L) 2:V[(] goto action: Also in state 0 we could have reduced to S S’àS.$ 3:V[S] In state 1 we are at the end

  • f an item. This will give rise

to a reduce action Transitions: the shifts and goto-s explicitly connect the states. The reduces implicitly move to another state by popping the rhs off the stack, after which a goto with the lhs will produce a new next state

LR(0) states and transitions

CS453 Shift-reduce Parsing 15

S’à.S$ S à .x Sà.(L) 0:V[ε] S à x. 1:V[x] Sà(.L) Là.L,S Là.S Sà.x Sà.(L) 2:V[(] S’àS.$ 3:V[S] x ( S ( S L à S. 6:V[(S] S à (L.) Là L.,S 4:V[(L] L ) S à (L). 5:V[(L)] Là L,.S Sà.x Sà.(L) 7:V[(L] , ( x S L àL,S. 8:V[(L,S] List grammar 0: S’ à S$ 1: Sà( L ) 2: Sàx 3: LàS 4: LàL , S x

LR(0) Closure, Goto, State Diagram, Reduce

CS453 Shift-reduce Parsing 16

Closure(I): // state I repeat for any item Aà àα . Xβ for any Xà à γ I+= Xà à . γ until I does not change Goto(I,X): // state I , symbol X if X==$ return {} // no gotos for $ J = {} // new state for any item Aà àα . Xβ in I J+= Aà àαX . β return Closure(J) // close it State Diagram construction T = Closure({ S’ à à .S$ } ); // states E = {} // edges (gotos and shifts) repeat until no change in E or T for each state I in T for each item Aà àα . Xβ in I J = Goto(I,X); T+=J ; E += (X: (I,J)) // the edge (I,J) labeled X Reduce(T): R = {} for each state I in T for each item Aà àα . R += (I, Aà àα )

slide-5
SLIDE 5

* 07/16/96 5

LR(0) parse table construction

Parse table rows: states columns: terminals (for shift and reduce actions) non-terminals (for goto actions) For each edge (X: (I,J)) if X is terminal, put shift J at (I,X) if X is non-terminal, put goto J at (I,X) if I contains S’à àS . $ , put accept at (I,$) if I contains Aà àα . where Aà àα . has rule number n for each terminal x, put reduce reduce n at (I,x)

CS453 Shift-reduce Parsing 17

Parse table for List grammar

0: S’ à à S$ 1: Sà à( L ) 2: Sà àx 3: Là àS 4: Là àL , S ( ) x , $ S L 0 s2 s1 g3 1 r2 r2 r2 r2 r2 2 s2 s1 g6 g4 3 a 4 s5 s7 5 r1 r1 r1 r1 r1 6 r3 r3 r3 r3 r3 7 s2 s1 g8 8 r4 r4 r4 r4 r4

CS453 Shift-reduce Parsing 18

parse (x,(x))$

stack input action 0 (x,(x))$ s2 0(2 x,(x))$ s1 0(2x1 ,(x))$ r2: Sàx 0(2S6 ,(x))$ r3: LàS 0(2L4 ,(x))$ s7 0(2L4,7 (x))$ s2 0(2L4,7(2 x))$ s1 0(2L4,7(2x1 ))$ r2: Sàx 0(2L4,7(2S6 ))$ r3: LàS 0(2L4,7(2L4 ))$ s5 0(2L4,7(2L4)5 )$ r1: S à(L) 0(2L4,7S8 )$ r4: LàL,S 0(2L4 )$ s5 0(2L4)5 $ r1:Sà(L) 03S $ a

Problem with LR(0): shift reduce conflict

If there is an item Aà àα . item in I , we reduce for all terminals This can cause CONFLICTS: Eà à E+T E à à T T à à T*F In state 1: we reduce (Eà àT.) AND we shift (Tà àT . *F) What should we do?

CS453 Shift-reduce Parsing 19

Eà.E+T Eà.T Tà.T*F T EàT. TàT . *F 1 * TàT * . F 2

LR(0) shift reduce conflict

We can resolve the conflict by looking at a right most derivation: Eà àTà àT*Fà àT*idà àF*idà àid*id Stack input action id*id$ S id *id$ R: Fà àid F *id$ R: Fà àT T *id$ S We should shift T* id$ S T*id $ R: Fà àid T*F $ R: Tà àT*F T $ R:Eà à E $ accept

CS453 Shift-reduce Parsing 20

slide-6
SLIDE 6

* 07/16/96 6

SLR parsing

SLR parsing is LR(0) parsing, but with a different reduce rule: For each edge (X: (I,J)) if X is terminal, put shift J at (I,X) if I contains Aà àα . where Aà àα . has rule number n for each terminal x in Follow(A), put reduce reduce n at (I,x) Let’s build an SLR parser for our expression grammar ¡0: ¡Sà àE$ ¡ ¡ ¡1:Eà àE+T ¡ ¡ ¡2:Eà àT ¡ ¡ ¡3:Tà àT*F ¡ ¡ ¡4:Tà àF ¡ ¡ ¡5:Fà à(E) ¡ ¡ ¡6:Fà àid ¡ ¡ ¡ ¡ ¡We ¡need ¡to ¡build ¡the ¡transi5on ¡diagram ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡and ¡follow ¡sets ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡to ¡decide ¡where ¡to ¡put ¡the ¡reduce ¡ac5ons ¡in ¡the ¡SLR ¡table

CS453 Shift-reduce Parsing 21

More realistic example: Expression grammar EàE+T | T TàT*F | F Fà (E) | id SàE$ input: a*(b+c)$ ¡

¡Stack ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡input ¡ ¡ ¡ ¡ ¡ ¡ac+on ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡a*(b+c)$ ¡ ¡S ¡

¡ ¡ ¡ ¡ ¡ ¡

¡ ¡ ¡Stack ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡input ¡ ¡ ¡ ¡ac+on ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡T*(E+ ¡ ¡ ¡ ¡ ¡ ¡ ¡c)$ ¡ ¡ ¡ ¡ ¡ ¡ ¡S ¡ ¡ ¡ ¡ ¡T*(E+c ¡ ¡ ¡ ¡ ¡)$ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡R: ¡Fàid ¡ ¡ ¡ ¡ ¡T*(E+F ¡ ¡ ¡ ¡ ¡)S ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡R: ¡TàF ¡ ¡ ¡ ¡ ¡T*(E+T ¡ ¡ ¡ ¡ ¡)$ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡R: ¡EàE+T ¡ ¡ ¡ ¡ ¡T*(E ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡)$ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡S ¡ ¡ ¡ ¡ ¡T*(E) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡$ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡R: ¡Fà(E) ¡ ¡ ¡ ¡ ¡T*F ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡$ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡R: ¡TàT*F ¡ ¡ ¡ ¡ ¡T ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡$ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡R: ¡Eà àT ¡ ¡ ¡ ¡ ¡E ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡$ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡accept ¡

SàE$àT$àT*F$àT*(E)$àT*(E+T)$àT*(E+F)$à ¡T*(E+id)$àT*(T+id)$à ¡ ¡ T*(F+id)$àT*(id+id)$à ¡F*(id+id)$àid*(id+id)$ ¡ Rightmost ¡deriva3on ¡in ¡reverse ¡

¡ ¡ ¡a ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡*(b+c)$ ¡ ¡ ¡ ¡R: ¡Fàid ¡ ¡ ¡ ¡F ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡*(b+c)$ ¡ ¡ ¡ ¡R: ¡TàF ¡ ¡ ¡ ¡T ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡*(b+c)$ ¡ ¡ ¡ ¡S ¡ ¡ ¡ ¡T* ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡(b+c)$ ¡ ¡ ¡ ¡ ¡ ¡S ¡ ¡ ¡ ¡T*( ¡ ¡ ¡ ¡ ¡ ¡ ¡b+c)$ ¡ ¡ ¡ ¡ ¡ ¡ ¡S ¡ ¡ ¡ ¡T*(b ¡ ¡ ¡ ¡ ¡+c)$ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡R: ¡Fàid ¡ ¡ ¡ ¡T*(F ¡ ¡ ¡ ¡ ¡+c)$ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡R: ¡TàF ¡ ¡ ¡ ¡T*(T ¡ ¡ ¡ ¡ ¡+c)$ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡R: ¡EàT ¡ ¡ ¡ ¡T*(E ¡ ¡ ¡ ¡ ¡+c)$ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡S ¡

CS453 Shift-reduce Parsing 22

¡ ¡ ¡0: ¡Sà àE$ ¡ ¡ ¡1:Eà àE+T ¡ ¡ ¡2:Eà àT ¡ ¡ ¡3:Tà àT*F ¡ ¡ ¡4:Tà àF ¡ ¡ ¡5:Fà à(E) ¡ ¡ ¡6:Fà àid ¡

¡ ¡ ¡ ¡SLR ¡parse ¡table ¡(reduces ¡only ¡for ¡follows) ¡ ¡ ¡ ¡ ¡ State ¡ ¡ ¡ ¡ ¡ ¡id ¡ ¡ ¡ ¡ ¡+ ¡ ¡ ¡ ¡ ¡* ¡ ¡ ¡ ¡ ¡( ¡ ¡ ¡ ¡ ¡) ¡ ¡ ¡ ¡ ¡$ ¡ ¡ ¡ ¡ ¡E ¡ ¡ ¡ ¡ ¡T ¡ ¡ ¡ ¡ ¡F ¡ ¡ ¡ ¡ ¡ ¡ ¡0 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡s5 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡s4 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡g1 ¡ ¡ ¡g2 ¡ ¡ ¡g3 ¡ ¡ ¡ ¡ ¡1 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡s6 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡a ¡ ¡ ¡ ¡ ¡2 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡r2 ¡ ¡ ¡ ¡s7 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡r2 ¡ ¡ ¡r2 ¡ ¡ ¡ ¡ ¡ ¡3 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡r4 ¡ ¡ ¡ ¡r4 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡r4 ¡ ¡ ¡r4 ¡ ¡ ¡ ¡ ¡4 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡s5 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡s4 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡g8 ¡ ¡ ¡g2 ¡ ¡ ¡g3 ¡ ¡ ¡ ¡ ¡5 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡r6 ¡ ¡ ¡ ¡r6 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡r6 ¡ ¡ ¡r6 ¡ ¡ ¡ ¡ ¡6 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡s5 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡s4 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡g9 ¡ ¡ ¡g3 ¡ ¡ ¡ ¡ ¡7 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡s5 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡s4 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡g10 ¡ ¡ ¡ ¡ ¡8 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡s6 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡s11 ¡ ¡ ¡ ¡ ¡9 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡r1 ¡ ¡ ¡ ¡ ¡s7 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡r1 ¡ ¡ ¡r1 ¡ ¡ ¡ ¡10 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡r3 ¡ ¡ ¡ ¡ ¡r3 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡r3 ¡ ¡ ¡r3 ¡ ¡ ¡ ¡11 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡r5 ¡ ¡ ¡ ¡ ¡r5 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡r5 ¡ ¡ ¡r5 ¡ Stack ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡input ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ac+on ¡

0 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡a*(b+c)$ ¡ ¡ ¡ ¡s5 ¡ 0a5 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡*(b+c)$ ¡ ¡ ¡ ¡r6: ¡Fàid ¡ 0F3 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡*(b+c)$ ¡ ¡ ¡ ¡r4: ¡TàF ¡ 0T2 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡*(b+c)$ ¡ ¡ ¡ ¡s7 ¡ 0T2*7 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡(b+c)$ ¡ ¡ ¡ ¡s4 ¡ 0T2*7(4 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡b+c)$ ¡ ¡ ¡ ¡s5 ¡ 0T3*7(4b5 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡+c)$ ¡ ¡ ¡ ¡r6: ¡Fàid ¡ 0T3*7(4F3 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡+c)$ ¡ ¡ ¡ ¡ ¡r4: ¡TàF ¡ 0T3*7(4T2 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡+c)$ ¡ ¡ ¡ ¡ ¡r2: ¡EàT ¡ 0T3*7(4E8 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡+c)$ ¡ ¡ ¡ ¡ ¡s6 ¡ 0T3*7(4E8+6 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡c)$ ¡ ¡ ¡ ¡s5 ¡ 0T3*7(4E8+6c5 ¡ ¡ ¡ ¡ ¡ ¡ ¡)$ ¡ ¡ ¡ ¡r6: ¡Fàid ¡ 0T3*7(4E8+6F3 ¡ ¡ ¡ ¡ ¡ ¡ ¡)$ ¡ ¡ ¡ ¡r4: ¡TàF ¡ 0T3*7(4E8+6T9 ¡ ¡ ¡ ¡ ¡ ¡ ¡)$ ¡ ¡ ¡ ¡r1: ¡EàE+T ¡ 0T3*7(4E8 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡)$ ¡ ¡ ¡ ¡S11 ¡ 0T3*7(4E8)11 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡$ ¡ ¡ ¡ ¡r5: ¡Fà(E) ¡ 0T3*7F10 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡$ ¡ ¡ ¡ ¡r3: ¡TàT*F ¡ 0T2 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡$ ¡ ¡ ¡ ¡r2: ¡EàT ¡ ¡ 0E1 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡$ ¡ ¡ ¡ ¡a ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡

CS453 Shift-reduce Parsing 23