interscript 2.4.2 → 2.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 982178c34f4b37c42c2e3375b9d1fc2f9b77c2f9df57724b3a9759c83246a859
4
- data.tar.gz: 190f08e085ea3783c49766973bf574c186133335989b207f92f9b40890551d28
3
+ metadata.gz: c7f937aac91160169f007353c245aa689ed3c5e3e4ed946c6da44f399ea733b1
4
+ data.tar.gz: 4c67b41ff52d4927793d772660d12b0c42c6548703a4c96f426ec1c26b54b9b7
5
5
  SHA512:
6
- metadata.gz: 82dc3abf972d7d694afe34bc5c9b424cd74db29158fd9d75c53068bacd383e634d3285d4e6679fc9e4ec592c784dae11af8b7644a389f02e890c7e4f771d18f5
7
- data.tar.gz: e4931a3bc891988449fecb6ce35e4c321f796bfd4da093ca375d795a1a2e3e00f185271f48bba8958a6250b06c70da5d0ac48487e56d910cefa54ec671796365
6
+ metadata.gz: 68c4890831dc4481c1c5152dc4781a061b214cebfee877d69876a972d43ee77616b533f6462db4d662e2fd032a93693d6afde443dd429096bead01f1238f35b8
7
+ data.tar.gz: ab9df5bc388a6882c0be9f83e3170944995f0104f593d0ff6a46360b6860bde1e0fa003f7db92531b837ebcfe56860e5635442f559d9c388f1997ea23b0fd14e
@@ -18,13 +18,13 @@ jobs:
18
18
  os: [ ubuntu-latest, windows-latest, macos-latest ]
19
19
  experimental: [ false ]
20
20
  include:
21
- - ruby: 3.0
21
+ - ruby: "3.0"
22
22
  os: 'ubuntu-latest'
23
23
  experimental: true
24
- - ruby: 3.0
24
+ - ruby: "3.0"
25
25
  os: 'windows-latest'
26
26
  experimental: true
27
- - ruby: 3.0
27
+ - ruby: "3.0"
28
28
  os: 'macos-latest'
29
29
  experimental: true
30
30
 
@@ -1,6 +1,7 @@
1
1
  require 'thor'
2
2
  require 'interscript'
3
3
  require 'json'
4
+
4
5
  module Interscript
5
6
  # Command line interface
6
7
  class Command < Thor
@@ -24,5 +25,46 @@ module Interscript
24
25
  puts path
25
26
  end
26
27
  end
28
+
29
+ desc 'stats', 'Prints statistics about the maps we have'
30
+ def stats
31
+ maps = Interscript.maps(load_path: true)
32
+ parsed_maps = maps.map { |i| [i, Interscript.parse(i)] }.to_h
33
+ maps_by_rule_count = parsed_maps.transform_values do |map|
34
+ map.stages.values.map { |i| i.children.map { |j| j.is_a?(Interscript::Node::Group) ? j.children : j } }.flatten.count
35
+ end
36
+
37
+ authorities, languages, source_scripts, target_scripts = 4.times.map do |i|
38
+ maps.group_by { |map| map.split('-')[i] }
39
+ end
40
+
41
+ puts <<~END
42
+ Languages supported: #{languages.keys.count}
43
+ Source scripts supported: #{source_scripts.keys.count}
44
+ Target scripts supported: #{target_scripts.keys.count}
45
+ Authorities supported: #{authorities.keys.count}
46
+ Total number of rules in Interscript: #{maps_by_rule_count.values.sum}
47
+
48
+ END
49
+
50
+ authorities.each do |auth, auth_maps|
51
+ rule_counts = auth_maps.map { |i| maps_by_rule_count[i] }
52
+ puts <<~END
53
+ Authority #{auth}:
54
+ * Conversion systems: #{auth_maps.count}
55
+ * Total number of rules: #{rule_counts.sum}
56
+
57
+ END
58
+ end
59
+
60
+ puts <<~END
61
+ Interesting facts:
62
+ * #{maps_by_rule_count.max_by { |i| i.last }.first} has the most rules
63
+ * Authority #{authorities.max_by { |i| i.last.count }.first} has the most systems
64
+ * Language #{languages.max_by { |i| i.last.count }.first} has the most systems
65
+ * Source script #{source_scripts.max_by { |i| i.last.count }.first} has the most systems
66
+ * Target script #{target_scripts.max_by { |i| i.last.count }.first} has the most systems
67
+ END
68
+ end
27
69
  end
