interscript 3.3.0 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,31 @@
1
+ class Interscript::Node::Rule::Use < Interscript::Node::Rule
2
+ # ISC-WF-1 W1/W2: a `use` directive before expansion. The NodeAdapter
3
+ # expands use directives at build time (macro expansion, spec §3.2), so
4
+ # this node only appears on documents built without expansion; it names
5
+ # the ruleset and, when present, the dependency alias and the per-site
6
+ # override rows.
7
+ attr_accessor :ruleset, :map, :overrides
8
+
9
+ def initialize(ruleset, map: nil, overrides: [])
10
+ self.ruleset = ruleset
11
+ self.map = map
12
+ self.overrides = overrides
13
+ end
14
+
15
+ def to_hash
16
+ {class: self.class.to_s,
17
+ ruleset: ruleset,
18
+ map: map,
19
+ overrides: overrides.map(&:to_hash)}
20
+ end
21
+
22
+ def ==(other)
23
+ super && ruleset == other.ruleset && map == other.map && overrides == other.overrides
24
+ end
25
+
26
+ def inspect
27
+ out = "use #{[map, ruleset].compact.map { |i| "@#{i}" }.join(".")}"
28
+ out += " override { #{overrides.map(&:inspect).join(", ")} }" unless overrides.empty?
29
+ out
30
+ end
31
+ end
@@ -3,6 +3,7 @@ class Interscript::Node::Rule < Interscript::Node
3
3
  autoload :Sub, "interscript/node/rule/sub"
4
4
  autoload :Run, "interscript/node/rule/run"
5
5
  autoload :Funcall, "interscript/node/rule/funcall"
6
+ autoload :Use, "interscript/node/rule/use"
6
7
 
7
8
  def ==(other)
8
9
  super && reverse_run == other.reverse_run
@@ -0,0 +1,6 @@
1
+ class Interscript::Node::Ruleset < Interscript::Node::Stage
2
+ # ISC-WF-1 W1: a named, reusable block of stage items. Lives on
3
+ # Node::Document#rulesets, never in #stages — a ruleset never executes
4
+ # on its own; it only reaches the runtime through `use` expansion
5
+ # (a macro expansion performed at adapter time).
6
+ end
@@ -8,6 +8,8 @@ class Interscript::Node
8
8
  autoload :Dependency, "interscript/node/dependency"
9
9
  autoload :Tests, "interscript/node/tests"
10
10
  autoload :Stage, "interscript/node/stage"
11
+ autoload :Ruleset, "interscript/node/ruleset"
12
+ autoload :LanguagesDecl, "interscript/node/languages_decl"
11
13
  autoload :Rule, "interscript/node/rule"
12
14
  autoload :Item, "interscript/node/item"
13
15
 
@@ -1,3 +1,3 @@
1
1
  module Interscript
2
- VERSION = "3.3.0"
2
+ VERSION = "3.5.0"
3
3
  end
data/lib/interscript.rb CHANGED
@@ -50,9 +50,22 @@ module Interscript
50
50
  end
51
51
 
52
52
  # Transliterates the string.
53
- def transliterate(system_code, string, maps = {}, compiler: Interscript::Interpreter)
53
+ #
54
+ # ISC-WF-1 W3: `language:` selects one of the map's declared
55
+ # `languages`, activating the matching `when`-guarded rules. A
56
+ # selection outside the declaration (or no selection) leaves every
57
+ # guard inert (spec §5.1).
58
+ def transliterate(system_code, string, maps = {}, compiler: Interscript::Interpreter, language: nil)
54
59
  # The current best implementation is Interpreter
55
- load(system_code, maps, compiler: compiler).call(string)
60
+ compiled = load(system_code, maps, compiler: compiler)
61
+ if language.nil?
62
+ compiled.call(string)
63
+ elsif compiler.equal?(Interscript::Interpreter)
64
+ compiled.call(string, language: language)
65
+ else
66
+ raise ArgumentError,
67
+ "language selection is only supported by Interscript::Interpreter, not #{compiler}"
68
+ end
56
69
  end
57
70
 
58
71
  # Gives each possible value of the transliteration.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: interscript
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-11-05 00:00:00.000000000 Z
11
+ date: 2026-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.5'
33
+ version: '3.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.5'
40
+ version: '3.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: text
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +150,7 @@ files:
150
150
  - lib/interscript/isc/model/document.rb
151
151
  - lib/interscript/isc/model/item.rb
152
152
  - lib/interscript/isc/model/rule.rb
153
+ - lib/interscript/isc/model/ruleset.rb
153
154
  - lib/interscript/isc/model/stage.rb
154
155
  - lib/interscript/isc/model/stage_item.rb
155
156
  - lib/interscript/isc/model/test.rb
@@ -182,11 +183,14 @@ files:
182
183
  - lib/interscript/node/item/repeat.rb
183
184
  - lib/interscript/node/item/stage.rb
184
185
  - lib/interscript/node/item/string.rb
186
+ - lib/interscript/node/languages_decl.rb
185
187
  - lib/interscript/node/metadata.rb
186
188
  - lib/interscript/node/rule.rb
187
189
  - lib/interscript/node/rule/funcall.rb
188
190
  - lib/interscript/node/rule/run.rb
189
191
  - lib/interscript/node/rule/sub.rb
192
+ - lib/interscript/node/rule/use.rb
193
+ - lib/interscript/node/ruleset.rb
190
194
  - lib/interscript/node/stage.rb
191
195
  - lib/interscript/node/tests.rb
192
196
  - lib/interscript/stdlib.rb