Repository navigation
Preserve the failure position of described parsers - #91
Closed
Aschenbath wants to merge 1 commit into
Closed
Aschenbath wants to merge 1 commit into
Aschenbath wants to merge 1 commit into
Conversation
Member
|
This PR doesn't address the issues raised in my last comment in #77 Consider this (master branch): >>> import parsy as P
>>> a_and_b = P.string('a') + P.string('b')
>>> a_and_b.parse('a')
...
parsy.ParseError: expected 'b' at 0:1
>>> a_and_b.desc('a and b').parse('a')
parsy.ParseError: expected 'a and b' at 0:0With the PR you instead get: which is incorrect, 'a and b' is not expected at 0:1, only 'b' is. In terms of quality I'm closing this immediately as slop https://lukeplant.me.uk/blog/posts/why-im-calling-your-contribution-slop/ |
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.
Calling
.desc()on a combined parser reset a failed parse's position to the start of that parser. For example,(string('a') >> string('b')).desc('a pair').parse('ax')reported column 0 even though parsing failed at column 1.Preserve the underlying result's furthest failure position while replacing its expected text with the supplied description, as discussed in #77. Successful results retain their existing values and backtracking information. Add regressions for alternatives, generators, nonzero offsets, bytes and token lists, plus documentation and a release note.
Fixes #77.
Validation:
docs/_staticwarning. Wheel and source distribution build; direct wheel-import checks pass.Prepared with AI assistance; validation was run locally on Windows.