| 1 |
When tt(parse) encounters a em(syntax error), it calls the error reporting |
| 2 |
member function (tt(error)) to print an error message. A very basic in-line |
| 3 |
implementation is provided by b() in the parser class internal header file |
| 4 |
(see chapter ref(INTERFACE)), which can easily be redefined by the |
| 5 |
programmer. The tt(error) member's default implementation is OK for |
| 6 |
tt(rpn). |
| 7 |
|
| 8 |
Once tt(error) returns, b()'s parser may recover from the error and continue |
| 9 |
parsing if the grammar contains a suitable error rule (see chapter |
| 10 |
ref(RECOVERY)). Otherwise, the parsing function tt(parse) returns a non-zero |
| 11 |
value. No error production rules were used for tt(rpn), so the calculator |
| 12 |
terminates at the first syntax error.. Not very nice in a real-life |
| 13 |
calculator, but it is acceptable for this first example. |
| 14 |
|
| 15 |
|