parsanol 1.3.125 → 1.3.127

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: 9300ad7831ee208e1424f8a65c035db1db73f335bedfa2e3cb77027e7ae048ba
4
- data.tar.gz: ec7e0cc9a73e967e957eba039f52b66e80c63cf53ca4048e69c6303b2d09f23b
3
+ metadata.gz: 546957659860d8cd0f8303884dab80d9b5eda15e7c88a1640af61abb649cbf26
4
+ data.tar.gz: 31b2b2f388f0909aaabcfbedaa1bb28e15c1a361bc1d8191642d7c4d0cbe7941
5
5
  SHA512:
6
- metadata.gz: c57b6923afc7be098b06844fd17fc42957c84ca7829363b8ce90fc04947c64ff7d30d16acef7aa8352f15c2b0b6f406095b6c97acd4aed4806057d4e96c31bf7
7
- data.tar.gz: 200c2f64e60befe15181fbb92735d65428f02e3c01245fc66732da1e38083dfdc5143968d5b86f8d3957d4572c42a74af114eea7e0ce9917abe9379885a43aa9
6
+ metadata.gz: c6241ab7dfabaab19533b55a34e959e01e6492d186aeb456618ed15dea5ac4d17d263c3adfef2cee36190d4511e788be5e89147770c19f53d66bfb024a2eb730
7
+ data.tar.gz: 92827122ae0fa4149ad9df3353e5bce8d5d30a015049a2ebef91b0ba17a2290fba27649c1284a53637c65e18952777e3524ac8edd502959efae5a58abef360e1
data/Cargo.lock CHANGED
@@ -307,9 +307,9 @@ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
307
307
 
308
308
  [[package]]
309
309
  name = "parsanol"
310
- version = "0.19.19"
310
+ version = "0.19.20"
311
311
  source = "registry+https://github.com/rust-lang/crates.io-index"
312
- checksum = "7ec17007676a476ef23db64b69c3bf5b36d741763ac11ced3089b90a96c9a716"
312
+ checksum = "a46c6589eedd0fe3d0defd2511a38eed85fd066ffc9a566c87bfc2c0d4247d16"
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.19.19"
329
+ version = "0.19.20"
330
330
  source = "registry+https://github.com/rust-lang/crates.io-index"
331
- checksum = "fc342af122d8854b8916eaacc6a6c2ad911419c605ea47b74b575c2ca24ab23d"
331
+ checksum = "0a4e3935f53a2b90189756055eb8e9ceef14fb42f62c7a419dce385db57652a7"
332
332
  dependencies = [
333
333
  "proc-macro2",
334
334
  "quote",
@@ -36,10 +36,24 @@ module Parsanol
36
36
  # bound map (parsanol-ruby#413): a capture present in the parse
37
37
  # but bound nowhere is silent data loss, the one case the
38
38
  # binding layer's other checks miss. Absence in the TREE is
39
- # legitimate optionality and never raises.
39
+ # legitimate optionality and never raises. Coverage is checked
40
+ # against every hash key anywhere in the bound map, not just the
41
+ # binding's own leaf: a `(raw)` binding carries its entire
42
+ # subtree, so captures nested inside a raw-bound ancestor are
43
+ # delivered through it (parsanol-ruby#427 — BS 9113 bundled_list).
44
+ bound_keys = {}
45
+ walk_keys = lambda do |node|
46
+ case node
47
+ when Hash
48
+ node.each_key { |key| bound_keys[key.to_sym] = true }
49
+ node.each_value { |value| walk_keys.call(value) }
50
+ when Array then node.each(&walk_keys)
51
+ end
52
+ end
53
+ walk_keys.call(out)
40
54
  lost = bindings.select do |binding|
41
55
  capture = binding["capture"].to_sym
42
- present.include?(capture) && !bound?(out, binding)
56
+ present.include?(capture) && !bound_keys.key?(capture)
43
57
  end
44
58
  unless lost.empty?
45
59
  raise BindError,
@@ -49,21 +63,6 @@ module Parsanol
49
63
  out
50
64
  end
51
65
 
52
- # Did this binding contribute anything to the bound map? Scalars
53
- # bind under their leaf key; array groups bind under their prefix.
54
- def bound?(out, binding)
55
- path = binding["path"].to_s
56
- if path.include?("[]")
57
- prefix = path.split("[]").first.to_sym
58
- rows = out[prefix]
59
- rows.is_a?(Array) && rows.any? do |row|
60
- row.is_a?(Hash) && row.key?(leaf_key(binding))
61
- end
62
- else
63
- out.key?(leaf_key(binding))
64
- end
65
- end
66
-
67
66
  # Canonical test-value form: one equality surface for capture and
68
67
  # example expectations on both sides of the comparison (Slice vs
69
68
  # source literal was comparing heterogeneous types). Terminals
@@ -632,8 +632,8 @@ module Parsanol
632
632
  markers[literal] = node.a.to_sym if literal && !literal.strip.empty?
633
633
  collect.call(@document.rules[node.a]) if @document.rules.key?(node.a)
634
634
  when :alt, :seq then node.a.each { |b| collect.call(b) }
635
- when :rep, :opt, :cap then collect.call(node.a)
636
- when :pred then collect.call(node.b)
635
+ when :rep, :opt then collect.call(node.a)
636
+ when :cap, :pred then collect.call(node.b)
637
637
  end
638
638
  end
639
639
  collect.call(@document.skip_declaration)
@@ -652,7 +652,11 @@ module Parsanol
652
652
  case n.kind
653
653
  when :lit then literal = n.a
654
654
  when :seq, :alt then n.a.each { |c| walk.call(c) unless literal }
655
- when :rep, :opt, :cap, :pred then walk.call(n.a || n.b) unless literal
655
+ # :cap stores the capture NAME in `a` (a plain String) and the
656
+ # captured node in `b`; :pred stores its flag in `a`. Walking
657
+ # `a` on either crashes — descend through `b`.
658
+ when :rep, :opt then walk.call(n.a) unless literal
659
+ when :cap, :pred then walk.call(n.b) unless literal
656
660
  end
657
661
  end
658
662
  walk.call(node)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Parsanol
4
- VERSION = "1.3.125"
4
+ VERSION = "1.3.127"
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.125
4
+ version: 1.3.127
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.