parsanol 1.3.77 → 1.3.78

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: d50458b2aaf5e7227e08f447b64dcc2197fd3df69e02ad7d9c332f87fdad15ec
4
- data.tar.gz: 07e542379ad8ffaf5a9c0c317c88f8f2b1a3f9c9bff9d1b54983b8e6bbb70d14
3
+ metadata.gz: 8b7c210627fda0c572855efe7f2e27930aff2e01f632de082abeb68dba5a99f7
4
+ data.tar.gz: e6bcb584fe1de6cb62f35273980dfe78e8e24688e76ba089a734606338fe94b6
5
5
  SHA512:
6
- metadata.gz: 4be52cd42ea4ad9773e0d7a0e8bcf718cd485c880594291fcf4c798255d74c1619ed238a82ca81d83f2b1a74392ffb384583e190a2a6a308ae93c1b38cd425ba
7
- data.tar.gz: 1160ef2ee557c591c7c28894bf24a59570e1ba9f565744cb5cb839d7f33af59a1deeae1ef1906c1211d1cc1fe9c388c0f16e16d4e0aa003442fa15bff74c2c97
6
+ metadata.gz: 49caa14b1f70ecefe02e75e44f572823613f30aabcfcfeb21b9477358cfb20fff09823ff6f2497c90353866de94af3c571072df859ecad702cfb532252547238
7
+ data.tar.gz: 6822401276fc2af955631834129ee5d75ffb64736f76d5719cba1180139d56a778fe8fad599ef59e8ab73cc634190644b4f148c808e1d92ff9065ed47ec05631
data/Cargo.lock CHANGED
@@ -307,9 +307,9 @@ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
307
307
 
308
308
  [[package]]
309
309
  name = "parsanol"
310
- version = "0.17.0"
310
+ version = "0.17.1"
311
311
  source = "registry+https://github.com/rust-lang/crates.io-index"
312
- checksum = "0a96694c55219bc77b62cc838883850952ad4f883cca10c11312a76a380da58d"
312
+ checksum = "170442a26c6a0b5ac25fbdb9c249dbaee821a2d364d4a42219c32af11f008b3d"
313
313
  dependencies = [
314
314
  "ahash",
315
315
  "getrandom 0.3.4",
@@ -326,9 +326,9 @@ dependencies = [
326
326
 
327
327
  [[package]]
328
328
  name = "parsanol-derive"
329
- version = "0.17.0"
329
+ version = "0.17.1"
330
330
  source = "registry+https://github.com/rust-lang/crates.io-index"
331
- checksum = "07917f2daf91d216927237719ae459f068dd29bef53669a2d12dc4b28ad6a1d9"
331
+ checksum = "c3567bd641f8a18ee4a1e0339d9e1d0bd804764c1d813efc25b8fd7f24ed8ad3"
332
332
  dependencies = [
333
333
  "proc-macro2",
334
334
  "quote",
@@ -13,4 +13,4 @@ doc = false
13
13
 
14
14
  [dependencies]
15
15
  # 0.17.0 carries LookSpec + the widened opaque writeback
16
- parsanol = { version = "0.17.0" }
16
+ parsanol = { version = "0.17.1" }
@@ -32,7 +32,7 @@ magnus = { version = "0.9" }
32
32
  # parsanol parser library (crates.io; 0.17.0 carries the LookSpec regex
33
33
  # lookbehind (rs#163 gap 1) and the widened opaque writeback: the
34
34
  # lazy-continuation fix, parsanol-ruby#160)
35
- parsanol = { version = "0.17.0", features = ["ruby"] }
35
+ parsanol = { version = "0.17.1", features = ["ruby"] }
36
36
 
37
37
  # Logging
38
38
  log = "0.4"
@@ -132,6 +132,12 @@ module Parsanol
132
132
  #
133
133
  def invoke_from_rust(callback_id, context)
134
134
  block = @mutex.synchronize { @callbacks[callback_id]&.dig(:block) }
135
+ if ENV["PARSANOL_INVOKE_TRACE"]
136
+ cont = context[:captures][:cont]
137
+ warn "INVOKE id=#{callback_id} pos=#{context[:pos]} " \
138
+ "block=#{context[:captures][:block].inspect} " \
139
+ "cont=#{cont.class}@#{cont.object_id}"
140
+ end
135
141
  return nil unless block
136
142
 
137
143
  # Build DynamicContext from hash
@@ -142,18 +148,33 @@ module Parsanol
142
148
  )
143
149
 
144
150
  # Call the block. Parslet-canonical blocks take two arguments
145
- # (source, context): pass the restricted context for both so
146
- # either convention works (GH-76). Captures are read-only
147
- # snapshots of the engine state; write-dependent dispatch must
148
- # run on mode: :ruby.
151
+ # (source, context). The source is a REAL Parsanol::Source
152
+ # positioned at the dispatch point: blocks that read source
153
+ # state (bytepos, line_and_column — the lazy-continuation
154
+ # guards do) previously got the context wrapper for both
155
+ # args and raised NoMethodError, which the bridge turned
156
+ # into a silent dispatch failure (rs#165). Consumption
157
+ # side-effects stay local to the call: the resolved fragment
158
+ # is the parse.
149
159
  result = if block.arity == 2
150
- block.call(ctx, ctx)
160
+ dispatch_source = Parsanol::Source.new(context[:input])
161
+ dispatch_source.bytepos = context[:pos]
162
+ block.call(dispatch_source, ctx)
151
163
  else
152
164
  block.call(ctx)
153
165
  end
154
166
 
155
167
  return nil unless result
156
168
 
169
+ if ENV["PARSANOL_FRAG_TRACE"]
170
+ begin
171
+ json = result.to_atom_json
172
+ warn "FRAG id=#{callback_id} json=#{json[0, 120]}"
173
+ rescue StandardError => e
174
+ warn "FRAG id=#{callback_id} RAISE #{e.class}: #{e.message[0, 140]}"
175
+ end
176
+ end
177
+
157
178
  # Capture-write contract (GH-80): return the atom and the
158
179
  # post-call captures hash; the Rust bridge diffs it against
159
180
  # the seeded values and propagates the block's writes
@@ -121,6 +121,13 @@ module Parsanol
121
121
  }
122
122
  end
123
123
 
124
+ # Public (rs#166): the VM program cache shares compiled
125
+ # programs across fresh parser instances keyed on this —
126
+ # the same disambiguator the grammar cache uses.
127
+ def public_structure_hash(atom)
128
+ grammar_structure_hash(atom)
129
+ end
130
+
124
131
  private
125
132
 
126
133
  def grammar_cache_key(root_atom)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Parsanol
4
- VERSION = "1.3.77"
4
+ VERSION = "1.3.78"
5
5
  end
data/lib/parsanol/vm.rb CHANGED
@@ -202,6 +202,10 @@ module Parsanol
202
202
  # starts memoized on its very first parse (fresh parser instances
203
203
  # included — the seed is recomputed at every compile), so the
204
204
  # cold-start never pays the doomed unmemoized exploration.
205
+ # rs#166: proneness rides the structure-hash share as a bool —
206
+ # a later identical-structure grammar inherits the seed instead
207
+ # of running its cold start unmemoized because compilation was
208
+ # skipped entirely.
205
209
  if compiler.backtracking_prone
206
210
  (@heavy ||= {}.compare_by_identity)[root] = true
207
211
  trim_cache(@heavy)
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.77
4
+ version: 1.3.78
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.