@@ -60,11 +60,11 @@ def compile_rule(r, map = @map, wrapper = false)
6060 # Try to build a tree
6161 a = [ ]
6262 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
6868
6969 next if i . reverse_run == true
7070 a << [ compile_item ( i . from , map , :par ) , compile_item ( i . to , map , :parstr ) ]
@@ -79,7 +79,7 @@ def compile_rule(r, map = @map, wrapper = false)
7979 # Otherwise let's build a megaregexp
8080 a = [ ]
8181 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
8383
8484 next if i . reverse_run == true
8585 a << [ build_regexp ( i , map ) , compile_item ( i . to , map , :parstr ) ]
@@ -112,7 +112,7 @@ def compile_rule(r, map = @map, wrapper = false)
112112 end
113113 c += "s = Interscript::Maps.transliterate(#{ stage . doc_name . inspect } , s, #{ stage . name . inspect } )\n "
114114 else
115- raise ArgumentError , "Can't compile unhandled #{ r . class } "
115+ raise Interscript :: SystemConversionError , "Can't compile unhandled #{ r . class } "
116116 end
117117 c
118118 end
@@ -146,17 +146,17 @@ def compile_item i, doc=@map, target=nil
146146 astr = if i . map
147147 d = doc . dep_aliases [ i . map ] . document
148148 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
150150 "Interscript::Maps.get_alias_ALIASTYPE(#{ a . doc_name . inspect } , #{ a . name . inspect } )"
151151 elsif Interscript ::Stdlib ::ALIASES . include? ( i . name )
152152 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"
154154 end
155155 stdlib_alias = true
156156 "Interscript::Stdlib::ALIASES[#{ i . name . inspect } ]"
157157 else
158158 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
160160
161161 "Interscript::Maps.get_alias_ALIASTYPE(#{ a . doc_name . inspect } , #{ a . name . inspect } )"
162162 end
@@ -194,7 +194,7 @@ def compile_item i, doc=@map, target=nil
194194 end
195195 when Interscript ::Node ::Item ::CaptureGroup
196196 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"
198198 end
199199 "(" + compile_item ( i . data , doc , target ) + ")"
200200 when Interscript ::Node ::Item ::Maybe ,
@@ -206,7 +206,7 @@ def compile_item i, doc=@map, target=nil
206206 Interscript ::Node ::Item ::MaybeSome => "*" } [ i . class ]
207207
208208 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"
210210 end
211211 if Interscript ::Node ::Item ::String === i . data && i . data . data . length != 1
212212 "(?:" + compile_item ( i . data , doc , target ) + ")" + resuffix
@@ -215,15 +215,15 @@ def compile_item i, doc=@map, target=nil
215215 end
216216 when Interscript ::Node ::Item ::CaptureRef
217217 if target == :par
218- raise ArgumentError , "Can't use CaptureRef in parallel mode"
218+ raise Interscript :: SystemConversionError , "Can't use CaptureRef in parallel mode"
219219 elsif target == :re
220220 "\\ #{ i . id } "
221221 elsif target == :str
222222 "\" \\ \\ #{ i . id } \" "
223223 end
224224 when Interscript ::Node ::Item ::Any
225225 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!
227227 elsif target == :par
228228 i . data . map ( &:data )
229229 elsif target == :re
0 commit comments