Repository navigation
Move X10 into the X rules section and split it into per-definition helpers - #17
Merged
Merged
Conversation
It implements rule X10 and is called once right after phase X, so it now sits after apply_explicit_levels. The Helpers section, which held only this function, is removed.
_find_level_runs (BD7), _find_matching_pdi (BD9) and _compute_sos_eos (X10) replace the inline loops and nested functions, leaving only the BD13 chaining loop. The next run is now the one that starts with the matching PDI, as BD13 words it; behaviour is unchanged.
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
Move:
get_isolating_run_sequencesimplements rule X10 and is called once, right after phase X. It now sits at the end of the X rules section instead of in a separate Helpers section, so the file reads in the order the algorithm runs (P → X1–X9 → X10 → W → N → I → L). The Helpers section held only this function and is removed.Split: the function was about 140 lines. Its parts are now private helpers, each named after the definition it implements:
_find_level_runs(BD7): level runs, skipping characters removed by X9_find_matching_pdi(BD9): the matching PDI of an isolate initiator_compute_sos_eos(X10): sos and eos, replacing the nestedlevel_before/level_afterfunctionsget_isolating_run_sequenceskeeps only the BD13 chaining loop.The next run in a sequence is now found as the run that starts with the matching PDI (BD13's wording), not the run that contains it. The two give the same result, because an isolate initiator ends a level run only when its isolate has content at a higher level, so the matching PDI always starts a new run.
CLAUDE.md now names the three new helpers.
There are no behaviour or output changes, so the README doesn't need updating.
Test plan
python tests/run_bidi_tests.py: 91707 passed, 0 failedpython tests/run_bidi_type_tests.py: 770241 passed, 0 failedpython bidi.py --allruns without errors