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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82d711217af3f7b64a8507f1a23757c3fa356af7eff8b4a2be3e4e2d8f7c3bc9
4
- data.tar.gz: 422015e3bf2451f6fc9f0472337f7034acafcedc36e1b74ef7f7a1e4539fb5d1
3
+ metadata.gz: 79343c7e73fa4e23d8a16ea8190019ec27c073490a1a792a1647a65febd13ca7
4
+ data.tar.gz: 076b417c7e07f7cb6cd6f546068ba6e55c613d61964aba483920c24f32530872
5
5
  SHA512:
6
- metadata.gz: ee2f9b6944734239897c91b40e18ae5b54b500a881aee51a7635273c8583e7bd04e16a7cd33ab44729eb1e11f22947bc6fa40d269b51d0f1e5ddfcaee67585f9
7
- data.tar.gz: e6075383b069b41761aa2a92fae4cd0bb8aedb6d4326838c67787d37d64b67b6a112030ce1ca4c5f1a7c8a7003888b12f0956c80be9fd44c0be0d590b50bc765
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(_atom)
243
- # For unsupported atom types, create a placeholder
244
- # This will cause a parse error at runtime
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
- "Str" => {
247
- "pattern" => "", # Empty pattern that will never match
256
+ "Ignore" => {
257
+ "atom" => inner_id,
248
258
  },
249
259
  }
250
260
  end
@@ -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
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Parsanol
4
- VERSION = "1.3.25"
4
+ VERSION = "1.3.26"
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.25
4
+ version: 1.3.26
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Ribose Inc.