parsanol 1.3.25-x86_64-linux → 1.3.26-x86_64-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/native/serializer.rb +15 -5
- data/lib/parsanol/native.rb +5 -0
- data/lib/parsanol/parser.rb +18 -1
- 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: 79343c7e73fa4e23d8a16ea8190019ec27c073490a1a792a1647a65febd13ca7
|
|
4
|
+
data.tar.gz: 076b417c7e07f7cb6cd6f546068ba6e55c613d61964aba483920c24f32530872
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d1597921c528f108680b56b5515516e64d706f727c3749541fa8891eb02ba6e63955e4bbafbc45fa53b4eef83b55ef4683efde184d8df48dc71d65b748a8aa85
|
|
7
|
+
data.tar.gz: 4d65d65e226ba3ec09470cd887d847fed844d9f415c22cb206e98fb0412fc84abbfb277b71177b18328c0460d0e01ac21fe7cb71815a7916633d8dccfac655ce
|
|
@@ -63,6 +63,8 @@ module Parsanol
|
|
|
63
63
|
serialize_scope(atom)
|
|
64
64
|
when Parsanol::Atoms::Dynamic
|
|
65
65
|
serialize_dynamic(atom)
|
|
66
|
+
when Parsanol::Atoms::Ignored
|
|
67
|
+
serialize_ignored(atom)
|
|
66
68
|
else
|
|
67
69
|
# Fallback for unknown atom types
|
|
68
70
|
serialize_unknown(atom)
|
|
@@ -239,12 +241,20 @@ module Parsanol
|
|
|
239
241
|
}
|
|
240
242
|
end
|
|
241
243
|
|
|
242
|
-
def serialize_unknown(
|
|
243
|
-
#
|
|
244
|
-
#
|
|
244
|
+
def serialize_unknown(atom)
|
|
245
|
+
# Fail fast at registration (TODO.perf/8 item 4): a never-matching
|
|
246
|
+
# placeholder here used to turn into a parse-time failure that the
|
|
247
|
+
# native tier silently recovered from with a full Ruby reparse.
|
|
248
|
+
raise Parsanol::Native::UnsupportedGrammar,
|
|
249
|
+
"the native backend cannot express #{atom.class} atoms; " \
|
|
250
|
+
"parse this grammar with mode: :ruby"
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
def serialize_ignored(atom)
|
|
254
|
+
inner_id = serialize_atom(atom.wrapped_atom)
|
|
245
255
|
{
|
|
246
|
-
"
|
|
247
|
-
"
|
|
256
|
+
"Ignore" => {
|
|
257
|
+
"atom" => inner_id,
|
|
248
258
|
},
|
|
249
259
|
}
|
|
250
260
|
end
|
data/lib/parsanol/native.rb
CHANGED
|
@@ -10,6 +10,11 @@ require "parsanol/native/batch_decoder"
|
|
|
10
10
|
|
|
11
11
|
module Parsanol
|
|
12
12
|
module Native
|
|
13
|
+
# Raised when a grammar uses atoms the Rust backend cannot express.
|
|
14
|
+
# Failing at registration (TODO.perf/8 item 4) instead of planting a
|
|
15
|
+
# never-matching placeholder that explodes mid-parse.
|
|
16
|
+
class UnsupportedGrammar < ArgumentError; end
|
|
17
|
+
|
|
13
18
|
# ffi-gem cdylib tier: lazy — only loaded when the MRI extension is absent.
|
|
14
19
|
autoload :Ffi, "parsanol/native/ffi"
|
|
15
20
|
# Dynamic-atom callbacks: autoloaded so the serializer's reference
|
data/lib/parsanol/parser.rb
CHANGED
|
@@ -123,7 +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
|
-
(Parsanol::Native.available? ? :native : :ruby)
|
|
126
|
+
(Parsanol::Native.available? && native_expressible? ? :native : :ruby)
|
|
127
127
|
case mode
|
|
128
128
|
when :ruby
|
|
129
129
|
super(input, opts)
|
|
@@ -230,6 +230,23 @@ module Parsanol
|
|
|
230
230
|
raise
|
|
231
231
|
end
|
|
232
232
|
|
|
233
|
+
# Engine selection for the default mode, decided at registration
|
|
234
|
+
# time (never mid-parse): grammars the Rust backend cannot express
|
|
235
|
+
# run on the Ruby engine, announced once per grammar — loud, not a
|
|
236
|
+
# silent parse-time fallback. An explicit mode: :native still raises
|
|
237
|
+
# UnsupportedGrammar from registration.
|
|
238
|
+
def native_expressible?
|
|
239
|
+
Parsanol::Native::Parser.grammar_handle(root)
|
|
240
|
+
true
|
|
241
|
+
rescue Parsanol::Native::UnsupportedGrammar => e
|
|
242
|
+
warned = (@@unsupported_warned ||= {}.compare_by_identity)
|
|
243
|
+
unless warned.key?(root)
|
|
244
|
+
warned[root] = true
|
|
245
|
+
warn "parsanol: parsing with the Ruby engine (#{e.message})"
|
|
246
|
+
end
|
|
247
|
+
false
|
|
248
|
+
end
|
|
249
|
+
|
|
233
250
|
# Feed the native deepest-failure diagnostics to a user-supplied
|
|
234
251
|
# reporter: one err_at event carrying the cause the native engine
|
|
235
252
|
# already produced. The full per-atom event stream of the Ruby
|
data/lib/parsanol/version.rb
CHANGED