Chapter 4: Syntax Analysis

Configurations in LR parser

Stack: S0 X 1 S1 X2 .X m Sm Input: ai ai+1 .an $

. If action[Sm ,ai ] = shift S Then the configuration becomes

Stack : S0 X1 S1 ..Xm Sm a i S Input : ai+1 .an $

. If action[S m ,ai ] = reduce A ß Then the configuration becomes

Stack : S0 X 1 S1 .X m-r Sm-r AS Input : ai ai+1 .an $

Where r = | ß | and S = goto[S m-r ,A]

. If action[Sm ,ai ] = accept

Then parsing is completed. HALT

. If action[Sm ,ai ] = error

Then invoke error recovery routine.