The synchronization set is implemented for the predictive parsing table. These symbols must be used to implement error recovery during the predictive parsing procedure.
/*
* ERROR RECOVERY METHOD:
*
* An effective error recovery strategy is a crucial aspect of compiler design, with the parser playing a key role in handling errors.
* The goal is to recover from errors as quickly as possible, allowing parsing to continue and detect additional errors.
* This implementation follows a basic panic-mode recovery approach.
*
* In panic-mode recovery, when an error is encountered, the parser discards input symbols one at a time
* until a designated synchronizing token is found, enabling parsing to resume in a meaningful state.
*
* This implementation considers three cases of error handling:
*
* I. If X is a terminal and does not match the next input token:
* X is popped from the stack and discarded.
*
* II. If X is a non-terminal and M[X, a] is marked as a synchronization token:
* The parser recovers by popping X from the stack and discarding it.
*
* III. If X is a non-terminal and M[X, a] is an error entry:
* The parser skips input tokens until a token in FOLLOW(X) or the endmarker $ is reached.
*/
Context
The synchronization set is implemented for the predictive parsing table. These symbols must be used to implement error recovery during the predictive parsing procedure.
Use Case
Proposed Solution
Alternative Solutions