flexr 1.0.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.
Files changed (161) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +33 -0
  3. data/CONTRIBUTING.md +39 -0
  4. data/LICENSE.txt +21 -0
  5. data/README.md +116 -0
  6. data/Rakefile +468 -0
  7. data/benchmark/baselines/json.json +34 -0
  8. data/benchmark/baselines/json_handwritten.rb +43 -0
  9. data/benchmark/baselines/json_rexical.rex +25 -0
  10. data/benchmark/corpora/README.md +11 -0
  11. data/benchmark/corpora/generate_json.rb +26 -0
  12. data/benchmark/golden/calculator_lexer.sha256 +1 -0
  13. data/benchmark/golden/json_lexer.sha256 +1 -0
  14. data/benchmark/golden/regexp_tokenizer.sha256 +1 -0
  15. data/benchmark/golden/ruby_subset_lexer.sha256 +1 -0
  16. data/benchmark/golden/toy_lang_lexer.sha256 +1 -0
  17. data/benchmark/golden/with_lrama_lexer.sha256 +1 -0
  18. data/benchmark/golden/with_racc_lexer.sha256 +1 -0
  19. data/benchmark/run.rb +254 -0
  20. data/docs/README.md +64 -0
  21. data/docs/RELEASING.md +30 -0
  22. data/docs/adr/0001-byte-level-dfa.md +5 -0
  23. data/docs/adr/0003-leftmost-longest.md +4 -0
  24. data/docs/adr/0006-accel-not-scanner.md +4 -0
  25. data/docs/adr/0008-what-pure-ruby-means.md +5 -0
  26. data/docs/adr/0016-spec-is-plain-ruby.md +4 -0
  27. data/docs/adr/0017-static-analysis-by-default.md +5 -0
  28. data/docs/adr/0018-prism-for-generator-only.md +4 -0
  29. data/docs/adr/0019-measured-performance-floor.md +26 -0
  30. data/docs/adr/0020-vendored-unicode-contract.md +21 -0
  31. data/docs/explanation/backends.md +33 -0
  32. data/docs/explanation/matching-semantics.md +20 -0
  33. data/docs/explanation/runtime-vs-generated.md +22 -0
  34. data/docs/explanation/security-model.md +18 -0
  35. data/docs/explanation/unicode-and-encoding.md +20 -0
  36. data/docs/how-to/deploy-a-standalone-lexer.md +23 -0
  37. data/docs/how-to/generate-a-lexer.md +39 -0
  38. data/docs/how-to/handle-errors.md +32 -0
  39. data/docs/how-to/integrate-with-lrama.md +21 -0
  40. data/docs/how-to/integrate-with-racc.md +25 -0
  41. data/docs/how-to/migrate-from-flex.md +21 -0
  42. data/docs/how-to/migrate-from-rexical.md +23 -0
  43. data/docs/how-to/run-a-lexer-at-runtime.md +29 -0
  44. data/docs/how-to/track-token-locations.md +27 -0
  45. data/docs/how-to/tune-performance.md +23 -0
  46. data/docs/how-to/use-states.md +36 -0
  47. data/docs/how-to/use-trailing-context.md +22 -0
  48. data/docs/internals/README.md +14 -0
  49. data/docs/perf-log.md +56 -0
  50. data/docs/reference/README.md +23 -0
  51. data/docs/reference/actions.md +47 -0
  52. data/docs/reference/cli.md +80 -0
  53. data/docs/reference/compatibility.md +38 -0
  54. data/docs/reference/diagnostics.md +41 -0
  55. data/docs/reference/dsl.md +81 -0
  56. data/docs/reference/errors.md +27 -0
  57. data/docs/reference/generated-artifacts.md +50 -0
  58. data/docs/reference/public-api.md +42 -0
  59. data/docs/reference/regexp.md +39 -0
  60. data/docs/reference/runtime.md +49 -0
  61. data/docs/reference/tokens-and-locations.md +33 -0
  62. data/docs/tutorial/build-a-calculator-lexer.md +96 -0
  63. data/examples/calculator/README.md +27 -0
  64. data/examples/calculator/lexer.flexr.rb +17 -0
  65. data/examples/json/README.md +30 -0
  66. data/examples/json/lexer.flexr.rb +24 -0
  67. data/examples/ruby_subset/README.md +17 -0
  68. data/examples/ruby_subset/lexer.flexr.rb +22 -0
  69. data/examples/toy_lang/README.md +17 -0
  70. data/examples/toy_lang/lexer.flexr.rb +18 -0
  71. data/examples/with_lrama/README.md +17 -0
  72. data/examples/with_lrama/lexer.flexr.rb +13 -0
  73. data/examples/with_racc/README.md +17 -0
  74. data/examples/with_racc/lexer.flexr.rb +13 -0
  75. data/exe/flexr +7 -0
  76. data/lib/flexr/automaton/accel.rb +39 -0
  77. data/lib/flexr/automaton/analysis.rb +38 -0
  78. data/lib/flexr/automaton/byte_class_set.rb +29 -0
  79. data/lib/flexr/automaton/compiler.rb +413 -0
  80. data/lib/flexr/automaton/dfa.rb +103 -0
  81. data/lib/flexr/automaton/minimizer.rb +70 -0
  82. data/lib/flexr/automaton/nfa.rb +92 -0
  83. data/lib/flexr/cli.rb +342 -0
  84. data/lib/flexr/codegen/base.rb +17 -0
  85. data/lib/flexr/codegen/direct.rb +52 -0
  86. data/lib/flexr/codegen/firstmatch.rb +17 -0
  87. data/lib/flexr/codegen/table.rb +158 -0
  88. data/lib/flexr/codegen/table_packer.rb +61 -0
  89. data/lib/flexr/diagnostics.rb +94 -0
  90. data/lib/flexr/dsl.rb +182 -0
  91. data/lib/flexr/errors.rb +28 -0
  92. data/lib/flexr/generated.rb +125 -0
  93. data/lib/flexr/generator.rb +400 -0
  94. data/lib/flexr/importer.rb +560 -0
  95. data/lib/flexr/ir.rb +36 -0
  96. data/lib/flexr/lexer.rb +10 -0
  97. data/lib/flexr/options.rb +47 -0
  98. data/lib/flexr/rake_task.rb +27 -0
  99. data/lib/flexr/regexp/ast.rb +45 -0
  100. data/lib/flexr/regexp/char_class.rb +7 -0
  101. data/lib/flexr/regexp/normalizer.rb +117 -0
  102. data/lib/flexr/regexp/parser.rb +517 -0
  103. data/lib/flexr/regexp/tokenizer.flexr.rb +27 -0
  104. data/lib/flexr/regexp/tokenizer.rb +168 -0
  105. data/lib/flexr/regexp/unsupported.rb +7 -0
  106. data/lib/flexr/runtime/buffer.rb +112 -0
  107. data/lib/flexr/runtime/core.rb +388 -0
  108. data/lib/flexr/runtime/errors.rb +22 -0
  109. data/lib/flexr/runtime/interpreter.rb +505 -0
  110. data/lib/flexr/runtime/location.rb +26 -0
  111. data/lib/flexr/runtime/token.rb +7 -0
  112. data/lib/flexr/source/passthrough.rb +31 -0
  113. data/lib/flexr/source/prism_reader.rb +283 -0
  114. data/lib/flexr/source/static_eval.rb +145 -0
  115. data/lib/flexr/unicode/case_fold.rb +45 -0
  116. data/lib/flexr/unicode/data/LICENSE-UNICODE.txt +5 -0
  117. data/lib/flexr/unicode/data/UNICODE_VERSION +1 -0
  118. data/lib/flexr/unicode/data/case_folding.rb +9 -0
  119. data/lib/flexr/unicode/data/properties.rb +10 -0
  120. data/lib/flexr/unicode/property.rb +107 -0
  121. data/lib/flexr/unicode/reference_regexp.rb +102 -0
  122. data/lib/flexr/unicode/utf8_splitter.rb +109 -0
  123. data/lib/flexr/version.rb +5 -0
  124. data/lib/flexr.rb +81 -0
  125. data/site/README.md +22 -0
  126. data/site/astro.config.mjs +57 -0
  127. data/site/package.json +19 -0
  128. data/site/pnpm-lock.yaml +5029 -0
  129. data/site/pnpm-workspace.yaml +6 -0
  130. data/site/public/playground.js +189 -0
  131. data/site/scripts/verify-site.mjs +42 -0
  132. data/site/src/content/docs/benchmarks.md +8 -0
  133. data/site/src/content/docs/concepts/matching-semantics.md +15 -0
  134. data/site/src/content/docs/concepts/regexp-model.md +18 -0
  135. data/site/src/content/docs/concepts/runtime-vs-generated.md +15 -0
  136. data/site/src/content/docs/concepts/security-model.md +15 -0
  137. data/site/src/content/docs/examples.md +17 -0
  138. data/site/src/content/docs/learn/generation.md +29 -0
  139. data/site/src/content/docs/learn/getting-started.md +56 -0
  140. data/site/src/content/docs/learn/parser-integration.md +27 -0
  141. data/site/src/content/docs/learn/runtime-mode.md +32 -0
  142. data/site/src/content/docs/reference/action-context.md +20 -0
  143. data/site/src/content/docs/reference/cli.md +22 -0
  144. data/site/src/content/docs/reference/diagnostics.md +16 -0
  145. data/site/src/content/docs/reference/dsl.md +19 -0
  146. data/site/src/content/docs/reference/public-api.md +18 -0
  147. data/site/src/content/docs/reference/regexp.md +16 -0
  148. data/site/src/content/docs/reference/runtime.md +16 -0
  149. data/site/src/content/docs/reference/tokens-and-locations.md +16 -0
  150. data/site/src/content.config.ts +12 -0
  151. data/site/src/env.d.ts +1 -0
  152. data/site/src/layouts/SiteLayout.astro +39 -0
  153. data/site/src/pages/index.astro +174 -0
  154. data/site/src/pages/playground.astro +64 -0
  155. data/site/src/styles/custom.css +711 -0
  156. data/site/tsconfig.json +5 -0
  157. data/tools/coverage.rb +32 -0
  158. data/tools/docs_verify.rb +116 -0
  159. data/tools/gen_unicode_tables.rb +202 -0
  160. data/tools/regexp_tokenizer_reference.rb +60 -0
  161. metadata +205 -0