28
70
  end
@@ -70,11 +70,11 @@ class Interscript::Compiler::Javascript < Interscript::Compiler
70
70
  # Try to build a tree
71
71
  a = []
72
72
  r.children.each do |i|
73
- raise ArgumentError, "Can't parallelize #{i.class}" unless Interscript::Node::Rule::Sub === i
74
- raise ArgumentError, "Can't parallelize rules with :before" if i.before
75
- raise ArgumentError, "Can't parallelize rules with :after" if i.after
76
- raise ArgumentError, "Can't parallelize rules with :not_before" if i.not_before
77
- raise ArgumentError, "Can't parallelize rules with :not_after" if i.not_after
73
+ raise Interscript::SystemConversionError, "Can't parallelize #{i.class}" unless Interscript::Node::Rule::Sub === i
74
+ raise Interscript::SystemConversionError, "Can't parallelize rules with :before" if i.before
75
+ raise Interscript::SystemConversionError, "Can't parallelize rules with :after" if i.after
76
+ raise Interscript::SystemConversionError, "Can't parallelize rules with :not_before" if i.not_before
77
+ raise Interscript::SystemConversionError, "Can't parallelize rules with :not_after" if i.not_after
78
78
 
79
79
  next if i.reverse_run == true
80
80
  a << [compile_item(i.from, map, :par), compile_item(i.to, map, :parstr)]
@@ -89,7 +89,7 @@ class Interscript::Compiler::Javascript < Interscript::Compiler
89
89
  # Otherwise let's build a megaregexp
90
90
  a = []
91
91
  Interscript::Stdlib.deterministic_sort_by_max_length(r.children).each do |i|
92
- raise ArgumentError, "Can't parallelize #{i.class}" unless Interscript::Node::Rule::Sub === i
92
+ raise Interscript::SystemConversionError, "Can't parallelize #{i.class}" unless Interscript::Node::Rule::Sub === i
93
93
 
94
94
  next if i.reverse_run == true
95
95
  a << [build_regexp(i, map), compile_item(i.to, map, :parstr)]
@@ -122,7 +122,7 @@ class Interscript::Compiler::Javascript < Interscript::Compiler
122
122
  end
123
123
  c += "s = Interscript.transliterate(#{stage.doc_name.to_json}, s, #{stage.name.to_json});\n"
124
124
  else
125
- raise ArgumentError, "Can't compile unhandled #{r.class}"
125
+ raise Interscript::SystemConversionError, "Can't compile unhandled #{r.class}"
126
126
  end
127
127
  c
128
128
  end
@@ -157,17 +157,17 @@ class Interscript::Compiler::Javascript < Interscript::Compiler
157
157
  astr = if i.map
158
158
  d = doc.dep_aliases[i.map].document
159
159
  a = d.imported_aliases[i.name]
160
- raise ArgumentError, "Alias #{i.name} of #{i.stage.map} not found" unless a
160
+ raise Interscript::SystemConversionError, "Alias #{i.name} of #{i.stage.map} not found" unless a
161
161
  "Interscript.get_alias_ALIASTYPE(#{a.doc_name.to_json}, #{a.name.to_json})"
162
162
  elsif Interscript::Stdlib::ALIASES.include?(i.name)
163
163
  if target != :re && Interscript::Stdlib.re_only_alias?(i.name)
164
- raise ArgumentError, "Can't use #{i.name} in a #{target} context"
164
+ raise Interscript::SystemConversionError, "Can't use #{i.name} in a #{target} context"
165
165
  end
166
166
  stdlib_alias = true
167
167
  "Interscript.aliases.#{i.name}"
168
168
  else
169
169
  a = doc.imported_aliases[i.name]
170
- raise ArgumentError, "Alias #{i.name} not found" unless a
170
+ raise Interscript::SystemConversionError, "Alias #{i.name} not found" unless a
171
171
 
172
172
  "Interscript.get_alias_ALIASTYPE(#{a.doc_name.to_json}, #{a.name.to_json})"
173
173
  end
@@ -205,7 +205,7 @@ class Interscript::Compiler::Javascript < Interscript::Compiler
205
205
  end
