parsanol 1.3.21 → 1.3.23

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: 9eb43d37e76e0d2483832c1d9f9d3f32b5ea66304b21c4aa0f1c6cb86731f81c
4
- data.tar.gz: adf4a7e05cddc6b4da594f4ad7fc14df058444ba13bfce9008830bbf96c37c9d
3
+ metadata.gz: '09e8cbdb35f892fc514bed1dbcade3fdbb9a3da37a36e021e75b55c3599da2fd'
4
+ data.tar.gz: 6ccb6c8bdd584e209d2fac37e8ebf1ed5c597546608cc57d93d12c62ba4c6255
5
5
  SHA512:
6
- metadata.gz: 78115ec7794cd6587de1fbee17583027faabd1bc282aeda18d5cd3f26c6e1540d25f2ece6ae701de54405fc4d6fad960f030ee235c43545e70071c794aebe41a
7
- data.tar.gz: 7cdfc3b8811cdd777085aec1333217602dfd0cbb19572e00c4b6b351182963495bc5add5b79b7b91eec7be3c2db61e27638f1aa43c4a591933eb7ed2c2e19c43
6
+ metadata.gz: 4edb7d59e2e1cd68284b49260240d09b3e43d9065508a1b93209d5ed3455b210b611f4e75b7c11bd9af823c0277d26a796252599e59a082b7d34b189e9c541c5
7
+ data.tar.gz: bae0c17ddd24ef7364594a1c82a65a3a8e510ea307f4630e67d6d8c140726153d016d66a9b13ce158c62d123764ab9a4385888689f145ed8b014964ef1073d0f
data/Cargo.lock CHANGED
@@ -253,7 +253,6 @@ 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#9076b51c4a6a4921751fbc59674d3769637b526f"
257
256
  dependencies = [
258
257
  "ahash",
259
258
  "getrandom 0.3.4",
@@ -270,7 +269,6 @@ dependencies = [
270
269
  [[package]]
271
270
  name = "parsanol-derive"
272
271
  version = "0.5.1"
273
- source = "git+https://github.com/parsanol/parsanol-rs?branch=main#9076b51c4a6a4921751fbc59674d3769637b526f"
274
272
  dependencies = [
275
273
  "proc-macro2",
276
274
  "quote",
@@ -202,14 +202,29 @@ module Parsanol
202
202
  # native serializer cannot express (e.g. custom atoms). For
203
203
  # pre-serialized JSON grammars the native message is wrapped in a
204
204
  # Parsanol::ParseFailed directly.
205
+ NATIVE_POS_MARKER = /\n@@parsanol_pos:(\d+)\z/
206
+
205
207
  def raise_native_parse_error(error, grammar, input)
208
+ # Native diagnostics: the Rust tracker reports the deepest
209
+ # failure position and the terminals expected there. Build the
210
+ # cause from that directly — the failure path never needs a
211
+ # reporter reparse. The single interpreter pass below stays only
212
+ # to recover inputs from grammars native cannot express.
213
+ if grammar.respond_to?(:parse) && (m = error.message.match(NATIVE_POS_MARKER))
214
+ source = Parsanol::Source.new(input)
215
+ success, value = grammar.run_with_context(source, nil, true)
216
+ return grammar.finalize_result(value) if success
217
+
218
+ pos = m[1].to_i
219
+ msg = error.message.sub(NATIVE_POS_MARKER, "")
220
+ cause = Parsanol::Cause.new(msg, source, pos)
221
+ raise Parsanol::ParseFailed.new(cause.to_s, cause)
222
+ end
223
+
206
224
  if grammar.respond_to?(:parse)
207
- # One interpreter pass with the error reporter attached covers
208
- # both jobs: a success means the native backend could not
209
- # express the grammar (recover the tree), a failure raises the
210
- # parslet-compatible cause tree. The native backend has
211
- # already failed, so a separate plain attempt first would be a
212
- # wasted parse.
225
+ # No native diagnostics (e.g. incomplete-input errors): one
226
+ # interpreter pass with the reporter attached a success
227
+ # recovers the tree, a failure raises the cause tree.
213
228
  reporter = Parsanol::ErrorReporter::Tree.new
214
229
  source = Parsanol::Source.new(input)
215
230
  success, value = grammar.run_with_context(source, reporter, true)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Parsanol
4
- VERSION = "1.3.21"
4
+ VERSION = "1.3.23"
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.21
4
+ version: 1.3.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.