parsanol 1.3.23 → 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: '09e8cbdb35f892fc514bed1dbcade3fdbb9a3da37a36e021e75b55c3599da2fd'
4
- data.tar.gz: 6ccb6c8bdd584e209d2fac37e8ebf1ed5c597546608cc57d93d12c62ba4c6255
3
+ metadata.gz: 51ea4c7c7fd78c075837c89b1a493bdf30a568039b62f2769053de5f0b04e96c
4
+ data.tar.gz: a89687b9944d96244ec0b9e157c451af1987e717d71b7f7ffa557dcf5ecc9e82
5
5
  SHA512:
6
- metadata.gz: 4edb7d59e2e1cd68284b49260240d09b3e43d9065508a1b93209d5ed3455b210b611f4e75b7c11bd9af823c0277d26a796252599e59a082b7d34b189e9c541c5
7
- data.tar.gz: bae0c17ddd24ef7364594a1c82a65a3a8e510ea307f4630e67d6d8c140726153d016d66a9b13ce158c62d123764ab9a4385888689f145ed8b014964ef1073d0f
6
+ metadata.gz: f5cbfc62118378137cd8db8fda585067d33f9e6471506e38d504afba8367cd6ba64d5b337c967a38e2ac6019a8acc61c1436cf7735bee6e00182fbe9f2ea3890
7
+ data.tar.gz: a1389dfca0a282a1530a3fa5d0b6de8e02f513b6f2cdc4fd037c4987cf687538b64ee3168d7f9f8d1f0468bd43899176eb8338f941ebf3d83c453ba4539bea34
data/Cargo.lock CHANGED
@@ -253,6 +253,7 @@ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
253
253
  [[package]]
254
254
  name = "parsanol"
255
255
  version = "0.5.1"
256
+ source = "git+https://github.com/parsanol/parsanol-rs?branch=main#0191b5c95ae0808957bd771a68387599f488cb61"
256
257
  dependencies = [
257
258
  "ahash",
258
259
  "getrandom 0.3.4",
@@ -269,6 +270,7 @@ dependencies = [
269
270
  [[package]]
270
271
  name = "parsanol-derive"
271
272
  version = "0.5.1"
273
+ source = "git+https://github.com/parsanol/parsanol-rs?branch=main#0191b5c95ae0808957bd771a68387599f488cb61"
272
274
  dependencies = [
273
275
  "proc-macro2",
274
276
  "quote",
@@ -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)
@@ -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
- (if Parsanol::Native.available? && !opts.key?(:prefix) &&
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
- if Parsanol::Native.available?
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.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Parsanol
4
- VERSION = "1.3.23"
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.23
4
+ version: 1.3.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.