|
| 1 | +# 00 — ISC runtime integration: bridge ISC document → Interscript::Node |
| 2 | + |
| 3 | +## Priority: P0 (blocks .isc adoption) |
| 4 | + |
| 5 | +## Problem |
| 6 | +The ISC parser produces a document hash (`{metadata:, tests:, stages:, aliases:}`), |
| 7 | +but the existing `Interscript.transliterate()` only accepts: |
| 8 | +1. `.imp` files (parsed via Ruby DSL `instance_exec`) |
| 9 | +2. System codes resolved through `Interscript::Path` |
| 10 | + |
| 11 | +There is **no bridge** from ISC document hash to `Interscript::Node::Document`. |
| 12 | +Until this exists, `.isc` files cannot be used for actual transliteration. |
| 13 | + |
| 14 | +## Solution |
| 15 | + |
| 16 | +### 1. Create `Interscript::Isc::NodeAdapter` |
| 17 | +``` |
| 18 | +lib/interscript/isc/node_adapter.rb |
| 19 | +``` |
| 20 | +```ruby |
| 21 | +module Interscript::Isc |
| 22 | + class NodeAdapter |
| 23 | + def self.to_interscript_node(isc_doc) |
| 24 | + Interscript::Node::Document.new.tap do |doc| |
| 25 | + doc.metadata = build_metadata(isc_doc[:metadata]) |
| 26 | + doc.tests = build_tests(isc_doc[:tests]) |
| 27 | + isc_doc[:stages].each { |s| doc.stages[s[:name]] = build_stage(s) } |
| 28 | + isc_doc[:aliases].each { |a| doc.aliases[a[:name]] = build_alias(a) } |
| 29 | + end |
| 30 | + end |
| 31 | + end |
| 32 | +end |
| 33 | +``` |
| 34 | + |
| 35 | +### 2. Update `Interscript::Path` to resolve `.isc` files |
| 36 | +```ruby |
| 37 | +# In Interscript::Path.find_map |
| 38 | +[".isc", ".imp"].each do |ext| |
| 39 | + path = "#{dir}/#{name}#{ext}" |
| 40 | + return path if File.exist?(path) |
| 41 | +end |
| 42 | +``` |
| 43 | + |
| 44 | +### 3. Update `Interscript.load_map` to dispatch by extension |
| 45 | +```ruby |
| 46 | +def self.parse_map(path) |
| 47 | + return Isc.load_file(path) if path.end_with?(".isc") |
| 48 | + DSL.parse(File.basename(path, ".imp")) # legacy |
| 49 | +end |
| 50 | +``` |
| 51 | + |
| 52 | +## Verification |
| 53 | +```ruby |
| 54 | +# Both should produce identical output: |
| 55 | +Interscript.transliterate("alalc-amh-Ethi-Latn-1997", "ሀለ") # .imp |
| 56 | +Interscript.transliterate("alalc-amh-Ethi-Latn-1997", "ሀለ") # .isc (if .isc exists) |
| 57 | +``` |
| 58 | + |
| 59 | +## Autoload Registration |
| 60 | +Add to `lib/interscript/isc.rb`: |
| 61 | +```ruby |
| 62 | +autoload :NodeAdapter, "interscript/isc/node_adapter" |
| 63 | +``` |
0 commit comments