206
206
  when Interscript::Node::Item::CaptureGroup
207
207
  if target != :re
208
- raise ArgumentError, "Can't use a CaptureGroup in a #{target} context"
208
+ raise Interscript::SystemConversionError, "Can't use a CaptureGroup in a #{target} context"
209
209
  end
210
210
  "(" + compile_item(i.data, doc, target) + ")"
211
211
  when Interscript::Node::Item::Maybe,
@@ -217,7 +217,7 @@ class Interscript::Compiler::Javascript < Interscript::Compiler
217
217
  Interscript::Node::Item::MaybeSome => "*" }[i.class]
218
218
 
219
219
  if target == :par
220
- raise ArgumentError, "Can't use a MaybeSome in a #{target} context"
220
+ raise Interscript::SystemConversionError, "Can't use a MaybeSome in a #{target} context"
221
221
  end
222
222
  if Interscript::Node::Item::String === i.data && i.data.data.length != 1
223
223
  "(?:" + compile_item(i.data, doc, target) + ")" + resuffix
@@ -226,7 +226,7 @@ class Interscript::Compiler::Javascript < Interscript::Compiler
226
226
  end
227
227
  when Interscript::Node::Item::CaptureRef
228
228
  if target == :par
229
- raise ArgumentError, "Can't use CaptureRef in parallel mode"
229
+ raise Interscript::SystemConversionError, "Can't use CaptureRef in parallel mode"
230
230
  elsif target == :re
231
231
  "\\\\#{i.id}"
232
232
  elsif target == :str
@@ -234,7 +234,7 @@ class Interscript::Compiler::Javascript < Interscript::Compiler
234
234
  end
235
235
  when Interscript::Node::Item::Any
236
236
  if target == :str
237
- raise ArgumentError, "Can't use Any in a string context" # A linter could find this!
237
+ raise Interscript::SystemConversionError, "Can't use Any in a string context" # A linter could find this!
238
238
  elsif target == :par
239
239
  i.data.map(&:data)
240
240
  elsif target == :re
@@ -60,11 +60,11 @@ class Interscript::Compiler::Ruby < Interscript::Compiler
60
60
  # Try to build a tree
61
61
  a = []
62
62
  r.children.each do |i|
63
- raise ArgumentError, "Can't parallelize #{i.class}" unless Interscript::Node::Rule::Sub === i
64
- raise ArgumentError, "Can't parallelize rules with :before" if i.before
65
- raise ArgumentError, "Can't parallelize rules with :after" if i.after
66
- raise ArgumentError, "Can't parallelize rules with :not_before" if i.not_before
67
- raise ArgumentError, "Can't parallelize rules with :not_after" if i.not_after
63
+ raise Interscript::SystemConversionError, "Can't parallelize #{i.class}" unless Interscript::Node::Rule::Sub === i
64
+ raise Interscript::SystemConversionError, "Can't parallelize rules with :before" if i.before
65
+ raise Interscript::SystemConversionError, "Can't parallelize rules with :after" if i.after
66
+ raise Interscript::SystemConversionError, "Can't parallelize rules with :not_before" if i.not_before
67
+ raise Interscript::SystemConversionError, "Can't parallelize rules with :not_after" if i.not_after
68
68
 
69
69
  next if i.reverse_run == true
70
70
  a << [compile_item(i.from, map, :par), compile_item(i.to, map, :parstr)]
@@ -79,7 +79,7 @@ class Interscript::Compiler::Ruby < Interscript::Compiler
79
79
  # Otherwise let's build a megaregexp
80
80
  a = []
81
81
  Interscript::Stdlib.deterministic_sort_by_max_length(r.children).each do |i|
82
- raise ArgumentError, "Can't parallelize #{i.class}" unless Interscript::Node::Rule::Sub === i
82
+ raise Interscript::SystemConversionError, "Can't parallelize #{i.class}" unless Interscript::Node::Rule::Sub === i
83
83
 
84
84
  next if i.reverse_run == true
85
85
  a << [build_regexp(i, map), compile_item(i.to, map, :parstr)]
@@ -112,7 +112,7 @@ class Interscript::Compiler::Ruby < Interscript::Compiler
112
112
  end
113
113
  c += "s = Interscript::Maps.transliterate(#{stage.doc_name.inspect}, s, #{stage.name.inspect})\n"
