parsanol 1.3.93-aarch64-linux → 1.3.94-aarch64-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: 84b446bd2c3e105bdacb0a2084bc7740f7ef939a9778bacd0317aafeeae0451d
4
- data.tar.gz: 11100a5767c58e50567f1a59de70870b77c264428b8a52783a69b3bf8cd90631
3
+ metadata.gz: 9e0c1efcdfb93af513ae908d45c90b6f2d6c42015fb643e474bffbb37ae39316
4
+ data.tar.gz: 86ad51bce683affc8b5b94426151bf56694c41fa87b91c9e56c98b7e801c1efc
5
5
  SHA512:
6
- metadata.gz: ef6c1ac2895b7a7ac30fe39b57d322744f9b662a4dc8e979fba655fde30c80b7e29ed69599fc64a2e754a9ec94cf670cfcc415e75a3df3f20c33602995305992
7
- data.tar.gz: 0b8e9efb06dbc30e86d912d603646b5b15f26fb5352e65f0c4dbc8bec51a533a0b66338b8cba1a32c3acbc3dca1a85e2677af3a88ea77e19d10f33b7f86a14cd
6
+ metadata.gz: 1b5aea575e016166e39822daa41c36c9ef80da76c121610231c6c359071d31362f4e5ed0efd24b4278d8db896ff70f7702e71cbfdf5d4ff4e2f36469222e5085
7
+ data.tar.gz: b89fe36dabaa496b63c7bb220bd5c40c5698fbc3ecac8329359d53d2319ec56df283accc410e15fcfe14d8e0729cbfd876e58c6de382079ce716f1f94e795725
@@ -152,12 +152,16 @@ module Parsanol
152
152
 
153
153
  # Run an external test list (suite files yield Document::Test
154
154
  # structs; embedded tests are artifact-shaped hashes).
155
- def run_test_list(tests, mode: :native)
155
+ # parse_with overrides how the input is turned into a shape
156
+ # (the envelope self-test drives the baked grammar JSON natively
157
+ # instead of root_atom's source rebuild); bindings and
158
+ # expectations still flow through the standard surface.
159
+ def run_test_list(tests, mode: :native, parse_with: nil)
156
160
  tests.filter_map do |test|
157
161
  hash = test.is_a?(Document::Test) ? test_to_hash(test) : test
158
162
  entry_name = hash["entry"] || entries.first
159
163
  begin
160
- shape = parse(entry_name, hash["input"], mode: mode)
164
+ shape = parse_with ? parse_with.call(hash["input"]) : parse(entry_name, hash["input"], mode: mode)
161
165
  case hash["kind"]
162
166
  when "reject"
163
167
  "test #{hash['input'].inspect}: expected the input to be rejected"
@@ -76,9 +76,40 @@ module Parsanol
76
76
  raise CompileError, failures.join("\n") unless failures.empty?
77
77
 
78
78
  envelope = build_envelope
79
+ failures = self.class.self_test(envelope, tables_dir: @tables_dir)
80
+ raise CompileError, failures.join("\n") unless failures.empty?
81
+
79
82
  Result.new(@atom_cache, @warnings, envelope)
80
83
  end
81
84
 
85
+ # Bake-time self-test (parsanol-ruby#223): replay the grammar's
86
+ # embedded tests against the BAKED ENVELOPE atom JSON, not the
87
+ # source this process just compiled. A bake that drops or
88
+ # rewrites a member (the 1.3.91 ordered-choice class) makes the
89
+ # envelope disagree with its own tests, and every Ruby-side
90
+ # parse path would mask it — root_atom rebuilds from the
91
+ # embedded source, so only the native engine's JSON registration
92
+ # executes the atom graph a wasm/rs consumer actually runs.
93
+ # Skips (empty) when the native engine is unavailable; the CI
94
+ # and release bakes always have it. Returns failure descriptions.
95
+ def self.self_test(envelope, tables_dir: nil)
96
+ tests = envelope["tests"].to_a
97
+ return [] if tests.empty?
98
+ return [] unless Native.available?
99
+
100
+ artifact = Artifact.from_json(JSON.generate(envelope), tables_dir: tables_dir)
101
+ default = envelope["default_entry"] || artifact.entries.first
102
+ grammars = {}
103
+ tests.filter_map do |test|
104
+ entry = test["entry"] || default
105
+ grammar_json = (grammars[entry] ||= JSON.generate(artifact.entry(entry)["grammar"]))
106
+ artifact.run_test_list(
107
+ [test],
108
+ parse_with: ->(input) { Native.parse_json_grammar(grammar_json, input) },
109
+ )
110
+ end.flatten
111
+ end
112
+
82
113
  def resolve_custom(name)
83
114
  class_name = @document.customs.fetch(name)
84
115
  klass = Object.const_get(class_name)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Parsanol
4
- VERSION = "1.3.93"
4
+ VERSION = "1.3.94"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parsanol
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.93
4
+ version: 1.3.94
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-10-16 00:00:00.000000000 Z
11
+ date: 2026-10-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A small Ruby library for constructing parsers in the PEG (Parsing Expression
14
14
  Grammar) fashion. Parsanol provides Parslet-compatible API with additional features