Sums Sums + Products ← Sums Products ← Products Products * Value ← Products Value ← Value int ← Value id ← Shift(S) lookahead has a partial Grammar match, wait for more combo of lookahead and rightmost in parse stack has a partial Grammar match, wait for more Parse(P) no for lookahead, reduce rightmost symbol in stack (find largest match) Look Step Parse Stack Unscanned Parser Action Ahead 15 P Reduce = Sums” to id = Sums $ “id “Assign” Grammar String Assign = Sums id = id + id * int $ id ← Sums Sums + Products ← Sums Products ← Products Products * Value ← Products ← Value int ← Value id ← lookahead has a partial Grammar match, wait for more combo of lookahead and rightmost in parse stack has a partial Grammar match, wait for more Parse(P) no match for lookahead, reduce rightmost symbol in stack (find largest match) Look Step Parse Stack Unscanned Parser Action 16 ACCEPT Assign $ Grammar Input String Assign = Sums id = id + id * int $ id ← Sums Sums + Products ← Sums Products ← Products Products * Value ← Products Value ←
Sums ← Sums + Products Sums ← Products Products ← Products * Value Products ← Value Value ← int Value ← id Shift(S) lookahead has a partial Grammar match, wait for more combo of lookahead and rightmost in parse stack has a partial Grammar match, wait for more Parse(P) no for lookahead, reduce rightmost symbol in stack (find largest match) Step Parse Stack Look Ahead Unscanned Parser Action 15 id = Sums $ P Reduce “id = Sums” to “Assign” Grammar String Assign ← id = Sums Sums ← Sums + Products Sums ← Products Products ← Products * Value Products ← Value ← int Value ← id id = id + id * int $ lookahead has a partial Grammar match, wait for more combo of lookahead and rightmost in parse stack has a partial Grammar match, wait for more Parse(P) no match for lookahead, reduce rightmost symbol in stack (find largest match) Step Parse Stack Look Unscanned Parser Action 16 Assign $ ACCEPT Grammar Input String Assign ← id = Sums Sums ← Sums + Products Sums ← Products Products ← Products * Value Products ← Value id = id + id * int $
Parsing.docx