Skip to content

Name the directional status stack fields and extract X-phase helpers - #18

Merged
isaranga merged 3 commits into
mainfrom
refactor-explicit-levels-helpers
Nov 29, 2026
Merged

isaranga merged 3 commits into
mainfrom
refactor-explicit-levels-helpers

Conversation

@isaranga

Copy link
Copy Markdown
Owner

Tidies apply_explicit_levels (rules X1–X9) without changing behaviour or output.

Changes

  • DirectionalStatus named tuple (level, override, isolate) for directional status stack entries, replacing positional tuples such as stack[-1][2].
  • _apply_override(ci, override) replaces the override step that was repeated in the RLI, LRI, FSI, PDI and X6 branches.
  • _apply_x9(chars) holds the X9 pass that runs after the X2–X8 loop.
  • is_valid names the push test repeated in X2–X5c, using the spec's term ("this RLE is valid").
  • X6 comment explains why X6 is the final else (it is the only rule defined by exclusion) and that BN also reaches it, which is harmless because X9 resets BN afterwards.
  • CLAUDE.md explains why X2–X8 stay as one loop with one branch per rule instead of separate per-rule functions.

Testing

  • tests/run_bidi_tests.py: 91707 / 91707 passed
  • tests/run_bidi_type_tests.py: 770241 / 770241 passed

- Add DirectionalStatus (level, override, isolate) for stack entries,
  replacing positional tuples such as stack[-1][2].
- Extract _apply_override for the override step repeated in X5a-X6a.
- Extract _apply_x9 for the separate X9 pass after the X2-X8 loop.
- Document in CLAUDE.md why X2-X8 stay as one loop.
@isaranga
isaranga merged commit 3b6f880 into main Nov 29, 2026
6 checks passed
@isaranga
isaranga deleted the refactor-explicit-levels-helpers branch November 29, 2026 08:34
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