114
114
  else
115
- raise ArgumentError, "Can't compile unhandled #{r.class}"
115
+ raise Interscript::SystemConversionError, "Can't compile unhandled #{r.class}"
116
116
  end
117
117
  c
118
118
  end
@@ -146,17 +146,17 @@ class Interscript::Compiler::Ruby < Interscript::Compiler
146
146
  astr = if i.map
147
147
  d = doc.dep_aliases[i.map].document
148
148
  a = d.imported_aliases[i.name]
149
- raise ArgumentError, "Alias #{i.name} of #{i.stage.map} not found" unless a
149
+ raise Interscript::SystemConversionError, "Alias #{i.name} of #{i.stage.map} not found" unless a
150
150
  "Interscript::Maps.get_alias_ALIASTYPE(#{a.doc_name.inspect}, #{a.name.inspect})"
151
151
  elsif Interscript::Stdlib::ALIASES.include?(i.name)
152
152
  if target != :re && Interscript::Stdlib.re_only_alias?(i.name)
153
- raise ArgumentError, "Can't use #{i.name} in a #{target} context"
153
+ raise Interscript::SystemConversionError, "Can't use #{i.name} in a #{target} context"
154
154
  end
155
155
  stdlib_alias = true
156
156
  "Interscript::Stdlib::ALIASES[#{i.name.inspect}]"
157
157
  else
158
158
  a = doc.imported_aliases[i.name]
159
- raise ArgumentError, "Alias #{i.name} not found" unless a
159
+ raise Interscript::SystemConversionError, "Alias #{i.name} not found" unless a
160
160
 
161
161
  "Interscript::Maps.get_alias_ALIASTYPE(#{a.doc_name.inspect}, #{a.name.inspect})"
162
162
  end
@@ -194,7 +194,7 @@ class Interscript::Compiler::Ruby < Interscript::Compiler
194
194
  end
195
195
  when Interscript::Node::Item::CaptureGroup
196
196
  if target != :re
197
- raise ArgumentError, "Can't use a CaptureGroup in a #{target} context"
197
+ raise Interscript::SystemConversionError, "Can't use a CaptureGroup in a #{target} context"
198
198
  end
199
199
  "(" + compile_item(i.data, doc, target) + ")"
200
200
  when Interscript::Node::Item::Maybe,
@@ -206,7 +206,7 @@ class Interscript::Compiler::Ruby < Interscript::Compiler
206
206
  Interscript::Node::Item::MaybeSome => "*" }[i.class]
207
207
 
208
208
  if target == :par
209
- raise ArgumentError, "Can't use a Maybe in a #{target} context"
209
+ raise Interscript::SystemConversionError, "Can't use a Maybe in a #{target} context"
210
210
  end
211
211
  if Interscript::Node::Item::String === i.data && i.data.data.length != 1
212
212
  "(?:" + compile_item(i.data, doc, target) + ")" + resuffix
@@ -215,7 +215,7 @@ class Interscript::Compiler::Ruby < Interscript::Compiler
215
215
  end
216
216
  when Interscript::Node::Item::CaptureRef
217
217
  if target == :par
218
- raise ArgumentError, "Can't use CaptureRef in parallel mode"
218
+ raise Interscript::SystemConversionError, "Can't use CaptureRef in parallel mode"
219
219
  elsif target == :re
220
220
  "\\#{i.id}"
221
221
  elsif target == :str
@@ -223,7 +223,7 @@ class Interscript::Compiler::Ruby < Interscript::Compiler
223
223
  end
224
224
  when Interscript::Node::Item::Any
225
225
  if target == :str
226
- raise ArgumentError, "Can't use Any in a string context" # A linter could find this!
226
+ raise Interscript::SystemConversionError, "Can't use Any in a string context" # A linter could find this!
227
227
  elsif target == :par
228
228
  i.data.map(&:data)
229
229
  elsif target == :re
@@ -14,7 +14,7 @@ class Interscript::DSL::Aliases
14
14
  end
15
15
 
16
16
  unless Symbol === name
17
- raise TypeError, "Alias name must be a Symbol, given #{name.class}"
17
+ raise Interscript::SystemConversionError, "Alias name must be a Symbol, given #{name.class}"
18
18
  end
19
19
 