@@ -0,0 +1,283 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Flexr
4
+ module Source
5
+ RuleDefinition = Struct.new(
6
+ :index, :patterns, :trailing, :action_source, :action, :states, :bol_only, :end_anchor,
7
+ :pattern_conditions,
8
+ :span, keyword_init: true
9
+ )
10
+ SpecSource = Struct.new(
11
+ :source, :path, :class_name, :rules, :config, :dsl_spans, :first_dsl_offset, :constants,
12
+ :states, keyword_init: true
13
+ )
14
+
15
+ class PrismReader
16
+ DSL_NAMES = %i[rule state all_states on_eof emits backend token_kind encoding option accel].freeze
17
+
18
+ def initialize(source, path: nil)
19
+ @source = source
20
+ @path = path
21
+ @constants = {}
22
+ @constant_definitions = {}
23
+ @rules = []
24
+ @spans = []
25
+ @states = { initial: { inclusive: true } }
26
+ @eof_rules = {}
27
+ @config = { backend: :table, token_kind: :array, encoding: Encoding::UTF_8, declared_tokens: [] }
28
+ end
29
+
30
+ def read(allow_dynamic: false)
31
+ @allow_dynamic = allow_dynamic
32
+ prism = begin
33
+ require "prism"
34
+ Prism.parse(@source)
35
+ rescue LoadError => e
36
+ diagnostic = Diagnostics.error("FLEXR-E019", "Prism is required for source generation", note: e.message)
37
+ raise CompileError.new(diagnostic.message, diagnostic: diagnostic)
38
+ end
39
+ unless prism.errors.empty?
40
+ error = prism.errors.first
41
+ diagnostic = Diagnostics.error("FLEXR-E010", error.message)
42
+ raise CompileError.new(diagnostic.message, diagnostic: diagnostic)
43
+ end
44
+
45
+ klass, class_name = find_lexer_class(prism.value)
46
+ raise CompileError, "no class inheriting from Flexr::Lexer found" unless klass
47
+
48
+ @lexer_scope = class_name.to_s.delete_prefix("::").split("::").reject(&:empty?)
49
+ collect_constants(prism.value)
50
+ resolve_constants
51
+ collect_body(klass.body, [:initial])
52
+ first_dsl_offset = @spans.map(&:first).min || class_body_offset(klass)
53
+ @config[:eof_rules] = @eof_rules
54
+ SpecSource.new(source: @source, path: @path, class_name: class_name, rules: @rules,
55
+ config: @config, dsl_spans: @spans.uniq(&:first),
56
+ first_dsl_offset: first_dsl_offset, constants: @constants, states: @states)
57
+ end
58
+
59
+ private
60
+
61
+ def find_lexer_class(node, namespace = [])
62
+ candidates = lexer_class_candidates(node, namespace)
63
+ candidates.find { |candidate, _name| lexer_has_dsl?(candidate.body) } || candidates.first
64
+ end
65
+
66
+ def lexer_class_candidates(node, namespace = [])
67
+ return [] unless node.respond_to?(:child_nodes)
68
+
69
+ kind = node.class.name.split("::").last
70
+ if %w[ClassNode ModuleNode].include?(kind)
71
+ name = source_slice(node.constant_path)
72
+ current_namespace = namespace + name.to_s.split("::")
73
+ own = if kind == "ClassNode" && lexer_superclass?(node)
74
+ [[node, current_namespace.join("::")]]
75
+ else
76
+ []
77
+ end
78
+ return own + node.child_nodes.compact.flat_map { |child| lexer_class_candidates(child, current_namespace) }
79
+ end
80
+
81
+ node.child_nodes.compact.flat_map { |child| lexer_class_candidates(child, namespace) }
82
+ end
83
+
84
+ def lexer_has_dsl?(node)
85
+ found = false
86
+ each_node(node) do |child|
87
+ found = true if child.class.name.end_with?("CallNode") && child.receiver.nil? && DSL_NAMES.include?(child.name.to_sym)
88
+ end
89
+ found
90
+ end
91
+
92
+ def lexer_superclass?(node)
93
+ return false unless node.superclass
94
+
95
+ source_slice(node.superclass).delete(" ").sub(/\A::/, "") == "Flexr::Lexer"
96
+ end
97
+
98
+ def collect_constants(node, scope: [])
99
+ return unless node
100
+
101
+ kind = node.class.name.split("::").last
102
+ if %w[ClassNode ModuleNode].include?(kind)
103
+ nested_scope = scope + namespace_parts(node.constant_path)
104
+ collect_constants(node.body, scope: nested_scope)
105
+ return
106
+ end
107
+
108
+ if kind.end_with?("ConstantWriteNode")
109
+ name = qualify_constant(scope, node.name)
110
+ @constant_definitions[name] = [node.value, scope.dup]
111
+ end
112
+
113
+ node.child_nodes.compact.each { |child| collect_constants(child, scope: scope) }
114
+ end
115
+
116
+ def resolve_constants
117
+ pending = @constant_definitions.dup
118
+
119
+ loop do
120
+ resolved = false
121
+ pending.each_key do |name|
122
+ value_node, scope = pending.fetch(name)
123
+ value = StaticEval.new(@source, constants: @constants, scope: scope).call(value_node)
124
+ @constants[name] = value
125
+ pending.delete(name)
126
+ resolved = true
127
+ rescue StaticResolutionError
128
+ # Keep unresolved definitions out of the table. If a DSL expression
129
+ # refers to one later, StaticEval emits the normal FLEXR-E017.
130
+ end
131
+ break unless resolved
132
+ end
133
+ end
134
+
135
+ def namespace_parts(node)
136
+ source_slice(node).delete_prefix("::").split("::").reject(&:empty?)
137
+ end
138
+
139
+ def qualify_constant(scope, name)
140
+ (scope + [name.to_s]).reject(&:empty?).join("::")
141
+ end
142
+
143
+ def collect_body(node, states)
144
+ body = node.respond_to?(:body) ? node.body : []
145
+ Array(body).each do |child|
146
+ collect_call(child, states)
147
+ end
148
+ end
149
+
150
+ def collect_call(node, states)
151
+ return unless node
152
+ return collect_body(node, states) if node.class.name.end_with?("StatementsNode")
153
+ return unless node.class.name.end_with?("CallNode")
154
+ return if node.receiver
155
+
156
+ name = node.name.to_sym
157
+ return unless DSL_NAMES.include?(name)
158
+ @spans << [node.location.start_offset, node.location.end_offset]
159
+ case name
160
+ when :rule
161
+ collect_rule(node, states)
162
+ when :state
163
+ collect_state(node, states)
164
+ when :all_states
165
+ collect_state(node, @states.keys)
166
+ when :on_eof
167
+ action_source = node.block && source_slice(node.block)
168
+ action = if action_source
169
+ action_source.start_with?("do") ? "proc #{action_source}" : "proc#{action_source}"
170
+ end
171
+ @eof_rules[states.last.to_sym] = action if action
172
+ when :emits
173
+ values = positional(node).map { |item| static(item) }.compact.flatten
174
+ @config[:declared_tokens].concat(values.map(&:to_sym))
175
+ when :backend
176
+ @config[:backend] = static(positional(node).first).to_sym
177
+ when :token_kind
178
+ @config[:token_kind] = static(positional(node).first).to_sym
179
+ when :encoding
180
+ @config[:encoding] = static(positional(node).first)
181
+ when :option
182
+ @config[:options] ||= {}
183
+ positional(node).each { |item| @config[:options][static(item).to_sym] = true }
184
+ when :accel
185
+ @config[:options] ||= {}
186
+ @config[:options][:accel] = static(positional(node).first).to_sym
187
+ end
188
+ end
189
+
190
+ def collect_state(node, parent_states)
191
+ args = positional(node)
192
+ names = args.map { |argument| static(argument, scope: @lexer_scope).to_sym }
193
+ names = parent_states if node.name.to_sym == :all_states
194
+ inclusive = keyword(node, :inclusive) ? static(keyword(node, :inclusive), scope: @lexer_scope) : false
195
+ names.each { |name| @states[name] = { inclusive: inclusive } }
196
+ block = node.block
197
+ collect_body(block&.body, names)
198
+ end
199
+
200
+ def collect_rule(node, states)
201
+ values = positional(node)
202
+ patterns = static(values.first, scope: @lexer_scope)
203
+ patterns = [patterns] unless patterns.is_a?(Array)
204
+ unless (@allow_dynamic && patterns.any?(&:nil?)) || patterns.all? { |pattern| pattern.is_a?(::Regexp) || pattern.is_a?(String) }
205
+ diagnostic = Diagnostics.error("FLEXR-E018", "rule pattern must be a Regexp, String, or Array")
206
+ raise CompileError.new(diagnostic.message, diagnostic: diagnostic)
207
+ end
208
+ options = keywords(node)
209
+ action_source = node.block && source_slice(node.block)
210
+ if action_source&.match?(/\breject\b/)
211
+ diagnostic = Diagnostics.error(
212
+ "FLEXR-E013", "reject is not supported by flexr",
213
+ help: "use a state transition and less(n) to express the fallback"
214
+ )
215
+ raise CompileError.new(diagnostic.message, diagnostic: diagnostic)
216
+ end
217
+ action = if action_source
218
+ action_source.start_with?("do") ? "proc #{action_source}" : "proc#{action_source}"
219
+ end
220
+ @rules << RuleDefinition.new(
221
+ index: @rules.length, patterns: patterns,
222
+ trailing: options[:followed_by] && static(options[:followed_by], scope: @lexer_scope),
223
+ action_source: action_source, action: action || action_for(options), states: states.dup,
224
+ bol_only: false, end_anchor: nil,
225
+ span: [node.location.start_offset, node.location.end_offset]
226
+ )
227
+ end
228
+
229
+ def action_for(options)
230
+ return :skip if options[:skip] && static(options[:skip])
231
+ return [:emit, static(options[:emit]).to_sym] if options[:emit]
232
+
233
+ "proc { emit(nil, text) }"
234
+ end
235
+
236
+ def static(node, scope: @lexer_scope)
237
+ StaticEval.new(@source, constants: @constants, scope: scope).call(node)
238
+ rescue StaticResolutionError
239
+ raise unless @allow_dynamic
240
+
241
+ nil
242
+ end
243
+
244
+ def positional(node)
245
+ Array(node.arguments&.arguments).reject { |argument| argument.class.name.end_with?("KeywordHashNode") }
246
+ end
247
+
248
+ def keywords(node)
249
+ hash = Array(node.arguments&.arguments).find { |argument| argument.class.name.end_with?("KeywordHashNode") }
250
+ Array(hash&.elements).to_h { |assoc| [static(assoc.key).to_sym, assoc.value] }
251
+ end
252
+
253
+ def keyword(node, key)
254
+ keywords(node)[key]
255
+ end
256
+
257
+ def each_node(node, &block)
258
+ return unless node
259
+
260
+ node.child_nodes.each do |child|
261
+ block.call(child)
262
+ each_node(child, &block)
263
+ end
264
+ end
265
+
266
+ def source_slice(node)
267
+ return "" unless node
268
+
269
+ location = node.respond_to?(:location) ? node.location : node
270
+ @source.byteslice(location.start_offset...location.end_offset)
271
+ end
272
+
273
+ def class_body_offset(node)
274
+ return node.body.location.start_offset if node.body
275
+
276
+ ending = node.location.end_offset
277
+ return ending - 3 if @source.byteslice(ending - 3, 3) == "end"
278
+
279
+ ending
280
+ end
281
+ end
282
+ end
283
+ end
@@ -0,0 +1,145 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Flexr
4
+ module Source
5
+ class StaticEval
6
+ MISSING = Object.new.freeze
7
+
8
+ attr_reader :constants
9
+
10
+ def initialize(source, constants: {}, scope: [])
11
+ @source = source
12
+ @constants = constants
13
+ @scope = Array(scope).map(&:to_s)
14
+ end
15
+
16
+ def call(node)
17
+ evaluate(node)
18
+ rescue StaticResolutionError
19
+ raise
20
+ rescue StandardError => e
21
+ raise_resolution("#{node.class}: #{e.message}")
22
+ end
23
+
24
+ private
25
+
26
+ def evaluate(node)
27
+ kind = node.class.name.split("::").last
28
+ case kind
29
+ when "RegularExpressionNode"
30
+ ::Regexp.new(node.unescaped, node.options)
31
+ when "InterpolatedRegularExpressionNode"
32
+ ::Regexp.new(interpolated(node.parts), node.options)
33
+ when "StringNode"
34
+ node.unescaped
35
+ when "InterpolatedStringNode"
36
+ interpolated(node.parts)
37
+ when "SymbolNode"
38
+ node.unescaped.to_sym
39
+ when "IntegerNode", "FloatNode"
40
+ node.value
41
+ when "TrueNode"
42
+ true
43
+ when "FalseNode"
44
+ false
45
+ when "NilNode"
46
+ nil
47
+ when "ArrayNode"
48
+ node.elements.map { |element| evaluate(element) }
49
+ when "ConstantReadNode"
50
+ evaluate_constant([node.name.to_s], absolute: false)
51
+ when "ConstantPathNode"
52
+ evaluate_constant_path(node)
53
+ when "SplatNode"
54
+ evaluate(node.expression)
55
+ when "RangeNode"
56
+ Range.new(evaluate(node.left), evaluate(node.right), node.exclude_end?)
57
+ when "CallNode"
58
+ evaluate_call(node)
59
+ else
60
+ raise_resolution("expression #{kind} is not statically supported")
61
+ end
62
+ end
63
+
64
+ def interpolated(parts)
65
+ parts.map do |part|
66
+ kind = part.class.name.split("::").last
67
+ if kind == "EmbeddedStatementsNode"
68
+ body = part.statements&.body || []
69
+ value = evaluate(body.last)
70
+ value.is_a?(::Regexp) ? "(?:#{value.source})" : value.to_s
71
+ else
72
+ evaluate(part).to_s
73
+ end
74
+ end.join
75
+ end
76
+
77
+ def evaluate_constant_path(node)
78
+ source = source_slice(node)
79
+ absolute = source.start_with?("::")
80
+ parts = source.delete_prefix("::").split("::").reject(&:empty?)
81
+ evaluate_constant(parts, absolute: absolute)
82
+ end
83
+
84
+ def evaluate_constant(parts, absolute:)
85
+ candidates = if absolute
86
+ [parts.join("::")]
87
+ else
88
+ @scope.length.downto(0).map do |depth|
89
+ (@scope.take(depth) + parts).join("::")
90
+ end
91
+ end
92
+
93
+ candidates.uniq.each do |candidate|
94
+ value = constant_value(candidate)
95
+ return value unless value.equal?(MISSING)
96
+ end
97
+
98
+ return ::Encoding.const_get(parts.last) if !absolute && parts.length == 2 && parts.first == "Encoding"
99
+
100
+ raise_resolution("constant #{parts.join('::')} is not statically known")
101
+ rescue NameError
102
+ raise_resolution("constant #{parts.join('::')} is not statically known")
103
+ end
104
+
105
+ def constant_value(name)
106
+ return @constants[name] if @constants.key?(name)
107
+
108
+ symbol = name.to_sym
109
+ return @constants[symbol] if @constants.key?(symbol)
110
+
111
+ MISSING
112
+ end
113
+
114
+ def source_slice(node)
115
+ location = node.location
116
+ @source.byteslice(location.start_offset...location.end_offset)
117
+ end
118
+
119
+ def evaluate_call(node)
120
+ return evaluate(node.receiver).freeze if node.receiver && node.name == :freeze
121
+ return ::Regexp.union(positional_arguments(node).map { |argument| evaluate(argument) }) if node.receiver && node.name == :union && constant_name(node.receiver) == "Regexp"
122
+ raise_resolution("method call #{node.name} is not statically supported")
123
+ end
124
+
125
+ def positional_arguments(node)
126
+ Array(node.arguments&.arguments).reject { |argument| argument.class.name.end_with?("KeywordHashNode") }
127
+ end
128
+
129
+ def constant_name(node)
130
+ return node.name.to_s if node.respond_to?(:name)
131
+
132
+ nil
133
+ end
134
+
135
+ def raise_resolution(reason)
136
+ diagnostic = Diagnostics.error(
137
+ "FLEXR-E017", "pattern is not statically resolvable",
138
+ help: "pass a literal, a constant, or use --eval",
139
+ note: "#{reason}; runtime mode still supports this Ruby expression; --eval can resolve it by executing the spec"
140
+ )
141
+ raise StaticResolutionError.new(diagnostic.message, diagnostic: diagnostic)
142
+ end
143
+ end
144
+ end
145
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Flexr
4
+ module Unicode
5
+ module CaseFold
6
+ module_function
7
+
8
+ def ranges(lo, hi)
9
+ table = Data.const_defined?(:CASE_FOLD, false) ? Data::CASE_FOLD : {}
10
+ return [[lo, hi]] if table.empty?
11
+
12
+ points = {}
13
+ table.each do |point, folded|
14
+ next unless point.between?(lo, hi) || folded.between?(lo, hi)
15
+
16
+ points[point] = true
17
+ points[folded] = true
18
+ end
19
+ loop do
20
+ changed = false
21
+ table.each do |point, folded|
22
+ next unless points.key?(point) || points.key?(folded)
23
+ next if points.key?(point) && points.key?(folded)
24
+
25
+ points[point] = true
26
+ points[folded] = true
27
+ changed = true
28
+ end
29
+ break unless changed
30
+ end
31
+ merge([[lo, hi]] + points.keys.map { |point| [point, point] })
32
+ end
33
+
34
+ def merge(ranges)
35
+ ranges.sort_by(&:first).each_with_object([]) do |range, result|
36
+ if result.empty? || range.first > result.last.last + 1
37
+ result << range.dup
38
+ else
39
+ result.last[1] = [result.last.last, range.last].max
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,5 @@
1
+ Copyright (c) 1991-2023 Unicode, Inc. All rights reserved.
2
+
3
+ The Unicode data tables distributed with flexr are derived from the Unicode
4
+ Character Database. The Unicode License is available at:
5
+ https://www.unicode.org/license.txt
@@ -0,0 +1 @@
1
+ 15.1.0
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Flexr
4
+ module Unicode
5
+ module Data
6
+ CASE_FOLD = {65 => 97, 66 => 98, 67 => 99, 68 => 100, 69 => 101, 70 => 102, 71 => 103, 72 => 104, 73 => 105, 74 => 106, 75 => 107, 76 => 108, 77 => 109, 78 => 110, 79 => 111, 80 => 112, 81 => 113, 82 => 114, 83 => 115, 84 => 116, 85 => 117, 86 => 118, 87 => 119, 88 => 120, 89 => 121, 90 => 122, 181 => 956, 192 => 224, 193 => 225, 194 => 226, 195 => 227, 196 => 228, 197 => 229, 198 => 230, 199 => 231, 200 => 232, 201 => 233, 202 => 234, 203 => 235, 204 => 236, 205 => 237, 206 => 238, 207 => 239, 208 => 240, 209 => 241, 210 => 242, 211 => 243, 212 => 244, 213 => 245, 214 => 246, 216 => 248, 217 => 249, 218 => 250, 219 => 251, 220 => 252, 221 => 253, 222 => 254, 256 => 257, 258 => 259, 260 => 261, 262 => 263, 264 => 265, 266 => 267, 268 => 269, 270 => 271, 272 => 273, 274 => 275, 276 => 277, 278 => 279, 280 => 281, 282 => 283, 284 => 285, 286 => 287, 288 => 289, 290 => 291, 292 => 293, 294 => 295, 296 => 297, 298 => 299, 300 => 301, 302 => 303, 306 => 307, 308 => 309, 310 => 311, 313 => 314, 315 => 316, 317 => 318, 319 => 320, 321 => 322, 323 => 324, 325 => 326, 327 => 328, 330 => 331, 332 => 333, 334 => 335, 336 => 337, 338 => 339, 340 => 341, 342 => 343, 344 => 345, 346 => 347, 348 => 349, 350 => 351, 352 => 353, 354 => 355, 356 => 357, 358 => 359, 360 => 361, 362 => 363, 364 => 365, 366 => 367, 368 => 369, 370 => 371, 372 => 373, 374 => 375, 376 => 255, 377 => 378, 379 => 380, 381 => 382, 383 => 115, 385 => 595, 386 => 387, 388 => 389, 390 => 596, 391 => 392, 393 => 598, 394 => 599, 395 => 396, 398 => 477, 399 => 601, 400 => 603, 401 => 402, 403 => 608, 404 => 611, 406 => 617, 407 => 616, 408 => 409, 412 => 623, 413 => 626, 415 => 629, 416 => 417, 418 => 419, 420 => 421, 422 => 640, 423 => 424, 425 => 643, 428 => 429, 430 => 648, 431 => 432, 433 => 650, 434 => 651, 435 => 436, 437 => 438, 439 => 658, 440 => 441, 444 => 445, 452 => 454, 453 => 454, 455 => 457, 456 => 457, 458 => 460, 459 => 460, 461 => 462, 463 => 464, 465 => 466, 467 => 468, 469 => 470, 471 => 472, 473 => 474, 475 => 476, 478 => 479, 480 => 481, 482 => 483, 484 => 485, 486 => 487, 488 => 489, 490 => 491, 492 => 493, 494 => 495, 497 => 499, 498 => 499, 500 => 501, 502 => 405, 503 => 447, 504 => 505, 506 => 507, 508 => 509, 510 => 511, 512 => 513, 514 => 515, 516 => 517, 518 => 519, 520 => 521, 522 => 523, 524 => 525, 526 => 527, 528 => 529, 530 => 531, 532 => 533, 534 => 535, 536 => 537, 538 => 539, 540 => 541, 542 => 543, 544 => 414, 546 => 547, 548 => 549, 550 => 551, 552 => 553, 554 => 555, 556 => 557, 558 => 559, 560 => 561, 562 => 563, 570 => 11365, 571 => 572, 573 => 410, 574 => 11366, 577 => 578, 579 => 384, 580 => 649, 581 => 652, 582 => 583, 584 => 585, 586 => 587, 588 => 589, 590 => 591, 837 => 953, 880 => 881, 882 => 883, 886 => 887, 895 => 1011, 902 => 940, 904 => 941, 905 => 942, 906 => 943, 908 => 972, 910 => 973, 911 => 974, 913 => 945, 914 => 946, 915 => 947, 916 => 948, 917 => 949, 918 => 950, 919 => 951, 920 => 952, 921 => 953, 922 => 954, 923 => 955, 924 => 956, 925 => 957, 926 => 958, 927 => 959, 928 => 960, 929 => 961, 931 => 963, 932 => 964, 933 => 965, 934 => 966, 935 => 967, 936 => 968, 937 => 969, 938 => 970, 939 => 971, 962 => 963, 975 => 983, 976 => 946, 977 => 952, 981 => 966, 982 => 960, 984 => 985, 986 => 987, 988 => 989, 990 => 991, 992 => 993, 994 => 995, 996 => 997, 998 => 999, 1000 => 1001, 1002 => 1003, 1004 => 1005, 1006 => 1007, 1008 => 954, 1009 => 961, 1012 => 952, 1013 => 949, 1015 => 1016, 1017 => 1010, 1018 => 1019, 1021 => 891, 1022 => 892, 1023 => 893, 1024 => 1104, 1025 => 1105, 1026 => 1106, 1027 => 1107, 1028 => 1108, 1029 => 1109, 1030 => 1110, 1031 => 1111, 1032 => 1112, 1033 => 1113, 1034 => 1114, 1035 => 1115, 1036 => 1116, 1037 => 1117, 1038 => 1118, 1039 => 1119, 1040 => 1072, 1041 => 1073, 1042 => 1074, 1043 => 1075, 1044 => 1076, 1045 => 1077, 1046 => 1078, 1047 => 1079, 1048 => 1080, 1049 => 1081, 1050 => 1082, 1051 => 1083, 1052 => 1084, 1053 => 1085, 1054 => 1086, 1055 => 1087, 1056 => 1088, 1057 => 1089, 1058 => 1090, 1059 => 1091, 1060 => 1092, 1061 => 1093, 1062 => 1094, 1063 => 1095, 1064 => 1096, 1065 => 1097, 1066 => 1098, 1067 => 1099, 1068 => 1100, 1069 => 1101, 1070 => 1102, 1071 => 1103, 1120 => 1121, 1122 => 1123, 1124 => 1125, 1126 => 1127, 1128 => 1129, 1130 => 1131, 1132 => 1133, 1134 => 1135, 1136 => 1137, 1138 => 1139, 1140 => 1141, 1142 => 1143, 1144 => 1145, 1146 => 1147, 1148 => 1149, 1150 => 1151, 1152 => 1153, 1162 => 1163, 1164 => 1165, 1166 => 1167, 1168 => 1169, 1170 => 1171, 1172 => 1173, 1174 => 1175, 1176 => 1177, 1178 => 1179, 1180 => 1181, 1182 => 1183, 1184 => 1185, 1186 => 1187, 1188 => 1189, 1190 => 1191, 1192 => 1193, 1194 => 1195, 1196 => 1197, 1198 => 1199, 1200 => 1201, 1202 => 1203, 1204 => 1205, 1206 => 1207, 1208 => 1209, 1210 => 1211, 1212 => 1213, 1214 => 1215, 1216 => 1231, 1217 => 1218, 1219 => 1220, 1221 => 1222, 1223 => 1224, 1225 => 1226, 1227 => 1228, 1229 => 1230, 1232 => 1233, 1234 => 1235, 1236 => 1237, 1238 => 1239, 1240 => 1241, 1242 => 1243, 1244 => 1245, 1246 => 1247, 1248 => 1249, 1250 => 1251, 1252 => 1253, 1254 => 1255, 1256 => 1257, 1258 => 1259, 1260 => 1261, 1262 => 1263, 1264 => 1265, 1266 => 1267, 1268 => 1269, 1270 => 1271, 1272 => 1273, 1274 => 1275, 1276 => 1277, 1278 => 1279, 1280 => 1281, 1282 => 1283, 1284 => 1285, 1286 => 1287, 1288 => 1289, 1290 => 1291, 1292 => 1293, 1294 => 1295, 1296 => 1297, 1298 => 1299, 1300 => 1301, 1302 => 1303, 1304 => 1305, 1306 => 1307, 1308 => 1309, 1310 => 1311, 1312 => 1313, 1314 => 1315, 1316 => 1317, 1318 => 1319, 1320 => 1321, 1322 => 1323, 1324 => 1325, 1326 => 1327, 1329 => 1377, 1330 => 1378, 1331 => 1379, 1332 => 1380, 1333 => 1381, 1334 => 1382, 1335 => 1383, 1336 => 1384, 1337 => 1385, 1338 => 1386, 1339 => 1387, 1340 => 1388, 1341 => 1389, 1342 => 1390, 1343 => 1391, 1344 => 1392, 1345 => 1393, 1346 => 1394, 1347 => 1395, 1348 => 1396, 1349 => 1397, 1350 => 1398, 1351 => 1399, 1352 => 1400, 1353 => 1401, 1354 => 1402, 1355 => 1403, 1356 => 1404, 1357 => 1405, 1358 => 1406, 1359 => 1407, 1360 => 1408, 1361 => 1409, 1362 => 1410, 1363 => 1411, 1364 => 1412, 1365 => 1413, 1366 => 1414, 4256 => 11520, 4257 => 11521, 4258 => 11522, 4259 => 11523, 4260 => 11524, 4261 => 11525, 4262 => 11526, 4263 => 11527, 4264 => 11528, 4265 => 11529, 4266 => 11530, 4267 => 11531, 4268 => 11532, 4269 => 11533, 4270 => 11534, 4271 => 11535, 4272 => 11536, 4273 => 11537, 4274 => 11538, 4275 => 11539, 4276 => 11540, 4277 => 11541, 4278 => 11542, 4279 => 11543, 4280 => 11544, 4281 => 11545, 4282 => 11546, 4283 => 11547, 4284 => 11548, 4285 => 11549, 4286 => 11550, 4287 => 11551, 4288 => 11552, 4289 => 11553, 4290 => 11554, 4291 => 11555, 4292 => 11556, 4293 => 11557, 4295 => 11559, 4301 => 11565, 5112 => 5104, 5113 => 5105, 5114 => 5106, 5115 => 5107, 5116 => 5108, 5117 => 5109, 7296 => 1074, 7297 => 1076, 7298 => 1086, 7299 => 1089, 7300 => 1090, 7301 => 1090, 7302 => 1098, 7303 => 1123, 7304 => 42571, 7312 => 4304, 7313 => 4305, 7314 => 4306, 7315 => 4307, 7316 => 4308, 7317 => 4309, 7318 => 4310, 7319 => 4311, 7320 => 4312, 7321 => 4313, 7322 => 4314, 7323 => 4315, 7324 => 4316, 7325 => 4317, 7326 => 4318, 7327 => 4319, 7328 => 4320, 7329 => 4321, 7330 => 4322, 7331 => 4323, 7332 => 4324, 7333 => 4325, 7334 => 4326, 7335 => 4327, 7336 => 4328, 7337 => 4329, 7338 => 4330, 7339 => 4331, 7340 => 4332, 7341 => 4333, 7342 => 4334, 7343 => 4335, 7344 => 4336, 7345 => 4337, 7346 => 4338, 7347 => 4339, 7348 => 4340, 7349 => 4341, 7350 => 4342, 7351 => 4343, 7352 => 4344, 7353 => 4345, 7354 => 4346, 7357 => 4349, 7358 => 4350, 7359 => 4351, 7680 => 7681, 7682 => 7683, 7684 => 7685, 7686 => 7687, 7688 => 7689, 7690 => 7691, 7692 => 7693, 7694 => 7695, 7696 => 7697, 7698 => 7699, 7700 => 7701, 7702 => 7703, 7704 => 7705, 7706 => 7707, 7708 => 7709, 7710 => 7711, 7712 => 7713, 7714 => 7715, 7716 => 7717, 7718 => 7719, 7720 => 7721, 7722 => 7723, 7724 => 7725, 7726 => 7727, 7728 => 7729, 7730 => 7731, 7732 => 7733, 7734 => 7735, 7736 => 7737, 7738 => 7739, 7740 => 7741, 7742 => 7743, 7744 => 7745, 7746 => 7747, 7748 => 7749, 7750 => 7751, 7752 => 7753, 7754 => 7755, 7756 => 7757, 7758 => 7759, 7760 => 7761, 7762 => 7763, 7764 => 7765, 7766 => 7767, 7768 => 7769, 7770 => 7771, 7772 => 7773, 7774 => 7775, 7776 => 7777, 7778 => 7779, 7780 => 7781, 7782 => 7783, 7784 => 7785, 7786 => 7787, 7788 => 7789, 7790 => 7791, 7792 => 7793, 7794 => 7795, 7796 => 7797, 7798 => 7799, 7800 => 7801, 7802 => 7803, 7804 => 7805, 7806 => 7807, 7808 => 7809, 7810 => 7811, 7812 => 7813, 7814 => 7815, 7816 => 7817, 7818 => 7819, 7820 => 7821, 7822 => 7823, 7824 => 7825, 7826 => 7827, 7828 => 7829, 7835 => 7777, 7838 => 223, 7840 => 7841, 7842 => 7843, 7844 => 7845, 7846 => 7847, 7848 => 7849, 7850 => 7851, 7852 => 7853, 7854 => 7855, 7856 => 7857, 7858 => 7859, 7860 => 7861, 7862 => 7863, 7864 => 7865, 7866 => 7867, 7868 => 7869, 7870 => 7871, 7872 => 7873, 7874 => 7875, 7876 => 7877, 7878 => 7879, 7880 => 7881, 7882 => 7883, 7884 => 7885, 7886 => 7887, 7888 => 7889, 7890 => 7891, 7892 => 7893, 7894 => 7895, 7896 => 7897, 7898 => 7899, 7900 => 7901, 7902 => 7903, 7904 => 7905, 7906 => 7907, 7908 => 7909, 7910 => 7911, 7912 => 7913, 7914 => 7915, 7916 => 7917, 7918 => 7919, 7920 => 7921, 7922 => 7923, 7924 => 7925, 7926 => 7927, 7928 => 7929, 7930 => 7931, 7932 => 7933, 7934 => 7935, 7944 => 7936, 7945 => 7937, 7946 => 7938, 7947 => 7939, 7948 => 7940, 7949 => 7941, 7950 => 7942, 7951 => 7943, 7960 => 7952, 7961 => 7953, 7962 => 7954, 7963 => 7955, 7964 => 7956, 7965 => 7957, 7976 => 7968, 7977 => 7969, 7978 => 7970, 7979 => 7971, 7980 => 7972, 7981 => 7973, 7982 => 7974, 7983 => 7975, 7992 => 7984, 7993 => 7985, 7994 => 7986, 7995 => 7987, 7996 => 7988, 7997 => 7989, 7998 => 7990, 7999 => 7991, 8008 => 8000, 8009 => 8001, 8010 => 8002, 8011 => 8003, 8012 => 8004, 8013 => 8005, 8025 => 8017, 8027 => 8019, 8029 => 8021, 8031 => 8023, 8040 => 8032, 8041 => 8033, 8042 => 8034, 8043 => 8035, 8044 => 8036, 8045 => 8037, 8046 => 8038, 8047 => 8039, 8072 => 8064, 8073 => 8065, 8074 => 8066, 8075 => 8067, 8076 => 8068, 8077 => 8069, 8078 => 8070, 8079 => 8071, 8088 => 8080, 8089 => 8081, 8090 => 8082, 8091 => 8083, 8092 => 8084, 8093 => 8085, 8094 => 8086, 8095 => 8087, 8104 => 8096, 8105 => 8097, 8106 => 8098, 8107 => 8099, 8108 => 8100, 8109 => 8101, 8110 => 8102, 8111 => 8103, 8120 => 8112, 8121 => 8113, 8122 => 8048, 8123 => 8049, 8124 => 8115, 8126 => 953, 8136 => 8050, 8137 => 8051, 8138 => 8052, 8139 => 8053, 8140 => 8131, 8147 => 912, 8152 => 8144, 8153 => 8145, 8154 => 8054, 8155 => 8055, 8163 => 944, 8168 => 8160, 8169 => 8161, 8170 => 8058, 8171 => 8059, 8172 => 8165, 8184 => 8056, 8185 => 8057, 8186 => 8060, 8187 => 8061, 8188 => 8179, 8486 => 969, 8490 => 107, 8491 => 229, 8498 => 8526, 8544 => 8560, 8545 => 8561, 8546 => 8562, 8547 => 8563, 8548 => 8564, 8549 => 8565, 8550 => 8566, 8551 => 8567, 8552 => 8568, 8553 => 8569, 8554 => 8570, 8555 => 8571, 8556 => 8572, 8557 => 8573, 8558 => 8574, 8559 => 8575, 8579 => 8580, 9398 => 9424, 9399 => 9425, 9400 => 9426, 9401 => 9427, 9402 => 9428, 9403 => 9429, 9404 => 9430, 9405 => 9431, 9406 => 9432, 9407 => 9433, 9408 => 9434, 9409 => 9435, 9410 => 9436, 9411 => 9437, 9412 => 9438, 9413 => 9439, 9414 => 9440, 9415 => 9441, 9416 => 9442, 9417 => 9443, 9418 => 9444, 9419 => 9445, 9420 => 9446, 9421 => 9447, 9422 => 9448, 9423 => 9449, 11264 => 11312, 11265 => 11313, 11266 => 11314, 11267 => 11315, 11268 => 11316, 11269 => 11317, 11270 => 11318, 11271 => 11319, 11272 => 11320, 11273 => 11321, 11274 => 11322, 11275 => 11323, 11276 => 11324, 11277 => 11325, 11278 => 11326, 11279 => 11327, 11280 => 11328, 11281 => 11329, 11282 => 11330, 11283 => 11331, 11284 => 11332, 11285 => 11333, 11286 => 11334, 11287 => 11335, 11288 => 11336, 11289 => 11337, 11290 => 11338, 11291 => 11339, 11292 => 11340, 11293 => 11341, 11294 => 11342, 11295 => 11343, 11296 => 11344, 11297 => 11345, 11298 => 11346, 11299 => 11347, 11300 => 11348, 11301 => 11349, 11302 => 11350, 11303 => 11351, 11304 => 11352, 11305 => 11353, 11306 => 11354, 11307 => 11355, 11308 => 11356, 11309 => 11357, 11310 => 11358, 11311 => 11359, 11360 => 11361, 11362 => 619, 11363 => 7549, 11364 => 637, 11367 => 11368, 11369 => 11370, 11371 => 11372, 11373 => 593, 11374 => 625, 11375 => 592, 11376 => 594, 11378 => 11379, 11381 => 11382, 11390 => 575, 11391 => 576, 11392 => 11393, 11394 => 11395, 11396 => 11397, 11398 => 11399, 11400 => 11401, 11402 => 11403, 11404 => 11405, 11406 => 11407, 11408 => 11409, 11410 => 11411, 11412 => 11413, 11414 => 11415, 11416 => 11417, 11418 => 11419, 11420 => 11421, 11422 => 11423, 11424 => 11425, 11426 => 11427, 11428 => 11429, 11430 => 11431, 11432 => 11433, 11434 => 11435, 11436 => 11437, 11438 => 11439, 11440 => 11441, 11442 => 11443, 11444 => 11445, 11446 => 11447, 11448 => 11449, 11450 => 11451, 11452 => 11453, 11454 => 11455, 11456 => 11457, 11458 => 11459, 11460 => 11461, 11462 => 11463, 11464 => 11465, 11466 => 11467, 11468 => 11469, 11470 => 11471, 11472 => 11473, 11474 => 11475, 11476 => 11477, 11478 => 11479, 11480 => 11481, 11482 => 11483, 11484 => 11485, 11486 => 11487, 11488 => 11489, 11490 => 11491, 11499 => 11500, 11501 => 11502, 11506 => 11507, 42560 => 42561, 42562 => 42563, 42564 => 42565, 42566 => 42567, 42568 => 42569, 42570 => 42571, 42572 => 42573, 42574 => 42575, 42576 => 42577, 42578 => 42579, 42580 => 42581, 42582 => 42583, 42584 => 42585, 42586 => 42587, 42588 => 42589, 42590 => 42591, 42592 => 42593, 42594 => 42595, 42596 => 42597, 42598 => 42599, 42600 => 42601, 42602 => 42603, 42604 => 42605, 42624 => 42625, 42626 => 42627, 42628 => 42629, 42630 => 42631, 42632 => 42633, 42634 => 42635, 42636 => 42637, 42638 => 42639, 42640 => 42641, 42642 => 42643, 42644 => 42645, 42646 => 42647, 42648 => 42649, 42650 => 42651, 42786 => 42787, 42788 => 42789, 42790 => 42791, 42792 => 42793, 42794 => 42795, 42796 => 42797, 42798 => 42799, 42802 => 42803, 42804 => 42805, 42806 => 42807, 42808 => 42809, 42810 => 42811, 42812 => 42813, 42814 => 42815, 42816 => 42817, 42818 => 42819, 42820 => 42821, 42822 => 42823, 42824 => 42825, 42826 => 42827, 42828 => 42829, 42830 => 42831, 42832 => 42833, 42834 => 42835, 42836 => 42837, 42838 => 42839, 42840 => 42841, 42842 => 42843, 42844 => 42845, 42846 => 42847, 42848 => 42849, 42850 => 42851, 42852 => 42853, 42854 => 42855, 42856 => 42857, 42858 => 42859, 42860 => 42861, 42862 => 42863, 42873 => 42874, 42875 => 42876, 42877 => 7545, 42878 => 42879, 42880 => 42881, 42882 => 42883, 42884 => 42885, 42886 => 42887, 42891 => 42892, 42893 => 613, 42896 => 42897, 42898 => 42899, 42902 => 42903, 42904 => 42905, 42906 => 42907, 42908 => 42909, 42910 => 42911, 42912 => 42913, 42914 => 42915, 42916 => 42917, 42918 => 42919, 42920 => 42921, 42922 => 614, 42923 => 604, 42924 => 609, 42925 => 620, 42926 => 618, 42928 => 670, 42929 => 647, 42930 => 669, 42931 => 43859, 42932 => 42933, 42934 => 42935, 42936 => 42937, 42938 => 42939, 42940 => 42941, 42942 => 42943, 42944 => 42945, 42946 => 42947, 42948 => 42900, 42949 => 642, 42950 => 7566, 42951 => 42952, 42953 => 42954, 42960 => 42961, 42966 => 42967, 42968 => 42969, 42997 => 42998, 43888 => 5024, 43889 => 5025, 43890 => 5026, 43891 => 5027, 43892 => 5028, 43893 => 5029, 43894 => 5030, 43895 => 5031, 43896 => 5032, 43897 => 5033, 43898 => 5034, 43899 => 5035, 43900 => 5036, 43901 => 5037, 43902 => 5038, 43903 => 5039, 43904 => 5040, 43905 => 5041, 43906 => 5042, 43907 => 5043, 43908 => 5044, 43909 => 5045, 43910 => 5046, 43911 => 5047, 43912 => 5048, 43913 => 5049, 43914 => 5050, 43915 => 5051, 43916 => 5052, 43917 => 5053, 43918 => 5054, 43919 => 5055, 43920 => 5056, 43921 => 5057, 43922 => 5058, 43923 => 5059, 43924 => 5060, 43925 => 5061, 43926 => 5062, 43927 => 5063, 43928 => 5064, 43929 => 5065, 43930 => 5066, 43931 => 5067, 43932 => 5068, 43933 => 5069, 43934 => 5070, 43935 => 5071, 43936 => 5072, 43937 => 5073, 43938 => 5074, 43939 => 5075, 43940 => 5076, 43941 => 5077, 43942 => 5078, 43943 => 5079, 43944 => 5080, 43945 => 5081, 43946 => 5082, 43947 => 5083, 43948 => 5084, 43949 => 5085, 43950 => 5086, 43951 => 5087, 43952 => 5088, 43953 => 5089, 43954 => 5090, 43955 => 5091, 43956 => 5092, 43957 => 5093, 43958 => 5094, 43959 => 5095, 43960 => 5096, 43961 => 5097, 43962 => 5098, 43963 => 5099, 43964 => 5100, 43965 => 5101, 43966 => 5102, 43967 => 5103, 64261 => 64262, 65313 => 65345, 65314 => 65346, 65315 => 65347, 65316 => 65348, 65317 => 65349, 65318 => 65350, 65319 => 65351, 65320 => 65352, 65321 => 65353, 65322 => 65354, 65323 => 65355, 65324 => 65356, 65325 => 65357, 65326 => 65358, 65327 => 65359, 65328 => 65360, 65329 => 65361, 65330 => 65362, 65331 => 65363, 65332 => 65364, 65333 => 65365, 65334 => 65366, 65335 => 65367, 65336 => 65368, 65337 => 65369, 65338 => 65370, 66560 => 66600, 66561 => 66601, 66562 => 66602, 66563 => 66603, 66564 => 66604, 66565 => 66605, 66566 => 66606, 66567 => 66607, 66568 => 66608, 66569 => 66609, 66570 => 66610, 66571 => 66611, 66572 => 66612, 66573 => 66613, 66574 => 66614, 66575 => 66615, 66576 => 66616, 66577 => 66617, 66578 => 66618, 66579 => 66619, 66580 => 66620, 66581 => 66621, 66582 => 66622, 66583 => 66623, 66584 => 66624, 66585 => 66625, 66586 => 66626, 66587 => 66627, 66588 => 66628, 66589 => 66629, 66590 => 66630, 66591 => 66631, 66592 => 66632, 66593 => 66633, 66594 => 66634, 66595 => 66635, 66596 => 66636, 66597 => 66637, 66598 => 66638, 66599 => 66639, 66736 => 66776, 66737 => 66777, 66738 => 66778, 66739 => 66779, 66740 => 66780, 66741 => 66781, 66742 => 66782, 66743 => 66783, 66744 => 66784, 66745 => 66785, 66746 => 66786, 66747 => 66787, 66748 => 66788, 66749 => 66789, 66750 => 66790, 66751 => 66791, 66752 => 66792, 66753 => 66793, 66754 => 66794, 66755 => 66795, 66756 => 66796, 66757 => 66797, 66758 => 66798, 66759 => 66799, 66760 => 66800, 66761 => 66801, 66762 => 66802, 66763 => 66803, 66764 => 66804, 66765 => 66805, 66766 => 66806, 66767 => 66807, 66768 => 66808, 66769 => 66809, 66770 => 66810, 66771 => 66811, 66928 => 66967, 66929 => 66968, 66930 => 66969, 66931 => 66970, 66932 => 66971, 66933 => 66972, 66934 => 66973, 66935 => 66974, 66936 => 66975, 66937 => 66976, 66938 => 66977, 66940 => 66979, 66941 => 66980, 66942 => 66981, 66943 => 66982, 66944 => 66983, 66945 => 66984, 66946 => 66985, 66947 => 66986, 66948 => 66987, 66949 => 66988, 66950 => 66989, 66951 => 66990, 66952 => 66991, 66953 => 66992, 66954 => 66993, 66956 => 66995, 66957 => 66996, 66958 => 66997, 66959 => 66998, 66960 => 66999, 66961 => 67000, 66962 => 67001, 66964 => 67003, 66965 => 67004, 68736 => 68800, 68737 => 68801, 68738 => 68802, 68739 => 68803, 68740 => 68804, 68741 => 68805, 68742 => 68806, 68743 => 68807, 68744 => 68808, 68745 => 68809, 68746 => 68810, 68747 => 68811, 68748 => 68812, 68749 => 68813, 68750 => 68814, 68751 => 68815, 68752 => 68816, 68753 => 68817, 68754 => 68818, 68755 => 68819, 68756 => 68820, 68757 => 68821, 68758 => 68822, 68759 => 68823, 68760 => 68824, 68761 => 68825, 68762 => 68826, 68763 => 68827, 68764 => 68828, 68765 => 68829, 68766 => 68830, 68767 => 68831, 68768 => 68832, 68769 => 68833, 68770 => 68834, 68771 => 68835, 68772 => 68836, 68773 => 68837, 68774 => 68838, 68775 => 68839, 68776 => 68840, 68777 => 68841, 68778 => 68842, 68779 => 68843, 68780 => 68844, 68781 => 68845, 68782 => 68846, 68783 => 68847, 68784 => 68848, 68785 => 68849, 68786 => 68850, 71840 => 71872, 71841 => 71873, 71842 => 71874, 71843 => 71875, 71844 => 71876, 71845 => 71877, 71846 => 71878, 71847 => 71879, 71848 => 71880, 71849 => 71881, 71850 => 71882, 71851 => 71883, 71852 => 71884, 71853 => 71885, 71854 => 71886, 71855 => 71887, 71856 => 71888, 71857 => 71889, 71858 => 71890, 71859 => 71891, 71860 => 71892, 71861 => 71893, 71862 => 71894, 71863 => 71895, 71864 => 71896, 71865 => 71897, 71866 => 71898, 71867 => 71899, 71868 => 71900, 71869 => 71901, 71870 => 71902, 71871 => 71903, 93760 => 93792, 93761 => 93793, 93762 => 93794, 93763 => 93795, 93764 => 93796, 93765 => 93797, 93766 => 93798, 93767 => 93799, 93768 => 93800, 93769 => 93801, 93770 => 93802, 93771 => 93803, 93772 => 93804, 93773 => 93805, 93774 => 93806, 93775 => 93807, 93776 => 93808, 93777 => 93809, 93778 => 93810, 93779 => 93811, 93780 => 93812, 93781 => 93813, 93782 => 93814, 93783 => 93815, 93784 => 93816, 93785 => 93817, 93786 => 93818, 93787 => 93819, 93788 => 93820, 93789 => 93821, 93790 => 93822, 93791 => 93823, 125184 => 125218, 125185 => 125219, 125186 => 125220, 125187 => 125221, 125188 => 125222, 125189 => 125223, 125190 => 125224, 125191 => 125225, 125192 => 125226, 125193 => 125227, 125194 => 125228, 125195 => 125229, 125196 => 125230, 125197 => 125231, 125198 => 125232, 125199 => 125233, 125200 => 125234, 125201 => 125235, 125202 => 125236, 125203 => 125237, 125204 => 125238, 125205 => 125239, 125206 => 125240, 125207 => 125241, 125208 => 125242, 125209 => 125243, 125210 => 125244, 125211 => 125245, 125212 => 125246, 125213 => 125247, 125214 => 125248, 125215 => 125249, 125216 => 125250, 125217 => 125251}.freeze
7
+ end
8
+ end
9
+ end