Skip to content

feat: to-position case functions and same-map stage runs - #6

Merged
ronaldtse merged 2 commits into
mainfrom
feat/case-functions-and-stage-runs
Sep 29, 2026
Merged

ronaldtse merged 2 commits into
mainfrom
feat/case-functions-and-stage-runs

Conversation

@ronaldtse

Copy link
Copy Markdown
Contributor

What

Three ISC constructs the converter rejected, all needed by the Ruby runtime's DSL vocabulary (and present in corpus maps):

  1. sub { from X to upcase } — the replacement is the match itself passed through the casing function. The converter emits subst ops with a case field; the engine applies _CASE_FNS (upcase/downcase/title_case/swapcase/strip/reverse) to the matched text.
  2. run stage.X (same-map named runs) — inlined at conversion time: the referenced stage's converted rules splice into the calling stage, so each converted stage is self-contained (the engine keeps its flat rule list). Chained runs (one → two → three) follow transitively; cycles raise a clear cyclic run stage.X error.
  3. run stage.X where X belongs to an imported (alias-less) dependency — resolves to a run op over the imported map, matching import semantics that merge its stages into scope.

Why now

interscript-ruby's Compiler::Python bridge is being reworked to serialize in-memory documents to ISC and execute them through this runtime (the old bridge wrote generated .py modules — a contract this runtime no longer has). The dsl_stage/reversibility vocabulary needs these constructs.

Tests

  • to-position case → subst.case op
  • chained same-map runs inline in run order
  • cyclic runs raise
  • imported-stage runs resolve to the dependency target
  • existing suite: 22 passed / 1 xpassed (with INTERSCRIPT_MAPS_PATH), no regressions

The ISC corpus and the Ruby runtime express two constructs the
converter rejected:

- sub { from X to upcase } — the replacement is the match itself passed
  through the casing function. The converter now emits subst ops with a
  case field; the engine applies _CASE_FNS to the matched text
  (upcase/downcase/title_case/swapcase/strip/reverse).
- run stage.X — same-map named runs now inline the referenced stage's
  converted rules at conversion time (chained runs follow; cycles raise
  a clear error). Stage names survive conversion as a result.
- run stage.X where X belongs to an imported (alias-less) dependency
  resolves to a run op over the imported map.

Also unblocks the Ruby compiler bridge: interscript-ruby serializes
in-memory documents to ISC and executes them through this runtime.
The Ruby bridge regenerates synthetic documents under reused names;
without eviction the stale engine keeps serving the old document.
@ronaldtse
ronaldtse merged commit f5e4bbd into main Sep 29, 2026
6 checks passed
@ronaldtse
ronaldtse deleted the feat/case-functions-and-stage-runs branch September 29, 2026 07:47
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