parsanol 1.3.24 → 1.3.25

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: 0bc2202f0fc776a4211bfdb92685bef4060456ed45f2dcc7d1a6da101ea43b6d
4
- data.tar.gz: 9fcbbedcd54b53cee1fdf09ff749f3f61f247288f71c5e74ca7684b357603093
3
+ metadata.gz: 51ea4c7c7fd78c075837c89b1a493bdf30a568039b62f2769053de5f0b04e96c
4
+ data.tar.gz: a89687b9944d96244ec0b9e157c451af1987e717d71b7f7ffa557dcf5ecc9e82
5
5
  SHA512:
6
- metadata.gz: 959e445f1d28863e471658e332596a0c9ad254cad3272011841e29305c27449760c1330bfd7165d8cd81d7dedc44e48d38c582badf1b1592b5b02a16fcfe45f4
7
- data.tar.gz: ecbaada2b340858f93b22bd30a0065ec5183e688d14783de1cba0b74ba591b9680eeebbc3798302e069c323467197f38809a9fbbf7422a7e12c72e4693add9e8
6
+ metadata.gz: f5cbfc62118378137cd8db8fda585067d33f9e6471506e38d504afba8367cd6ba64d5b337c967a38e2ac6019a8acc61c1436cf7735bee6e00182fbe9f2ea3890
7
+ data.tar.gz: a1389dfca0a282a1530a3fa5d0b6de8e02f513b6f2cdc4fd037c4987cf687538b64ee3168d7f9f8d1f0468bd43899176eb8338f941ebf3d83c453ba4539bea34
@@ -123,11 +123,7 @@ module Parsanol
123
123
  # forwarding options via super produces; :mode must be honored
124
124
  # wherever it appears, or those callers silently get the native path.
125
125
  mode = opts.delete(:mode) ||
126
- (if Parsanol::Native.available? && !opts.key?(:reporter)
127
- :native
128
- else
129
- :ruby
130
- end)
126
+ (Parsanol::Native.available? ? :native : :ruby)
131
127
  case mode
132
128
  when :ruby
133
129
  super(input, opts)
@@ -217,17 +213,33 @@ module Parsanol
217
213
  # @return [Object] parse result with Slice objects for position info
218
214
  #
219
215
  def parse_native(input, opts)
220
- if Parsanol::Native.available?
221
- if opts.key?(:prefix) && opts[:prefix]
222
- value, _end_pos = Parsanol::Native.parse_prefix(root, input)
223
- return value
224
- end
225
-
226
- Parsanol::Native.parse(root, input)
227
- else
216
+ unless Parsanol::Native.available?
228
217
  Parsanol::Atoms::Base.instance_method(:parse).bind_call(self, input,
229
218
  opts)
219
+ return
220
+ end
221
+
222
+ if opts.key?(:prefix) && opts[:prefix]
223
+ value, _end_pos = Parsanol::Native.parse_prefix(root, input)
224
+ return value
230
225
  end
226
+
227
+ Parsanol::Native.parse(root, input)
228
+ rescue Parsanol::ParseFailed => e
229
+ feed_native_reporter(opts[:reporter], input, e)
230
+ raise
231
+ end
232
+
233
+ # Feed the native deepest-failure diagnostics to a user-supplied
234
+ # reporter: one err_at event carrying the cause the native engine
235
+ # already produced. The full per-atom event stream of the Ruby
236
+ # engine remains available via an explicit `mode: :ruby`.
237
+ def feed_native_reporter(reporter, input, error)
238
+ return unless reporter.respond_to?(:err_at)
239
+
240
+ source = Parsanol::Source.new(input)
241
+ cause = error.parse_failure_cause
242
+ reporter.err_at(nil, source, error.message, cause ? cause.position : 0)
231
243
  end
232
244
 
233
245
  # JSON output mode - returns JSON with position info.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Parsanol
4
- VERSION = "1.3.24"
4
+ VERSION = "1.3.25"
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.24
4
+ version: 1.3.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.