Skip to content

Move X10 into the X rules section and split it into per-definition helpers - #17

Merged
isaranga merged 2 commits into
mainfrom
move-x10-into-x-rules
Nov 27, 2026
Merged

isaranga merged 2 commits into
mainfrom
move-x10-into-x-rules

Conversation

@isaranga

Copy link
Copy Markdown
Owner

Summary

  • Move: get_isolating_run_sequences implements 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 nested level_before/level_after functions

    get_isolating_run_sequences keeps 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 failed
  • python tests/run_bidi_type_tests.py: 770241 passed, 0 failed
  • python bidi.py --all runs without errors

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.
@isaranga
isaranga merged commit d60002d into main Nov 27, 2026
6 checks passed
@isaranga
isaranga deleted the move-x10-into-x-rules branch November 27, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant