parsanol 1.3.23-arm-linux → 1.3.25-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 +4 -4
- data/lib/parsanol/3.2/parsanol_native.so +0 -0
- data/lib/parsanol/3.3/parsanol_native.so +0 -0
- data/lib/parsanol/3.4/parsanol_native.so +0 -0
- data/lib/parsanol/4.0/parsanol_native.so +0 -0
- data/lib/parsanol/native.rb +15 -0
- data/lib/parsanol/parser.rb +25 -9
- 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: ebb3a9691bf076837a83759aa454fafac939dac4317860789130b1b64d3c303a
|
|
4
|
+
data.tar.gz: 57cd242f5f9fec6f71524855004b69d5fe86e63a85ef6e4ef29ec6b777e017b0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1adb012f0c482a8d0b42b798b120fd922e6106d18d3f90dcd23a5ce53eac747ce7307dbb401a64570a21ad6de080e72d5bcc793a381c558c84031568075824f7
|
|
7
|
+
data.tar.gz: 68778fdd00c2d9a14764d2e628c8ba2e3e77298b2456956a0092bebbb5dd9dad5c9fe837f95c552aa21bbaea82ddd1eb304acdb1e6d3b7c73bd440c03fb21a75
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/lib/parsanol/native.rb
CHANGED
|
@@ -246,6 +246,21 @@ module Parsanol
|
|
|
246
246
|
raise_native_parse_error(e, grammar_json, input)
|
|
247
247
|
end
|
|
248
248
|
|
|
249
|
+
# Prefix-mode parse (partial match allowed): the grammar registers
|
|
250
|
+
# by handle exactly like #parse; the Rust side returns
|
|
251
|
+
# [value, end_pos] with trailing input unconsumed.
|
|
252
|
+
def parse_prefix(grammar, input)
|
|
253
|
+
handle = Parser.grammar_handle(grammar)
|
|
254
|
+
|
|
255
|
+
begin
|
|
256
|
+
value, end_pos = _parse_handle_prefix(handle, input)
|
|
257
|
+
[value, end_pos]
|
|
258
|
+
rescue ArgumentError
|
|
259
|
+
Parser.invalidate_handle(handle)
|
|
260
|
+
_parse_handle_prefix(Parser.grammar_handle(grammar), input)
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
|
|
249
264
|
# Grammar-atom path: registers once and parses by Rust-side handle,
|
|
250
265
|
# so steady-state calls marshal no JSON and copy no input string.
|
|
251
266
|
def parse_atom_grammar(grammar, input)
|
data/lib/parsanol/parser.rb
CHANGED
|
@@ -123,12 +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
|
-
!opts.key?(:reporter)
|
|
128
|
-
:native
|
|
129
|
-
else
|
|
130
|
-
:ruby
|
|
131
|
-
end)
|
|
126
|
+
(Parsanol::Native.available? ? :native : :ruby)
|
|
132
127
|
case mode
|
|
133
128
|
when :ruby
|
|
134
129
|
super(input, opts)
|
|
@@ -218,12 +213,33 @@ module Parsanol
|
|
|
218
213
|
# @return [Object] parse result with Slice objects for position info
|
|
219
214
|
#
|
|
220
215
|
def parse_native(input, opts)
|
|
221
|
-
|
|
222
|
-
Parsanol::Native.parse(root, input)
|
|
223
|
-
else
|
|
216
|
+
unless Parsanol::Native.available?
|
|
224
217
|
Parsanol::Atoms::Base.instance_method(:parse).bind_call(self, input,
|
|
225
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
|
|
226
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)
|
|
227
243
|
end
|
|
228
244
|
|
|
229
245
|
# JSON output mode - returns JSON with position info.
|
data/lib/parsanol/version.rb
CHANGED