Skip to content

WO19 G6: portable grammar keyword/directive adoption + py subtree alignment - #858

Merged
ronaldtse merged 2 commits into
mainfrom
wo19-g6-ruby
Nov 14, 2026
Merged

ronaldtse merged 2 commits into
mainfrom
wo19-g6-ruby

Conversation

@ronaldtse

Copy link
Copy Markdown
Contributor

Summary

Two commits, one logical round (the WO19 G6 rulings):

1. Portable grammar (lib/interscript/isc/grammar/isc.parg)

  • Item 1: the six fn-literal names (upcase downcase title_case reverse strip swapcase) join the keyword rule. A bare fn name is never an alias reference; downcase = any(...) still declares an alias (alias_decl has no keyword guard). New sha 1695964…, pinned by the regenerated ts/py parsers.
  • Item 3: reverse/strip/swapcase join case_directive — all six fn names are stage directives in the artifact-parse grammar.

2. py subtree (interscript-py/)

  • Item 4: \UXXXX decodes in the action layer (gki-bel's sub "\U040E" "Ŭ" used to carry from-value "U040E"; the row never fired). Regression test pins the decoded Ў.
  • Item 3: reverse/strip/swapcase in BUILTIN_FUNCTIONS — ruby String semantics (strip = ruby's ASCII whitespace + NUL set, deliberately not python's Unicode-whitespace strip; swapcase = full Unicode mapping, "ß"→"SS" verified against ruby).
  • Item 2: a fn literal in FROM position raises MapLogicError at compile (was: misleading "Alias downcase not found"); any_character keeps its alias path (primitive spelled as a function atom — kp-kor's constraint rows exercise it).
  • Item 5: the outside-form block-rule when extension is retired (canonical rs binds inside the braces; ruby parses the inside form only), and the PEG gains span rollback — lookahead bodies and failing sequence/rep/alt branches drop the speculative from/to spans they recorded. Crash reproduced on the pre-round peg.py with the new grammar (ValueError: 2 unconsumed from/to spans); the span-rollback compile paths fix it.

Ruby runtime: no change needed (evidence)

  • Item 5 probe parallel { sub "k" "K" when kur / sub "k" "q" }: ruby KaK (kur-selected) / qaq (unselected) — identical to rs canonical. The audit's "ruby binds it inside" refers to parse placement, where ruby already rejects the outside form like rs.
  • Item 2: ruby already raises (MapLogicError: Wrong type Symbol, expected I::Node::Item).
  • Item 3: Stdlib::Functions has had the trio since G8 (the semantics reference).
  • Item 1: ruby's concern keyword table keeps downcase/upcase/title_case only — the ruling targets the two portable pargs; the concern layer's fn-literal production already carries all six as item literals.

Noted divergence (documented, in-scope per the ruling): the concern grammar still parses only downcase/upcase/title_case as stage directives, so ruby's own .isc parsing rejects a bare reverse/strip/swapcase directive line; the artifact-parse grammar (this .parg, consumed by ts/py/rs) accepts all six.

Gates

  • ruby: bundle exec rake spec (SKIP_JS=1 SKIP_PYTHON=1) — 431 examples, 0 failures, 11 pending
  • py: GOLDEN_ROOT=~/src/interscript pytest — 0 failures (8 skips: model zips absent, known IR-limitation maps)
  • py-vs-py driver (scripts/parse_parity_py.py --hand-rev 7a84260): canonical 432/435, raw 432/435 — the 3 holdouts are exactly the capital-\U maps (gki-bel, mvd-bel, odni-bel): the generated parser now decodes where the hand parser carried the literal digits; the hand side is the bug this round fixes
  • py golden capture test + cross-grammar harness (412/435, 3 known kinds): zero delta

The six fn-literal names (upcase/downcase/title_case/reverse/strip/swapcase) join the keyword rule: a bare fn name is never an alias reference or an alias(...) argument, while downcase = any(...) still declares an alias (alias_decl has no keyword guard). All six fn names are stage directives: reverse/strip/swapcase join case_directive with the plain String semantics of Stdlib::Functions as the reference. New .parg sha 169596431e066ec762b69ceb5a21383154e97ed7f3630888032e0b7122a1750e (the generated ts/py parsers pin it).
…s, span rollback

Item 4: both \uXXXX and \UXXXX escape spellings decode in the action layer (gki-bel's sub "\U040E" "Ŭ" used to carry the from-value "U040E" and the row never fired).

Item 1: the grammar_source sync carries the six-fn-name keyword table (sha 169596431e066ec762b69ceb5a21383154e97ed7f3630888032e0b7122a1750e).

Item 3: reverse/strip/swapcase join BUILTIN_FUNCTIONS - stage directives and inline to-funcalls execute with the plain String semantics of ruby Stdlib::Functions (strip uses ruby's ASCII whitespace + NUL set, not python's Unicode-whitespace strip).

Item 2: a fn literal in FROM position raises MapLogicError at compile (the former alias fallback said "Alias downcase not found"); any_character keeps its alias path.

Item 5: the outside-form block-rule when extension is retired from the parser (canonical rs binds the guard inside the braces; ruby parses the inside form only) - and the PEG gains span rollback so the inside-form block rule with a when guard parses without desyncing the from/to span walk: lookahead bodies and failing sequence/rep/alt branches now drop the speculative spans they recorded (the crash was reproducible with the new grammar on HEAD's peg.py: ValueError 2 unconsumed from/to spans).
@ronaldtse
ronaldtse merged commit 2aa521a into main Nov 14, 2026
13 checks passed
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