Skip to main content

Module interpreter

Module interpreter 

Source
Expand description

The interpreter: Interscript::Interpreter::Stage parity. A backtracking item matcher (the Ruby runtime’s regex semantics without compiling to regex — Rust’s regex crate has no lookaround, which the constraint semantics require) plus the stage executor over parallel groups, sequential sub rules, run rules and funcalls.

Semantics contract (from interpreter.rb / stdlib.rb):

  • before -> lookbehind (?<=…)
  • not_before -> (?<!…)
  • after -> lookahead (?=…)
  • not_after -> (?!…)
  • an EMPTY constraint item behaves like the empty regex in that position: positive constraints become no-ops, negative ones disable the rule (Ruby (?<=) always true / (?<!) never true).
  • parallel groups: single left-to-right pass. Ruby’s two paths are both mirrored (they disagree on duplicate from keys): the tree path (parallel_replace_tree, constraint-free groups) is a last-wins char trie with longest-match scanning; the megaregexp fallback tries rules in deterministic_sort_by_max_length order (-max_length*100000+idx), first match wins.
  • replacement to items collapse through nth_string (Any -> first string) before building, exactly like build_item.

Structs§

Runtime
A loaded-map cache bound to a load path. Interscript.transliterate parity: transliterate(map_id, string) runs stage main.

Functions§

execute_stage_pub
Public alias for diagnostics and tests.