bottom up parsing - compiler design - dr. d. p. sharma - nit surathkal by wahid311
DESCRIPTION
Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311TRANSCRIPT
![Page 1: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/1.jpg)
1
Bottom-up ParsingBottom-up ParsingBottom-up ParsingBottom-up Parsing Bottom-up parsing is more
general than top-down parsing
Bottom-up parsers handle a large class of grammars.
Preferred method in practice
![Page 2: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/2.jpg)
2
Bottom-up ParsingBottom-up ParsingBottom-up ParsingBottom-up Parsing Bottom-up parsing is more
general than top-down parsing
Bottom-up parsers handle a large class of grammars.
Preferred method in practice
![Page 3: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/3.jpg)
3
Bottom-up ParsingBottom-up ParsingBottom-up ParsingBottom-up Parsing Bottom-up parsing is more
general than top-down parsing
Bottom-up parsers handle a large class of grammars.
Preferred method in practice
![Page 4: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/4.jpg)
4
Bottom-up ParsingBottom-up ParsingBottom-up ParsingBottom-up ParsingAlso called LR parsing L means that tokens are
read left to right R means that the parser
constructs a rightmost derivation.
![Page 5: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/5.jpg)
5
Bottom-up ParsingBottom-up ParsingBottom-up ParsingBottom-up ParsingAlso called LR parsing L means that tokens are
read left to right R means that the parser
constructs a rightmost derivation.
![Page 6: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/6.jpg)
6
Bottom-up ParsingBottom-up ParsingBottom-up ParsingBottom-up ParsingAlso called LR parsing L means that tokens are
read left to right R means that the parser
constructs a rightmost derivation.
![Page 7: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/7.jpg)
7
Bottom-up ParsingBottom-up ParsingBottom-up ParsingBottom-up Parsing LR parsers donot need
left-factored grammars LR parsers can handle
left-recursive grammars
![Page 8: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/8.jpg)
8
Bottom-up ParsingBottom-up ParsingBottom-up ParsingBottom-up Parsing LR parsers donot need
left-factored grammars LR parsers can handle
left-recursive grammars
![Page 9: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/9.jpg)
9
Bottom-up ParsingBottom-up ParsingBottom-up ParsingBottom-up Parsing
LR parsing reduces a string to the start symbol by inverting productions.
![Page 10: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/10.jpg)
10
Bottom-up ParsingBottom-up ParsingBottom-up ParsingBottom-up Parsing A derivation consists of a
series of rewrite steps
S 0 1 ... n-1 n sentence
![Page 11: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/11.jpg)
11
Bottom-up ParsingBottom-up ParsingBottom-up ParsingBottom-up ParsingS 0 ... n sentence
Each i is a sentential form if contains only terminals,
is a sentence in L(G) If contains 1
nonterminals, is a sentential form
![Page 12: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/12.jpg)
12
Bottom-up ParsingBottom-up ParsingBottom-up ParsingBottom-up ParsingS 0 ... n sentence
Each i is a sentential form if contains only terminals,
is a sentence in L(G) If contains 1
nonterminals, is a sentential form
![Page 13: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/13.jpg)
13
Bottom-up ParsingBottom-up ParsingBottom-up ParsingBottom-up ParsingS 0 ... n sentence
Each i is a sentential form if contains only terminals,
is a sentence in L(G) If contains 1
nonterminals, is a sentential form
![Page 14: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/14.jpg)
14
Bottom-up ParsingBottom-up ParsingBottom-up ParsingBottom-up Parsing A bottom-up parser builds a
derivation by working from input sentence back towards the start symbol S
S 0 ... n sentence
![Page 15: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/15.jpg)
15
Bottom-up ParsingBottom-up ParsingBottom-up ParsingBottom-up Parsing Consider the grammar
S → aABeA → Abc | bB → d
![Page 16: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/16.jpg)
16
Bottom-up ParsingBottom-up ParsingBottom-up ParsingBottom-up Parsing The sentence abbcde can be
reduced to S:abbcdeaAbcdeaAdeaABeS
![Page 17: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/17.jpg)
17
Bottom-up ParsingBottom-up ParsingBottom-up ParsingBottom-up Parsing The sentence abbcde can be
reduced to S:abbcdeaAbcdeaAdeaABeS
![Page 18: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/18.jpg)
18
Bottom-up ParsingBottom-up ParsingBottom-up ParsingBottom-up Parsing The sentence abbcde can be
reduced to S:abbcdeaAbcdeaAdeaABeS
![Page 19: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/19.jpg)
19
Bottom-up ParsingBottom-up ParsingBottom-up ParsingBottom-up Parsing The sentence abbcde can be
reduced to S:abbcdeaAbcdeaAdeaABeS
![Page 20: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/20.jpg)
20
Bottom-up ParsingBottom-up ParsingBottom-up ParsingBottom-up Parsing The sentence abbcde can be
reduced to S:abbcdeaAbcdeaAdeaABeS
![Page 21: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/21.jpg)
21
Bottom-up ParsingBottom-up ParsingBottom-up ParsingBottom-up Parsing These reductions, in fact,
trace out the following right-most derivation in reverse: S aABe
aAde aAbcde abbcde
![Page 22: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/22.jpg)
22
S By y xy rmrm rm
xx y
B
S
rule: B →
Terminals only
![Page 23: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/23.jpg)
23
Bottom-up ParsingBottom-up ParsingBottom-up ParsingBottom-up Parsing
Consider the grammar
1. E → E + (E) 2. | int
![Page 24: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/24.jpg)
24
Bottom-up ParsingBottom-up ParsingBottom-up ParsingBottom-up Parsing
Consider bottom-up parse of the string
int + (int) + (int)
![Page 25: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/25.jpg)
25
int + (int) + (int)
int+ ( int )int + ( )
![Page 26: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/26.jpg)
26
int + (int) + (int)
E + (int) + (int)
int+ ( int )int + ( )
E
![Page 27: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/27.jpg)
27
int + (int) + (int)
E + (int) + (int)
E + (E) + (int)
int+ ( int )int + ( )
E E
![Page 28: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/28.jpg)
28
int + (int) + (int)
E + (int) + (int)
E + (E) + (int)E + (int)
int+ ( int )int + ( )
E E
E
![Page 29: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/29.jpg)
29
int + (int) + (int)
E + (int) + (int)E + (E) + (int)E + (int)E + (E)
int+ ( int )int + ( )
E E E
E
![Page 30: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/30.jpg)
30
int + (int) + (int)
E + (int) + (int)E + (E) + (int)E + (int)E + (E)E
int+ ( int )int + ( )
E E E
E
EA rightmost derivation in reverse
![Page 31: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/31.jpg)
31
Bottom-up ParsingBottom-up ParsingBottom-up ParsingBottom-up Parsing
An LR parser traces a rightmost derivation in reverse
![Page 32: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/32.jpg)
32
ConsequenceConsequenceConsequenceConsequence Let be a step of a
bottom-up parse Assume that next reduction
is A → Then is a string of
terminals!
![Page 33: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/33.jpg)
33
ConsequenceConsequenceConsequenceConsequence Let be a step of a
bottom-up parse Assume that next reduction
is A → Then is a string of
terminals!
![Page 34: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/34.jpg)
34
ConsequenceConsequenceConsequenceConsequence Let be a step of a
bottom-up parse Assume that next reduction
is A → Then is a string of
terminals!
![Page 35: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/35.jpg)
35
ConsequenceConsequenceConsequenceConsequenceWhy? Because A → is a
step in a rightmost derivation
![Page 36: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/36.jpg)
36
NotationNotationNotationNotation
Idea: Split the string into two
substrings
![Page 37: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/37.jpg)
37
NotationNotationNotationNotation Right substring (a string of
terminals) is as yet unexamined by parser
Left substring has terminals and non-terminals
![Page 38: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/38.jpg)
38
NotationNotationNotationNotation Right substring (a string of
terminals) is as yet unexamined by parser
Left substring has terminals and non-terminals
![Page 39: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/39.jpg)
39
NotationNotationNotationNotation The dividing point is marked
by a ►
• The ► is not part of the string
Initially, all input is unexamined: ►x1 x1 . . . xn
![Page 40: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/40.jpg)
40
Shift-Reduce ParsingShift-Reduce ParsingShift-Reduce ParsingShift-Reduce Parsing
Bottom-up parsing uses only two kinds of actions:
1. Shift2. Reduce
![Page 41: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/41.jpg)
41
ShiftShiftShiftShiftMove ► one place to the rightshifts a terminal to the left string
E + (► int) E + (int ►)
![Page 42: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/42.jpg)
42
ReduceReduceReduceReduceApply an inverse production at the right end of the left string. If E → E + (E) is a production, then E + ( E+(E)►) E + ( E ►)
![Page 43: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/43.jpg)
43
Shift-Reduce ExampleShift-Reduce ExampleShift-Reduce ExampleShift-Reduce Example
►int + (int) + (int) $
shift
int ► + (int) + (int) $
reduce E → int
E ► + (int) + (int) $
shift 3 times
E + (int ►) + (int) $
reduce E → int
E + (E ►) + (int) $ shift
E + (E) ► + (int) $ reduce E → E+(E)
![Page 44: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/44.jpg)
44
Shift-Reduce ExampleShift-Reduce ExampleShift-Reduce ExampleShift-Reduce Example
►int + (int) + (int) $
shift
int ► + (int) + (int) $
reduce E → int
E ► + (int) + (int) $
shift 3 times
E + (int ►) + (int) $
reduce E → int
E + (E ►) + (int) $ shift
E + (E) ► + (int) $ reduce E → E+(E)
![Page 45: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/45.jpg)
45
Shift-Reduce ExampleShift-Reduce ExampleShift-Reduce ExampleShift-Reduce Example
►int + (int) + (int) $
shift
int ► + (int) + (int) $
reduce E → int
E ► + (int) + (int) $
shift 3 times
E + (int ►) + (int) $
reduce E → int
E + (E ►) + (int) $ shift
E + (E) ► + (int) $ reduce E → E+(E)
![Page 46: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/46.jpg)
46
Shift-Reduce ExampleShift-Reduce ExampleShift-Reduce ExampleShift-Reduce Example
►int + (int) + (int) $
shift
int ► + (int) + (int) $
reduce E → int
E ► + (int) + (int) $
shift 3 times
E + (int ►) + (int) $
reduce E → int
E + (E ►) + (int) $ shift
E + (E) ► + (int) $ reduce E → E+(E)
![Page 47: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/47.jpg)
47
Shift-Reduce ExampleShift-Reduce ExampleShift-Reduce ExampleShift-Reduce Example
►int + (int) + (int) $
shift
int ► + (int) + (int) $
reduce E → int
E ► + (int) + (int) $
shift 3 times
E + (int ►) + (int) $
reduce E → int
E + (E ►) + (int) $ shift
E + (E) ► + (int) $ reduce E → E+(E)
![Page 48: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/48.jpg)
48
Shift-Reduce ExampleShift-Reduce ExampleShift-Reduce ExampleShift-Reduce Example
►int + (int) + (int) $
shift
int ► + (int) + (int) $
reduce E → int
E ► + (int) + (int) $
shift 3 times
E + (int ►) + (int) $
reduce E → int
E + (E ►) + (int) $ shift
E + (E) ► + (int) $ reduce E → E+(E)
![Page 49: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/49.jpg)
49
Shift-Reduce ExampleShift-Reduce ExampleShift-Reduce ExampleShift-Reduce Example
►int + (int) + (int) $
shift
int ► + (int) + (int) $
reduce E → int
E ► + (int) + (int) $
shift 3 times
E + (int ►) + (int) $
reduce E → int
E + (E ►) + (int) $ shift
E + (E) ► + (int) $ reduce E → E+(E)
![Page 50: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/50.jpg)
50
Shift-Reduce ExampleShift-Reduce ExampleShift-Reduce ExampleShift-Reduce Example
►int + (int) + (int) $
shift
int ► + (int) + (int) $
reduce E → int
E ► + (int) + (int) $
shift 3 times
E + (int ►) + (int) $
reduce E → int
E + (E ►) + (int) $ shift
E + (E) ► + (int) $ reduce E → E+(E)
![Page 51: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/51.jpg)
51
Shift-Reduce ExampleShift-Reduce ExampleShift-Reduce ExampleShift-Reduce Example
►int + (int) + (int) $
shift
int ► + (int) + (int) $
reduce E → int
E ► + (int) + (int) $
shift 3 times
E + (int ►) + (int) $
reduce E → int
E + (E ►) + (int) $ shift
E + (E) ► + (int) $ reduce E → E+(E)
![Page 52: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/52.jpg)
52
Shift-Reduce ExampleShift-Reduce ExampleShift-Reduce ExampleShift-Reduce Example
►int + (int) + (int) $
shift
int ► + (int) + (int) $
reduce E → int
E ► + (int) + (int) $
shift 3 times
E + (int ►) + (int) $
reduce E → int
E + (E ►) + (int) $ shift
E + (E) ► + (int) $ reduce E → E+(E)
![Page 53: Bottom Up Parsing - Compiler Design - Dr. D. P. Sharma - NIT Surathkal by wahid311](https://reader035.vdocuments.mx/reader035/viewer/2022081507/551756a14979593d228b4922/html5/thumbnails/53.jpg)
53
Shift-Reduce ExampleShift-Reduce ExampleShift-Reduce ExampleShift-Reduce Example
E ► + (int) $ shift 3 times
E + (int ►) $ reduce E → int
E + (E ►) $ shift
E + (E) ► $ red E → E+(E)E ► $ accept