Repository navigation
feat: add support for 'a' (ASCII) and 'L' (LOCALE) regex flags - #1655
Closed
amansri-30 wants to merge 1 commit into
Closed
amansri-30 wants to merge 1 commit into
amansri-30 wants to merge 1 commit into
Conversation
Adds support for the 'a' and 'L' regex flags in Lark grammars, as requested in issue lark-parser#1527. - 'a' flag: Makes \w, \W, \b, \B, \d, \D, \s, \S perform ASCII-only matching instead of full Unicode matching - 'L' flag: Makes \w, \W, \b, \B locale dependent (only works with bytes patterns in Python 3) Changes: - Updated _RE_FLAGS in load_grammar.py to include 'a' and 'L' - Added test_flag_order_with_new_flags to verify 'a' flag works - Added test_token_flags_ascii to verify 'a' flag parses correctly
Member
|
low effort |
This was referenced Sep 20, 2026
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.
Summary
Adds support for the
a(ASCII) andL(LOCALE) regex flags in Lark grammars, as requested in issue #1527.Changes
_RE_FLAGSinload_grammar.pyto includeaandLtest_flag_order_with_new_flagsto verify theaflag works and is sorted deterministicallytest_token_flags_asciito verify theaflag parses correctlyDetails
aflag (ASCII): Makes\w,\W,\b,\B,\d,\D,\s,\Sperform ASCII-only matching instead of full Unicode matching. Works with both string and bytes patterns.Lflag (LOCALE): Makes\w,\W,\b,\Blocale dependent. Note: In Python 3, this flag can only be used with bytes patterns (whenuse_bytes=True).Testing
All existing tests pass, and new tests verify the flags work correctly:
Closes #1527