slides08-lr-parsing
slides08-lr-parsing
stmt_list Continue
Continue to
tokens
to shift
shift and
and reduce
reduce tokens
tokens
tokens to
to recognize
recognize another
another stmt
stmt
stmt_list read B Stack shows what constructs
stmt_list stmt have been recognized so far
Example Program and SLR(1) Grammar
read A
read B
sum := A + B
write sum
write sum / 2
Modeling a Parse with LR Items
• stack / item: 0
• input: stmt read B …
• stack / item: 0
• input: stmt_list read B …
There are also shift-reduce actions. So our states 0’, 1’ aren’t shown
here: they are “in between” states within a shift-reduce action
The CFSM as a Table
A Detailed Explanation of the CFSM
A Detailed Explanation of the CFSM
A Detailed Explanation of the CFSM
Exercise: LR Parsing