Professional Documents
Culture Documents
8
LR(1)
LALR
LL(1) SLR
LR(0)
9
stack input
1. S’ → E id + $ E $0 id+id+id$
2. E → E + E 0 s2 1 … …
3. E → id 1 s3 acc $0E1+3E4 +id$
2 r3 r3
3 s2 4
4 s3/r2 r2
When shifting on +:
yields right associativity
id+(id+id)
Shift/reduce conflict: When reducing on +:
action[4,+] = shift 4 yields left associativity
action[4,+] = reduce E → E + E (id+id)+id 10
▪ Left-associative operators: reduce
▪ Right-associative operators: shift
▪ Operator of higher precedence on stack: reduce
▪ Operator of lower precedence on stack: shift
stack input
$0 id*id+id$
S’ → E
E→E+E … …
E→E*E $0E1*3E5 +id$ reduce E → E * E
E → id
11
Thank You!!!!