feat(decode): implement optimized dual-path parser with enhanced error reporting per #10#54
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #54 +/- ##
===========================================
- Coverage 95.90% 95.42% -0.49%
===========================================
Files 18 18
Lines 1026 1071 +45
===========================================
+ Hits 984 1022 +38
- Misses 42 49 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Description
Overview
This PR implements positioned error reporting with line and column numbers.
It provides human-readable diagnostic messages for common syntax and validation
errors (e.g., trailing commas, duplicate/missing values, and missing separators) without introducing any performance overhead on successful parsing paths.
Key Improvements
pcallloop overhead.lpeg.Cp()), wrapping the token state machine in apcallto format precise line and column location info."Expected value after ':'","Expected key before ':'", and trailing comma disallowance reasons).erroras a local upvalue to maintain strict compliance with sandbox environments (_ENV = nil).get_invalid_character_infowhere line numbers were 0-indexed, and resolved a regex limitation that prevented matching single-character lines.trailingCommaandallowEmptyElement(wherein a trailing comma is treated as a trailing empty element ifallowEmptyElementis enabled).Performance Comparison
Using the baseline test matrix benchmark (
tests/dataTest.luadecoding a 500-key object 1,000 times on Lua 5.4):develop):0.470s0.666s(~41% overhead)0.481s(~2% overhead / within run-to-run noise)Testing & Validation
tests/lunit-error-reporting.luaasserting exact line/column positions across 15 failure conditions.