20
20
  puts "def_alias(#{name.inspect}, #{thing.inspect})" if $DEBUG
@@ -10,7 +10,7 @@ class Interscript::DSL::Group
10
10
 
11
11
  def run(stage, **kwargs)
12
12
  if stage.class != Interscript::Node::Item::Stage
13
- raise TypeError, "I::Node::Item::Stage expected, got #{stage.class}"
13
+ raise Interscript::MapLogicError, "I::Node::Item::Stage expected, got #{stage.class}"
14
14
  end
15
15
  @node.children << Interscript::Node::Rule::Run.new(stage, **kwargs)
16
16
  end
@@ -55,7 +55,7 @@ module Interscript::DSL::Items
55
55
  class << self
56
56
  # Select a remote map
57
57
  def [] map
58
- Symbol === map or raise TypeError, "A map name must be a Symbol, not #{alias_name.class}"
58
+ Symbol === map or raise Interscript::MapLogicError, "A map name must be a Symbol, not #{alias_name.class}"
59
59
  Map.new(map)
60
60
  end
61
61
  alias method_missing []
@@ -68,7 +68,7 @@ module Interscript::DSL::Items
68
68
 
69
69
  # Implementation of `map.x.aliasname`
70
70
  def [] alias_name
71
- Symbol === alias_name or raise TypeError, "An alias name must be a Symbol, not #{alias_name.class}"
71
+ Symbol === alias_name or raise Interscript::MapLogicError, "An alias name must be a Symbol, not #{alias_name.class}"
72
72
  Interscript::Node::Item::Alias.new(alias_name, map: @name)
73
73
  end
74
74
  alias method_missing []
@@ -4,7 +4,7 @@ class Interscript::DSL::Metadata
4
4
  attr_accessor :node
5
5
 
6
6
  def initialize(yaml: false, map_name: "", library: true, &block)
7
- raise ArgumentError, "Can't evaluate metadata from Ruby context" unless yaml
7
+ raise Interscript::MapLogicError, "Can't evaluate metadata from Ruby context" unless yaml
8
8
  @map_name = map_name
9
9
  @node = Interscript::Node::MetaData.new
10
10
  self.instance_exec(&block)
@@ -67,7 +67,7 @@ module Interscript::DSL
67
67
  ruby << l
68
68
  end
69
69
  end
70
- raise ArgumentError, "metadata stage isn't terminated" if md_reading
70
+ raise Interscript::MapLogicError, "metadata stage isn't terminated" if md_reading
71
71
  ruby, yaml = ruby.join("\n"), yaml.join("\n")
72
72
 
73
73
  obj = Interscript::DSL::Document.new(map_name)
@@ -76,7 +76,7 @@ module Interscript::DSL
76
76
  yaml = if yaml =~ /\A\s*\z/
77
77
  {}
78
78
  else
79
- YAML.load(yaml, exc_fname)
79
+ YAML.load(yaml, filename: exc_fname)
80
80
  end
81
81
 
82
82
  md = Interscript::DSL::Metadata.new(yaml: true, map_name: map_name, library: library) do
@@ -92,11 +92,11 @@ class Interscript::Interpreter < Interscript::Compiler
92
92
  # Try to build a tree
93
93
  subs_array = []
94
94
  r.children.each do |i|
95
- raise ArgumentError, "Can't parallelize #{i.class}" unless Interscript::Node::Rule::Sub === i
96
- raise ArgumentError, "Can't parallelize rules with :before" if i.before
97
- raise ArgumentError, "Can't parallelize rules with :after" if i.after
98
- raise ArgumentError, "Can't parallelize rules with :not_before" if i.not_before
99
- raise ArgumentError, "Can't parallelize rules with :not_after" if i.not_after
95
+ raise Interscript::SystemConversionError, "Can't parallelize #{i.class}" unless Interscript::Node::Rule::Sub === i
96
+ raise Interscript::SystemConversionError, "Can't parallelize rules with :before" if i.before
97
+ raise Interscript::SystemConversionError, "Can't parallelize rules with :after" if i.after
98
+ raise Interscript::SystemConversionError, "Can't parallelize rules with :not_before" if i.not_before
99
+ raise Interscript::SystemConversionError, "Can't parallelize rules with :not_after" if i.not_after
100
100
  next if i.reverse_run == true
