Expand description
Interscript::Node::*#reverse parity for the slice-1 subset:
reversed documents, stages, sub rules (with boundary-alias
transfer + capture/ref exchange), funcall inversion, and the
reverse_name convention.
Ground truth is interscript-ruby origin/main
(lib/interscript/node/*.rb); every rule here mirrors the Ruby
method named in its comment. The reversed document runs through
the NORMAL executor — the interpreter skips rules whose
reverse_run == Some(true), so the inversion lives entirely in
the produced document. Capture numbering is positional: refs stay
untouched numbers and groups re-number in regex order over the
reversed rule (assign_group_ids), reproducing Ruby’s
build_regexp numbering exactly.
Known deviations (all documented at the site): where the Ruby
reverse would crash (NoMethodError on repeat items in case-swap
subs, children= on a compacted-away from group, an upcase
funcall missing from reverse_function), this implementation
raises a clean Unsupported carrying the same information.
Functions§
- item_
downcase Item#downcase: String data downcases; Group/CaptureGroup recurse; Alias (incl. boundary prims) and refs/ranges are identity; Any rebuilds from per-char entries.- item_
upcase Item#upcase.- reverse_
document Interscript::Node::Document#reverse. Aliases are NOT reversed (rdoc.aliases = self.aliases); tests swap their pairs; dependency documents reverse recursively.- reverse_
name Interscript::Node::Document.reverse_name: split on-, swap positions 2/3 (source/target code) when there are at least 4 segments; otherwise strip a-reversesuffix, otherwise append one.- reverse_
stage Interscript::Node::Stage#reverse/Group#reverse: children in REVERSE order, each reversed, reverse_run toggled. (The ISC grammar cannot expressdont_reverse, so stages always reverse.)- reverse_
sub Interscript::Node::Rule::Sub#reverse.