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 +4 -4
- data/lib/parsanol/parser.rb +25 -13
- data/lib/parsanol/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 51ea4c7c7fd78c075837c89b1a493bdf30a568039b62f2769053de5f0b04e96c
|
|
4
|
+
data.tar.gz: a89687b9944d96244ec0b9e157c451af1987e717d71b7f7ffa557dcf5ecc9e82
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f5cbfc62118378137cd8db8fda585067d33f9e6471506e38d504afba8367cd6ba64d5b337c967a38e2ac6019a8acc61c1436cf7735bee6e00182fbe9f2ea3890
|
|
7
|
+
data.tar.gz: a1389dfca0a282a1530a3fa5d0b6de8e02f513b6f2cdc4fd037c4987cf687538b64ee3168d7f9f8d1f0468bd43899176eb8338f941ebf3d83c453ba4539bea34
|
data/lib/parsanol/parser.rb
CHANGED
|
@@ -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
|
-
(
|
|
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
|
-
|
|
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.
|
data/lib/parsanol/version.rb
CHANGED