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 +4 -4
- data/Cargo.lock +0 -2
- data/lib/parsanol/native.rb +21 -6
- 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: '09e8cbdb35f892fc514bed1dbcade3fdbb9a3da37a36e021e75b55c3599da2fd'
|
|
4
|
+
data.tar.gz: 6ccb6c8bdd584e209d2fac37e8ebf1ed5c597546608cc57d93d12c62ba4c6255
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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",
|
data/lib/parsanol/native.rb
CHANGED
|
@@ -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
|
-
#
|
|
208
|
-
#
|
|
209
|
-
#
|
|
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)
|
data/lib/parsanol/version.rb
CHANGED