101
101
  subs_array << [build_item(i.from, :par), build_item(i.to, :parstr)]
102
102
  end
@@ -109,7 +109,7 @@ class Interscript::Interpreter < Interscript::Compiler
109
109
  # Otherwise let's build a megaregexp
110
110
  subs_array = []
111
111
  Interscript::Stdlib.deterministic_sort_by_max_length(r.children).each do |i| # rule.from.max_length gives somewhat better test results, why is that
112
- raise ArgumentError, "Can't parallelize #{i.class}" unless Interscript::Node::Rule::Sub === i
112
+ raise Interscript::SystemConversionError, "Can't parallelize #{i.class}" unless Interscript::Node::Rule::Sub === i
113
113
  next if i.reverse_run == true
114
114
  subs_array << [build_regexp(i), build_item(i.to, :parstr)]
115
115
  end
@@ -178,16 +178,16 @@ class Interscript::Interpreter < Interscript::Compiler
178
178
  if i.map
179
179
  d = doc.dep_aliases[i.map].document
180
180
  a = d.imported_aliases[i.name]
181
- raise ArgumentError, "Alias #{i.name} of #{i.stage.map} not found" unless a
181
+ raise Interscript::SystemConversionError, "Alias #{i.name} of #{i.stage.map} not found" unless a
182
182
  build_item(a.data, target, d)
183
183
  elsif Interscript::Stdlib::ALIASES.include?(i.name)
184
184
  if target != :re && Interscript::Stdlib.re_only_alias?(i.name)
185
- raise ArgumentError, "Can't use #{i.name} in a #{target} context"
185
+ raise Interscript::SystemConversionError, "Can't use #{i.name} in a #{target} context"
186
186
  end
187
187
  Interscript::Stdlib::ALIASES[i.name]
188
188
  else
189
189
  a = doc.imported_aliases[i.name]
190
- raise ArgumentError, "Alias #{i.name} not found" unless a
190
+ raise Interscript::SystemConversionError, "Alias #{i.name} not found" unless a
191
191
  build_item(a.data, target, doc)
192
192
  end
193
193
  when Interscript::Node::Item::String
@@ -208,7 +208,7 @@ class Interscript::Interpreter < Interscript::Compiler
208
208
  end
209
209
  when Interscript::Node::Item::CaptureGroup
210
210
  if target == :par
211
- raise ArgumentError, "Can't use a CaptureGroup in a #{target} context"
211
+ raise Interscript::SystemConversionError, "Can't use a CaptureGroup in a #{target} context"
212
212
  end
213
213
  "(" + build_item(i.data, target, doc) + ")"
214
214
  when Interscript::Node::Item::Maybe,
@@ -220,7 +220,7 @@ class Interscript::Interpreter < Interscript::Compiler
220
220
  Interscript::Node::Item::MaybeSome => "*" }[i.class]
221
221
 
222
222
  if target == :par
223
- raise ArgumentError, "Can't use a MaybeSome in a #{target} context"
223
+ raise Interscript::SystemConversionError, "Can't use a MaybeSome in a #{target} context"
224
224
  end
225
225
  if Interscript::Node::Item::String === i.data && i.data.data.length != 1
226
226
  "(?:" + build_item(i.data, target, doc) + ")" + resuffix
@@ -229,13 +229,13 @@ class Interscript::Interpreter < Interscript::Compiler
229
229
  end
230
230
  when Interscript::Node::Item::CaptureRef
231
231
  if target == :par
232
- raise ArgumentError, "Can't use CaptureRef in parallel mode"
232
+ raise Interscript::SystemConversionError, "Can't use CaptureRef in parallel mode"
233
233
  end
234
234
  "\\#{i.id}"
235
235
  when Interscript::Node::Item::Any
236
236
  if target == :str
237
237
  # We may never reach this point
238
- raise ArgumentError, "Can't use Any in a string context"
238
+ raise Interscript::SystemConversionError, "Can't use Any in a string context"
239
239
  elsif target == :par
240
240
  i.data.map(&:data)
241
241
  elsif target == :re
@@ -10,7 +10,7 @@ class Interscript::Node::Item::Any < Interscript::Node::Item
10
10
  self.value = Interscript::Stdlib::ALIASES[data.name]
11
11
  else
12
12
  puts data.inspect
