Parser Syntax Error Recovery via Tuple-Based Token Adjustment
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing parsing technologies face challenges in recovering from syntax errors while preserving the parse tree structure, often resulting in incomplete or incorrect recovery, especially in cases of nesting errors where errors are detected far from the original point, leading to difficulties in identifying function and block boundaries.
Innovation Solution
The proposed solution involves using tuples with a head, middle, and synchronization point to evaluate indentation characteristics and generate or delete tokens, allowing for automatic error recovery by examining unmatched states and adjusting the token stream to maintain parse tree integrity, with optional user intervention through a graphical interface.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If traditional parsing technologies are used to process program text, then the parser can identify syntax errors, but the recovery from errors is incomplete and the parse tree structure is not preserved
Solution Approach 1:
The patent segments the error recovery process into distinct phases: error detection, error recovery decision-making, and parse tree reconstruction. By dividing the recovery process into manageable segments, the system can preserve parse tree structure while handling errors systematically. The parser is divided into a lexical analyzer, parser, and error recovery module that work independently but coordinate through defined interfaces.
Solution Approach 2:
The patent implements preliminary action by pre-defining error recovery rules and strategies before parsing occurs. The system prepares recovery actions in advance based on grammar rules and context, allowing the parser to recover from errors without compromising the overall parse tree structure. This includes pre-establishing rules for handling missing tokens, extra tokens, and malformed constructs.
2Productivity
If the parser continues processing after detecting a syntax error, then additional errors can be uncovered and useful information can be extracted, but subsequent correct tokens are interpreted as false errors
Solution Approach 1:
The patent implements feedback mechanisms where the error recovery module continuously monitors parsing progress and adjusts its behavior based on feedback from the parser. When the parser encounters tokens that suggest the error has been recovered from, the system uses this feedback to switch between error recovery mode and normal parsing mode, preventing false error interpretations while maintaining the ability to detect additional errors.
Solution Approach 2:
The parsing system dynamically switches between different operational modes: normal parsing mode for error-free input and error recovery mode when syntax errors are detected. This dynamic adaptation allows the system to optimize its behavior based on the current parsing context, improving both error detection capability and accuracy by adjusting parameters such as error tolerance thresholds and recovery strategies in real-time.
3Measurement precision
If the parser reports errors at the point where they are detected, then the error location is accurate, but the error may be far from the original point of mistake in nesting errors
Solution Approach 1:
The patent introduces an intermediary error tracking mechanism that maintains a mapping between detected error positions and the original error locations. This intermediary layer translates the precise but potentially misleading error positions into user-friendly locations that correspond to the actual programming mistakes. The system uses this intermediary to bridge the gap between accurate error detection and ease of operation by presenting errors at their logical locations rather than just their syntactic positions.
Data Source
AI summary
The described embodiments present techniques for recovering from syntax errors. These techniques correct potential errors while preserving the shape of the parse tree, and the specific implementation of the techniques can be automatically generated from the grammar. These techniques may operate by looking back at states associated with previously-received tokens to determine pair matching status, when a synchronizing symbol is received. The techniques can respond to the pair matching status determination by potentially adding a synthesized token or by deleting a token that has already been received. The techniques may use a structure referred to herein as a tuple to assist with the evaluation of the pair matching status. Some of the techniques utilize indentation information to evaluate the pair matching status, while other techniques ignore such information. The described embodiments also include a technique for automatically generating the tuples from a set of grammar rules associated with the parser.


