Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite...
-
Upload
savana-woodhams -
Category
Documents
-
view
226 -
download
0
Transcript of Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite...
![Page 1: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/1.jpg)
Pushdown Automata• Consists of
– Pushdown stack (can have terminals and nonterminals)
– Finite state automaton control
• Can do one of three actions (based on state and input):– Shift: Move current input from input onto stack
– Reduce:• If symbols on top of stack match right hand side of some grammar production NT
• Pop symbols () off of the stack• Push left hand side nonterminal (NT) onto stack
– Accept the input string
![Page 2: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/2.jpg)
Shift-Reduce Parser Example
* ( + num )numnum
Expr Expr Op Expr Expr (Expr)Expr - Expr
Expr numOp +Op -Op *
Stack
Tokenized Input String 5*(2+3)
![Page 3: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/3.jpg)
Shift-Reduce Parser Example
* ( + num )numnum
Expr Expr Op Expr Expr (Expr)Expr - Expr
Expr numOp +Op -Op *
Grammar Rules
![Page 4: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/4.jpg)
SHIFT
Shift-Reduce Parser Example
* ( + num )numnum
Expr Expr Op Expr Expr (Expr)Expr - Expr
Expr numOp +Op -Op *
![Page 5: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/5.jpg)
SHIFT
Shift-Reduce Parser Example
* ( + num )num
num
Expr Expr Op Expr Expr (Expr)Expr - Expr
Expr numOp +Op -Op *
![Page 6: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/6.jpg)
Shift-Reduce Parser Example
* ( + num )num
num
Expr Expr Op Expr Expr (Expr)Expr - Expr
Expr numOp +Op -Op *
REDUCE
![Page 7: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/7.jpg)
Shift-Reduce Parser Example
* ( + num )num
num
Expr Expr Op Expr Expr (Expr)Expr - Expr
Expr numOp +Op -Op *
REDUCE
Expr
![Page 8: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/8.jpg)
Shift-Reduce Parser Example
* ( + num )num
num
Expr Expr Op Expr Expr (Expr)Expr - Expr
Expr numOp +Op -Op *
Expr
SHIFT
![Page 9: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/9.jpg)
Shift-Reduce Parser Example
( + num )num
num
Expr Expr Op Expr Expr (Expr)Expr - Expr
Expr numOp +Op -Op *
Expr
SHIFT
*
![Page 10: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/10.jpg)
Shift-Reduce Parser Example
( + num )num
num
Expr Expr Op Expr Expr (Expr)Expr - Expr
Expr numOp +Op -Op *
Expr
Op
REDUCE
*
![Page 11: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/11.jpg)
Shift-Reduce Parser Example
( + num )num
num
Expr Expr Op Expr Expr (Expr)Expr - Expr
Expr numOp +Op -Op *
Expr
Op
*SHIFT
![Page 12: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/12.jpg)
Shift-Reduce Parser Example
+ num )num
num
Expr Expr Op Expr Expr (Expr)Expr - Expr
Expr numOp +Op -Op *
Expr
Op
*SHIFT
(
![Page 13: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/13.jpg)
Shift-Reduce Parser Example
+ num )num
num
Expr Expr Op Expr Expr (Expr)Expr - Expr
Expr numOp +Op -Op *
Expr
Op
*SHIFT
(
![Page 14: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/14.jpg)
Shift-Reduce Parser Example
+ num )
num
Expr Expr Op Expr Expr (Expr)Expr - Expr
Expr numOp +Op -Op *
Expr
Op
*SHIFT
(
num
![Page 15: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/15.jpg)
Shift-Reduce Parser Example
+ num )
num
Expr Expr Op Expr Expr (Expr)Expr - Expr
Expr numOp +Op -Op *
Expr
Op
*SHIFT
(
num
REDUCE
Expr
![Page 16: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/16.jpg)
Shift-Reduce Parser Example
+ num )
num
Expr Expr Op Expr Expr (Expr)Expr - Expr
Expr numOp +Op -Op *
Expr
Op
*SHIFT
(
num
Expr
![Page 17: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/17.jpg)
Shift-Reduce Parser Example
num )
num
Expr Expr Op Expr Expr (Expr)Expr - Expr
Expr numOp +Op -Op *
Expr
Op
*SHIFT
(
num
Expr
+
![Page 18: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/18.jpg)
Shift-Reduce Parser Example
num )
num
Expr Expr Op Expr Expr (Expr)Expr - Expr
Expr numOp +Op -Op *
Expr
Op
*SHIFT
(
num
Expr
Op
REDUCE
+
![Page 19: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/19.jpg)
Shift-Reduce Parser Example
num )
num
Expr Expr Op Expr Expr (Expr)Expr - Expr
Expr numOp +Op -Op *
Expr
Op
*SHIFT
(
num
Expr
Op
+
![Page 20: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/20.jpg)
Shift-Reduce Parser Example
)
num
Expr Expr Op Expr Expr (Expr)Expr - Expr
Expr numOp +Op -Op *
Expr
Op
*SHIFT
(
num
Expr
num
Op
+
![Page 21: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/21.jpg)
Shift-Reduce Parser Example
)
num
Expr Expr Op Expr Expr (Expr)Expr - Expr
Expr numOp +Op -Op *
Expr
Op
*SHIFT
(
num
Expr
Op
+
Expr
REDUCE
num
![Page 22: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/22.jpg)
Shift-Reduce Parser Example
)
num
Expr Expr Op Expr Expr (Expr)Expr - Expr
Expr numOp +Op -Op *
Expr
Op
*SHIFT
(
num +
REDUCE
num
Expr
Expr
Op
ExprExpr
![Page 23: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/23.jpg)
Shift-Reduce Parser Example
)
num
Expr Expr Op Expr Expr (Expr)Expr - Expr
Expr numOp +Op -Op *
Expr
Op
*SHIFT
(
num
Expr
Op
+
Expr
num
Expr
![Page 24: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/24.jpg)
Shift-Reduce Parser Example
num
Expr Expr Op Expr Expr (Expr)Expr - Expr
Expr numOp +Op -Op *
Expr
Op
*SHIFT
(
num
Expr
Op
+
Expr
num
Expr
)
![Page 25: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/25.jpg)
REDUCE
Shift-Reduce Parser Example
num
Expr Expr Op Expr Expr (Expr)Expr - Expr
Expr numOp +Op -Op *
Expr
Op
*
(
num
Expr
Op
+
Expr
num
Expr
)Expr
![Page 26: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/26.jpg)
REDUCE
Shift-Reduce Parser Example
num
Expr Expr Op Expr Expr (Expr)Expr - Expr
Expr numOp +Op -Op *Expr
Op
*
(
num
Expr
Op
+
Expr
num
Expr
)Expr
Expr
![Page 27: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/27.jpg)
ACCEPT!
Shift-Reduce Parser Example
num
Expr Expr Op Expr Expr (Expr)Expr - Expr
Expr numOp +Op -Op *Expr
Op
*
(
num
Expr
Op
+
Expr
num
Expr
)Expr
Expr
![Page 28: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/28.jpg)
*
num:5
num:2
+
num:3
Input String
5 * (2 + 3)
![Page 29: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/29.jpg)
Basic Idea
• Goal: reconstruct parse tree for input string
• Read input from left to right• Build tree in a bottom-up fashion
• Use stack to hold pending sequences of terminals and nonterminals
![Page 30: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/30.jpg)
Potential Conflicts
• Reduce/Reduce Conflict– Top of the stack may match RHS of multiple productions
– Which production to use in the reduction?
• Shift/Reduce Conflict– Stack may match RHS of production– But that may not be the right match– May need to shift an input and later find a different reduction
![Page 31: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/31.jpg)
Conflicts
Expr Expr Op ExprExpr (Expr)
Expr - ExprExpr numOp +Op - Op *
•Original GrammarExpr Expr Op ExprExpr Expr - ExprExpr (Expr)
Expr Expr - Expr numOp +Op - Op *
•New Grammar
![Page 32: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/32.jpg)
Conflicts
- numnum
Expr Expr Op ExprExpr Expr - Expr
Expr (Expr)Expr Expr -
Expr numOp +Op -Op *
![Page 33: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/33.jpg)
Conflicts
- numnum
SHIFT
Expr Expr Op ExprExpr Expr - Expr
Expr (Expr)Expr Expr -
Expr numOp +Op -Op *
![Page 34: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/34.jpg)
Conflicts
- num
SHIFT
num
Expr Expr Op ExprExpr Expr - Expr
Expr (Expr)Expr Expr -
Expr numOp +Op -Op *
![Page 35: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/35.jpg)
Conflicts
- num
SHIFT
Expr
REDUCE
num
Expr Expr Op ExprExpr Expr - Expr
Expr (Expr)Expr Expr -
Expr numOp +Op -Op *
![Page 36: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/36.jpg)
Conflicts
- num
SHIFT
Expr
num
Expr Expr Op ExprExpr Expr - Expr
Expr (Expr)Expr Expr -
Expr numOp +Op -Op *
![Page 37: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/37.jpg)
Conflicts
num
SHIFT
Expr
num
-
Expr Expr Op ExprExpr Expr - Expr
Expr (Expr)Expr Expr -
Expr numOp +Op -Op *
![Page 38: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/38.jpg)
Shift/Reduce/Reduce Conflict
num
Expr
num
-
Expr Expr Op ExprExpr Expr - Expr
Expr (Expr)Expr Expr -
Expr numOp +Op -Op *
Options:ShiftReduceReduce
![Page 39: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/39.jpg)
Shift/Reduce/Reduce Conflict
num
Expr
num
-
Expr Expr Op ExprExpr Expr - Expr
Expr (Expr)Expr Expr -
Expr numOp +Op -Op *
What Happens if Choose
Reduce
REDUCE
![Page 40: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/40.jpg)
Shift/Reduce/Reduce Conflict
num
Expr
num -
Expr Expr Op ExprExpr Expr - Expr
Expr (Expr)Expr Expr -
Expr numOp +Op -Op *
What Happens if Choose
Reduce
SHIFT
Expr
![Page 41: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/41.jpg)
Shift/Reduce/Reduce Conflict
Expr
num -
Expr Expr Op ExprExpr Expr - Expr
Expr (Expr)Expr Expr -
Expr numOp +Op -Op *
What Happens if Choose
Reduce
SHIFT
Expr
num
![Page 42: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/42.jpg)
Shift/Reduce/Reduce Conflict
Expr
num -
Expr Expr Op ExprExpr Expr - Expr
Expr (Expr)Expr Expr -
Expr numOp +Op -Op *
What Happens if Choose
Reduce
REDUCE
Expr
Expr
num
![Page 43: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/43.jpg)
Shift/Reduce/Reduce Conflict
Expr
num -
Expr Expr Op ExprExpr Expr - Expr
Expr (Expr)Expr Expr -
Expr numOp +Op -Op *
What Happens if Choose
Reduce
FAILS!
Expr
Expr
num
![Page 44: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/44.jpg)
Shift/Reduce/Reduce Conflict
num
Expr
num
-
Expr Expr Op ExprExpr Expr - Expr
Expr (Expr)Expr Expr -
Expr numOp +Op -Op *
Both of These Actions Work
ReduceShift
![Page 45: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/45.jpg)
Shift/Reduce/Reduce Conflict
num
Expr
num
-
Expr Expr Op ExprExpr Expr - Expr
Expr (Expr)Expr Expr -
Expr numOp +Op -Op *
What Happens if Choose
Reduce
![Page 46: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/46.jpg)
Shift/Reduce/Reduce Conflict
num
Expr
num
Op
Expr Expr Op ExprExpr Expr - Expr
Expr (Expr)Expr Expr -
Expr numOp +Op -Op *
What Happens if Choose
Reduce
-
REDUCE
![Page 47: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/47.jpg)
Shift/Reduce/Reduce Conflict
Expr
num
Op
Expr Expr Op ExprExpr Expr - Expr
Expr (Expr)Expr Expr -
Expr numOp +Op -Op *
What Happens if Choose
Reduce
-
SHIFT
num
![Page 48: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/48.jpg)
Shift/Reduce/Reduce Conflict
Expr
num
Op
Expr Expr Op ExprExpr Expr - Expr
Expr (Expr)Expr Expr -
Expr numOp +Op -Op *
What Happens if Choose
Reduce
-
REDUCE
Expr
num
![Page 49: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/49.jpg)
Shift/Reduce/Reduce Conflict
Expr
num
Op
Expr Expr Op ExprExpr Expr - Expr
Expr (Expr)Expr Expr -
Expr numOp +Op -Op *
What Happens if Choose
Reduce
-
REDUCE
Expr
num
Expr
![Page 50: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/50.jpg)
Shift/Reduce/Reduce Conflict
Expr
num
Op
Expr Expr Op ExprExpr Expr - Expr
Expr (Expr)Expr Expr -
Expr numOp +Op -Op *
What Happens if Choose
Reduce
-
ACCEPT
Expr
num
Expr
![Page 51: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/51.jpg)
num
Expr
num
-
Expr Expr Op ExprExpr Expr - Expr
Expr (Expr)Expr Expr -
Expr numOp +Op -Op *
SHIFT
Conflicts
What Happens if Choose
Shift
![Page 52: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/52.jpg)
Expr
num
-
Expr Expr Op ExprExpr Expr - Expr
Expr (Expr)Expr Expr -
Expr numOp +Op -Op *
SHIFT
num
Conflicts
What Happens if Choose
Shift
![Page 53: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/53.jpg)
Expr
num
-
Expr Expr Op ExprExpr Expr - Expr
Expr (Expr)Expr Expr -
Expr numOp +Op -Op *
REDUCE
Expr
Conflicts
num
What Happens if Choose
Shift
![Page 54: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/54.jpg)
Expr
num -
Expr Expr Op ExprExpr Expr - Expr
Expr (Expr)Expr Expr -
Expr numOp +Op -Op *
REDUCE
Expr
Conflicts
num
Expr
What Happens if Choose
Shift
![Page 55: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/55.jpg)
Expr
num -
Expr Expr Op ExprExpr Expr - Expr
Expr (Expr)Expr Expr -
Expr numOp +Op -Op *
ACCEPT
Expr
Conflicts
num
Expr
What Happens if Choose
Shift
![Page 56: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/56.jpg)
Shift/Reduce/Reduce Conflict
num
Expr
num
-
Expr Expr Op ExprExpr Expr - Expr
Expr (Expr)Expr Expr -
Expr numOp +Op -Op *
This Shift/Reduce Conflict Reflects Ambiguity in Grammar
![Page 57: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/57.jpg)
Shift/Reduce/Reduce Conflict
num
Expr
num
-
Expr Expr Op ExprExpr Expr - Expr
Expr (Expr)Expr Expr -
Expr numOp +Op -Op *
This Shift/Reduce Conflict Reflects Ambiguity in Grammar
Eliminate by HackingGrammar
![Page 58: Pushdown Automata Consists of –Pushdown stack (can have terminals and nonterminals) –Finite state automaton control Can do one of three actions (based.](https://reader036.fdocuments.net/reader036/viewer/2022062301/56649c8a5503460f94943610/html5/thumbnails/58.jpg)
Shift/Reduce/Reduce Conflict
num
Expr
num
-
Expr Expr Op ExprExpr Expr - Expr
Expr (Expr)Expr Expr -
Expr numOp +Op -Op *
This Shift/Reduce Conflict Can Be Eliminated By Lookahead of One Symbol
Parser Generator Should Handle It