Question: In C++, Python or Java: Implement the table driven parsing algorithm of FCS section 11.7 constructing parse trees of the grammar of simple programming statements
In C++, Python or Java: Implement the table driven parsing algorithm of FCS section 11.7 constructing parse trees of the grammar of simple programming statements (FCS figure 11.33). Your algorithm should make use of a stack as explained in FCS figure 11.34. After constructing a parse tree your algorithm should compute its height and list all labels in pre-order and post-order. Demonstrate with examples that your code operates properly.
| [\epsilon]
(1) ? w c
(2) ? {
(3) ? s ;
(4)
(5)
Fig. 11.33. Grammar for simple statements, parsable by recursive descent - ABOVE
FCS 11.34 - Below
| Stack | LookAhead | Remaining Input | |
| 1 | { | wcs;s;}ENDM | |
| 2 | { | { | wcs;s;}ENDM |
| 3 | w | cs;s;}ENDM | |
| 4 | w | cs;s;}ENDM | |
| 5 | wc | w | cs;s;}ENDM |
| 6 | c | c | s;s;}ENDM |
| 7 | s | ;s;}ENDM | |
| 8 | s; | s | ;s;}ENDM |
| 9 | ; | ; | s;}ENDM |
| 10 | s | ;}ENDM | |
| 11 | s | ;}ENDM | |
| 12 | s; | s | ;}ENDM |
| 13 | ; | ; | }ENDM |
| 14 | } | ENDM | |
| 15 | } | } | ENDM |
| 16 | ![]() | ENDM |
|
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts


