Operator Precedence Parsing
A + B * C
op | operand | input | action | why |
A + B * C | start | |||
A | + B * C | shift A | ||
+ | A | B * C | shift + | empty < + |
+ | A B | * C | shift B | |
+ * | A B | C | shift * | + < * |
+ * | A B C | shift C | ||
+ | A (* B C) | reduce | ||
(+ A (* B C)) | reduce | |||
A * B + C
op | operand | input | action | why |
A * B + C | start | |||
A | * B + C | shift A | ||
* | A | B + C | shift * | empty < * |
* | A B | + C | shift B | |
(* A B) | + C | reduce | * ≥ + | |
+ | (* A B) | C | shift + | empty < + |
+ | (* A B) C | shift C | ||
(+ (* A B) C) | reduce | |||