13
- raise TypeError, "Wrong type #{data[0].class}, excepted Array, String or Range"
13
+ raise Interscript::MapLogicError, "Wrong type #{data[0].class}, excepted Array, String or Range"
14
14
  end
15
15
  end
16
16
 
@@ -48,7 +48,7 @@ class Interscript::Node::Item::Group < Interscript::Node::Item
48
48
  end
49
49
 
50
50
  if wrong
51
- raise TypeError, "An I::Node::Item::Group can't contain an #{wrong.class} item."
51
+ raise Interscript::MapLogicError, "An I::Node::Item::Group can't contain an #{wrong.class} item."
52
52
  end
53
53
  end
54
54
 
@@ -42,7 +42,7 @@ class Interscript::Node::Item < Interscript::Node
42
42
 
43
43
  def self.try_convert(i)
44
44
  i = Interscript::Node::Item::String.new(i) if i.class == ::String
45
- raise TypeError, "Wrong type #{i.class}, expected I::Node::Item" unless Interscript::Node::Item === i
45
+ raise Interscript::MapLogicError, "Wrong type #{i.class}, expected I::Node::Item" unless Interscript::Node::Item === i
46
46
  i
47
47
  end
48
48
  end
@@ -184,7 +184,7 @@ class Interscript::Node::Rule::Sub < Interscript::Node::Rule
184
184
  node
185
185
  else
186
186
  state[:right][node.id] = true
187
- state[:left][node.id - 1] or raise "Capture count doesn't match"
187
+ state[:left][node.id - 1] or raise Interscript::MapLogicError, "Capture count doesn't match"
188
188
  end
189
189
  when Interscript::Node::Item::CaptureGroup
190
190
  state[:left] << node
@@ -226,7 +226,7 @@ class Interscript::Stdlib
226
226
  def self.secryst(output, model:)
227
227
  require "secryst" rescue nil # Try to load secryst, but don't fail hard if not possible.
228
228
  unless defined? Secryst
229
- raise StandardError, "Secryst is not loaded. Please read docs/Usage_with_Secryst.adoc"
229
+ raise Interscript::ExternalUtilError, "Secryst is not loaded. Please read docs/Usage_with_Secryst.adoc"
230
230
  end
231
231
  Interscript.secryst_index_locations.each do |remote|
232
232
  Secryst::Provisioning.add_remote(remote)
@@ -240,7 +240,7 @@ class Interscript::Stdlib
240
240
  def self.rababa(output, config:)
241
241
  require "rababa" rescue nil # Try to load rababa, but don't fail hard if not possible.
242
242
  unless defined? Rababa
243
- raise StandardError, "Rababa is not loaded. Please read docs/Usage_with_Rababa.adoc"
243
+ raise Interscript::ExternalUtilError, "Rababa is not loaded. Please read docs/Usage_with_Rababa.adoc"
244
244
  end
245
245
 
246
246
  config_value = Interscript.rababa_configs[config]
@@ -1,3 +1,3 @@
1
1
  module Interscript
2
- VERSION = "2.4.2"
2
+ VERSION = "2.4.3"
3
3
  end
data/lib/interscript.rb CHANGED
@@ -2,7 +2,14 @@ require "interscript/version"
2
2
  require "yaml"
3
3
 
4
4
  module Interscript
5
+ # An error caused by a lack of some map
5
6
  class MapNotFoundError < StandardError; end
7
+ # An error caused by a missing dependency
8
+ class ExternalUtilError < StandardError; end
9
+ # An error caused by a particular compiler
10
+ class SystemConversionError < StandardError; end
11
+ # An error caused by an incorrect map implementation
12
+ class MapLogicError < StandardError; end
6
13
 
7
14
  class << self
8
15
  def load_path
@@ -121,8 +128,8 @@ module Interscript
121
128
  write_path = path unless write_path
122
129
  rescue
123
130
  end
124
-
125
- raise StandardError, "Can't find a writable path for Rababa. Consider setting a RABABA_DATA environment variable" unless write_path
131
+
132
+ raise ExternalUtilError, "Can't find a writable path for Rababa. Consider setting a RABABA_DATA environment variable" unless write_path
126
133
 
127
134
  model_path = "#{write_path}/model-#{model_name}.onnx"
128
135
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: interscript
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.2
4
+ version: 2.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.