Add parser error tokens#47
Merged
Merged
Conversation
- Introduced `error` helper function in `ast_test_helpers.ml` to create error expressions. - Enhanced parser tests in `test_parser.ml` to check for missing expressions in `if` statements and `match` constructs, ensuring proper error diagnostics. - Updated existing tests to validate the parser's behavior when encountering incomplete expressions.
773e275 to
82bfa11
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces robust support for parse error reporting in the AST and parser. It adds new
EErrorandPErrornodes to the core AST, updates the parser to generate these nodes for common syntax errors, and ensures all downstream consumers (pretty-printer, equality, language service, and transformations) handle these cases gracefully. This will improve error messages and IDE integration for incomplete or incorrect code.AST Extensions for Error Handling
EErrorandPErrorconstructors to the core AST types inast_core.mlto represent expressions and patterns with parse errors, and updated all relevant pattern-matching code to handle these new cases. [1] [2] [3]Parser Improvements
parser.mly) to generateEErrornodes for missing expressions inlet,if-then-else, andmatchconstructs, and for missing match case bodies, providing more precise syntax error localization. [1] [2] [3]Pretty-Printing and Equality
ast_pp.ml) to display parse errors in red and the equality module (ast_eq.ml) to compare error nodes by their messages, ensuring errors are visible and comparable. [1] [2] [3] [4] [5]Language Service and Analysis
language_service.ml) to support the new error nodes in all relevant traversals, including hover text, completions, symbol analysis, and semantic tokens, so that tools and IDE features gracefully handle and report parse errors. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15]Transformation Passes
anf.ml) to treatEErroras a simple value, ensuring error nodes are preserved through normalization.These changes together provide end-to-end support for parse error recovery and reporting, making the language tooling more robust and user-friendly.