Add Lark.scan() for finding grammar matches in text, and parsing them.#1592
Open
erezsh wants to merge 3 commits into
Open
Add Lark.scan() for finding grammar matches in text, and parsing them.#1592erezsh wants to merge 3 commits into
erezsh wants to merge 3 commits into
Conversation
…uce__ Both methods only copied start_pos/line/column, silently dropping the end positions.
It finds and parses each non-overlapping match, yielding the longest possible match. Reimplementation of the long-standing #1429 PR on top of the merged TextSlice support, with some modifications.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1592 +/- ##
==========================================
+ Coverage 90.06% 90.27% +0.21%
==========================================
Files 52 53 +1
Lines 8089 8297 +208
==========================================
+ Hits 7285 7490 +205
- Misses 804 807 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
MegaIng
approved these changes
May 10, 2026
Member
MegaIng
left a comment
There was a problem hiding this comment.
Looks very good, thank you for taking over this implementation, sorry for never getting around to it.
I genuinely don't have any detailed comments that aren't unrelated nits, this is very clean.
Member
Author
|
No worries, thanks for looking it over! |
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.
It finds and parses each non-overlapping match, yielding the longest possible match.
Reimplementation of the long-standing #1429 PR by @MegaIng on top of the merged TextSlice support, with some modifications.
Works in 2 steps. First parses without callbacks, for cheap cloning. Then finally replays the chosen match with user callbacks.