Answers to test yourself exercise 2 in Augmented Grammar handout
Here are the productions of an augmented right-to-left regular parser for Ln³. The start symbol is A[0].
- A0 ¬ a A1, where A0.COUNT := A1.COUNT - 1
- A ¬ a B, where A.COUNT := B.COUNT-1, B.NEWCOUNT = 0
- B0 ¬ b B1, where B0.COUNT := B1.COUNT, B0.NEWCOUNT := B1.NEWCOUNT - 1
- B ¬ b C, where B.COUNT := C.COUNT, B.NEWCOUNT := C.COUNT - 1
- C0 ¬ c C1, where C0.COUNT := C1.COUNT + 1
- C ¬ c, where C.COUNT := 1
Here are the productions of an augmented left-to-right regular parser for Ln³. The start symbol is C[0].
- C0 ¬ C1 c, where C0.COUNT := C1.COUNT - 1
- C ¬ B c, where C.COUNT := B.COUNT - 1, B.NEWCOUNT = 0
- B0 ¬ B1 b, where B0.COUNT := B1.COUNT, B0.NEWCOUNT := B1.NEWCOUNT - 1
- B ¬ A b, where B.COUNT := A.COUNT, B.NEWCOUNT := A.COUNT - 1
- A0 ¬ A1 a, where A0.COUNT := A1.COUNT + 1
- A ¬ a, where A.COUNT := 1