parsanol 1.3.84-arm-linux → 1.3.85-arm-linux

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7fe58dafe54c7d48c133db50eaa7e71e289405348f4f9127a6cebb381efd648f
4
- data.tar.gz: 4150bbf3e58d1f56733309bf297d249b17b1896a5f5406ae28bcd18ab93cbed0
3
+ metadata.gz: b8fb8fead38031f96872f7aae3373ff012794c1733d534d759c6ac57e38cdb95
4
+ data.tar.gz: 11c3fbeae81c61325155c805cb31c8a0aefa6a29a3fa6979349912c715e0c596
5
5
  SHA512:
6
- metadata.gz: 4c5193545cbf0c4c9d8d4993e218876192d134a6085d8ba667f241f1ee7528a8919a6603f3be1a605eecb8b2146933997c44536f5861359c652bbf0d6cfac35e
7
- data.tar.gz: 837871fe2d1de062d73ed4eb47dac35e471346fb3926218b83c54fda9088fb27ba2b5a581cd4176c05854580df0ffd23dc0d6ac4223bd1024942c2d09ee6bd98
6
+ metadata.gz: 02254b1575071cd812a89e9cc18559df5d1c0fe75038928d159a52d9e448374505765e69e98e7eca201730639ca212424d2c9ac183e198b1ef6e71a3aab080fd
7
+ data.tar.gz: 28dd52ef90e9930b67deea237f40b63f0c68ea7526c6d9dbe6653536f8f265977ee238e3cd91b6b5e83e571152b579788193c3749048adb84254c98e381255f6
@@ -202,6 +202,38 @@ module Parsanol
202
202
  stats
203
203
  end
204
204
 
205
+ # True when the grammar carries no atoms the native tier cannot
206
+ # express (Dynamic callbacks, artifact custom bindings). Cached by
207
+ # grammar identity — the scan walks the atom tree once.
208
+ def native_expressible?(grammar)
209
+ root = grammar.is_a?(Parsanol::Parser) ? grammar.root : grammar
210
+ cache = (@expressible_cache ||= {}.compare_by_identity)
211
+ cache.fetch(root) do
212
+ expressible = !contains_inexpressible?(root, {}.compare_by_identity)
213
+ cache[root] = expressible
214
+ end
215
+ end
216
+
217
+ def contains_inexpressible?(atom, seen)
218
+ return false if seen.key?(atom)
219
+
220
+ seen[atom] = true
221
+ case atom
222
+ when Parsanol::Atoms::Dynamic, Parsanol::Atoms::CustomRef then true
223
+ when Parsanol::Atoms::Sequence, Parsanol::Atoms::Alternative
224
+ children = atom.respond_to?(:parslets) ? atom.parslets : atom.alternatives
225
+ children.any? { |child| contains_inexpressible?(child, seen) }
226
+ when Parsanol::Atoms::Entity, Parsanol::Atoms::Repetition,
227
+ Parsanol::Atoms::Named, Parsanol::Atoms::Capture, Parsanol::Atoms::Ignored,
228
+ Parsanol::Atoms::Trivia, Parsanol::Atoms::TriviaCapture, Parsanol::Atoms::Lookahead
229
+ inner = atom.respond_to?(:parslet) ? atom.parslet : nil
230
+ inner ||= atom.wrapped_atom if atom.respond_to?(:wrapped_atom)
231
+ inner && contains_inexpressible?(inner, seen)
232
+ else
233
+ false
234
+ end
235
+ end
236
+
205
237
  # Translates a native backend failure into the Parsanol error protocol.
206
238
  #
207
239
  # When the grammar atom is at hand, reparses through the pure Ruby
@@ -227,9 +259,19 @@ module Parsanol
227
259
  # across long parses (#123).
228
260
  message = error.message
229
261
  if parsanol_grammar && (pos_str = message[NATIVE_POS_MARKER, 1])
262
+ # The interpreter reparse exists to RECOVER grammars the
263
+ # native tier cannot express (Dynamic/CustomRef atoms —
264
+ # parsanol-ruby#80/#129). For grammars without them the
265
+ # native failure is authoritative and the deepest-position
266
+ # diagnostics ride in this message — reparsing through the
267
+ # interpreter buys nothing and, on capture-heavy injected
268
+ # grammars, explodes (#190: the interpreter memo never
269
+ # stores capture-spanning outcomes).
230
270
  source = Parsanol::Source.new(input)
231
- success, value = grammar.run_with_context(source, nil, true)
232
- return grammar.finalize_result(value) if success
271
+ unless native_expressible?(grammar)
272
+ success, value = grammar.run_with_context(source, nil, true)
273
+ return grammar.finalize_result(value) if success
274
+ end
233
275
 
234
276
  pos = pos_str.to_i
235
277
  msg = message.sub(NATIVE_POS_MARKER, "")
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Parsanol
4
- VERSION = "1.3.84"
4
+ VERSION = "1.3.85"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parsanol
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.84
4
+ version: 1.3.85
5
5
  platform: arm-linux
6
6
  authors:
7
7
  - Ribose Inc.