parsanol 1.3.7 → 1.3.9

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: 39ce7a8554166a92125c5336c0f7e7f3c9011791cd0c366c037f74d6d9b73a6e
4
- data.tar.gz: b33ecab1a711628c5fc4135705a5d21e7af53e48b5472fb60925664e15ce9688
3
+ metadata.gz: eb19c18264a1e1c6e26dfb2bab0ff9c9fd005f631423b918240a321e2470848a
4
+ data.tar.gz: 49af7d190c09e38ec7c46a168e0f2a20bbbfd4afe1d63b006becbe20b69e14f5
5
5
  SHA512:
6
- metadata.gz: da8b989aba1451e3bcbe5a922eef7a481614e098a5e1095a5f9a8d8d6f6d8ac46fbcf7e6fe727fc06c40753d80df1fb2731d54bdf66f96d5441aaf284eb6d2bd
7
- data.tar.gz: bbab802f416f69dfb61bd856549a3755b87923fb0944d9fcc06b96466ebe8cad8ac51515086b5bd40b7eb04bc3c8f813a7f6c109a9931952fc9d70c21f0304d8
6
+ metadata.gz: 58f02929ffcffb52c15fad2545f9fb36076e8396ec04ca90ea5c1d1a8186b5cd242b11fc415127906bccf724d3da3f175ad67c2b54ced828ad61a286802e6648
7
+ data.tar.gz: 3581460ba7dd3cd81634ab19fbb405c6220ac6d0084b0c9d1d13a8232d5d700346c560a76b6eaf610ff30c967b506c10fcb87879d4df46a18c2a2615feac261f
data/Cargo.lock CHANGED
@@ -206,15 +206,15 @@ dependencies = [
206
206
 
207
207
  [[package]]
208
208
  name = "itoa"
209
- version = "1.0.17"
209
+ version = "1.0.18"
210
210
  source = "registry+https://github.com/rust-lang/crates.io-index"
211
- checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2"
211
+ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
212
212
 
213
213
  [[package]]
214
214
  name = "js-sys"
215
- version = "0.3.91"
215
+ version = "0.3.92"
216
216
  source = "registry+https://github.com/rust-lang/crates.io-index"
217
- checksum = "b49715b7073f385ba4bc528e5747d02e66cb39c6146efb66b781f131f0fb399c"
217
+ checksum = "cc4c90f45aa2e6eacbe8645f77fdea542ac97a494bcd117a67df9ff4d611f995"
218
218
  dependencies = [
219
219
  "once_cell",
220
220
  "wasm-bindgen",
@@ -305,7 +305,8 @@ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
305
305
 
306
306
  [[package]]
307
307
  name = "parsanol"
308
- version = "0.4.1"
308
+ version = "0.5.0"
309
+ source = "git+https://github.com/parsanol/parsanol-rs?branch=main#99a5a2f3fa292ce506cda9ea7a6d5403abd5e8a0"
309
310
  dependencies = [
310
311
  "ahash",
311
312
  "getrandom 0.3.4",
@@ -321,7 +322,8 @@ dependencies = [
321
322
 
322
323
  [[package]]
323
324
  name = "parsanol-derive"
324
- version = "0.4.1"
325
+ version = "0.5.0"
326
+ source = "git+https://github.com/parsanol/parsanol-rs?branch=main#99a5a2f3fa292ce506cda9ea7a6d5403abd5e8a0"
325
327
  dependencies = [
326
328
  "proc-macro2",
327
329
  "quote",
@@ -437,9 +439,9 @@ checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a"
437
439
 
438
440
  [[package]]
439
441
  name = "rustc-hash"
440
- version = "2.1.1"
442
+ version = "2.1.2"
441
443
  source = "registry+https://github.com/rust-lang/crates.io-index"
442
- checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
444
+ checksum = "94300abf3f1ae2e2b8ffb7b58043de3d399c73fa6f4b73826402a5c457614dbe"
443
445
 
444
446
  [[package]]
445
447
  name = "rustversion"
@@ -563,9 +565,9 @@ dependencies = [
563
565
 
564
566
  [[package]]
565
567
  name = "wasm-bindgen"
566
- version = "0.2.114"
568
+ version = "0.2.115"
567
569
  source = "registry+https://github.com/rust-lang/crates.io-index"
568
- checksum = "6532f9a5c1ece3798cb1c2cfdba640b9b3ba884f5db45973a6f442510a87d38e"
570
+ checksum = "6523d69017b7633e396a89c5efab138161ed5aafcbc8d3e5c5a42ae38f50495a"
569
571
  dependencies = [
570
572
  "cfg-if",
571
573
  "once_cell",
@@ -576,9 +578,9 @@ dependencies = [
576
578
 
577
579
  [[package]]
578
580
  name = "wasm-bindgen-macro"
579
- version = "0.2.114"
581
+ version = "0.2.115"
580
582
  source = "registry+https://github.com/rust-lang/crates.io-index"
581
- checksum = "18a2d50fcf105fb33bb15f00e7a77b772945a2ee45dcf454961fd843e74c18e6"
583
+ checksum = "4e3a6c758eb2f701ed3d052ff5737f5bfe6614326ea7f3bbac7156192dc32e67"
582
584
  dependencies = [
583
585
  "quote",
584
586
  "wasm-bindgen-macro-support",
@@ -586,9 +588,9 @@ dependencies = [
586
588
 
587
589
  [[package]]
588
590
  name = "wasm-bindgen-macro-support"
589
- version = "0.2.114"
591
+ version = "0.2.115"
590
592
  source = "registry+https://github.com/rust-lang/crates.io-index"
591
- checksum = "03ce4caeaac547cdf713d280eda22a730824dd11e6b8c3ca9e42247b25c631e3"
593
+ checksum = "921de2737904886b52bcbb237301552d05969a6f9c40d261eb0533c8b055fedf"
592
594
  dependencies = [
593
595
  "bumpalo",
594
596
  "proc-macro2",
@@ -599,9 +601,9 @@ dependencies = [
599
601
 
600
602
  [[package]]
601
603
  name = "wasm-bindgen-shared"
602
- version = "0.2.114"
604
+ version = "0.2.115"
603
605
  source = "registry+https://github.com/rust-lang/crates.io-index"
604
- checksum = "75a326b8c223ee17883a4251907455a2431acc2791c98c26279376490c378c16"
606
+ checksum = "a93e946af942b58934c604527337bad9ae33ba1d5c6900bbb41c2c07c2364a93"
605
607
  dependencies = [
606
608
  "unicode-ident",
607
609
  ]
@@ -736,18 +738,18 @@ dependencies = [
736
738
 
737
739
  [[package]]
738
740
  name = "zerocopy"
739
- version = "0.8.42"
741
+ version = "0.8.48"
740
742
  source = "registry+https://github.com/rust-lang/crates.io-index"
741
- checksum = "f2578b716f8a7a858b7f02d5bd870c14bf4ddbbcf3a4c05414ba6503640505e3"
743
+ checksum = "eed437bf9d6692032087e337407a86f04cd8d6a16a37199ed57949d415bd68e9"
742
744
  dependencies = [
743
745
  "zerocopy-derive",
744
746
  ]
745
747
 
746
748
  [[package]]
747
749
  name = "zerocopy-derive"
748
- version = "0.8.42"
750
+ version = "0.8.48"
749
751
  source = "registry+https://github.com/rust-lang/crates.io-index"
750
- checksum = "7e6cc098ea4d3bd6246687de65af3f920c430e236bee1e3bf2e441463f08a02f"
752
+ checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4"
751
753
  dependencies = [
752
754
  "proc-macro2",
753
755
  "quote",
@@ -28,7 +28,7 @@ rb-sys = { version = "0.9.124", features = ["global-allocator"] }
28
28
  magnus = { version = "0.9" }
29
29
 
30
30
  # parsanol parser library (from git for latest features)
31
- parsanol = { git = "https://github.com/parsanol/parsanol-rs", rev = "3eda2c0", features = ["ruby"] }
31
+ parsanol = { git = "https://github.com/parsanol/parsanol-rs", branch = "main", features = ["ruby"] }
32
32
 
33
33
  # Logging
34
34
  log = "0.4"
@@ -323,9 +323,26 @@ module Parsanol
323
323
  all_items_are_hashes = non_hash_items.empty?
324
324
 
325
325
  if all_items_are_hashes
326
- # Merge all inner hashes into merged_hash
327
- item.each do |sub_item|
328
- merged_hash.merge!(sub_item) if sub_item.is_a?(Hash)
326
+ # Check if merging would overwrite existing keys in merged_hash.
327
+ # If so, this is a repetition pattern (item >> (sep >> item).repeat)
328
+ # and should be kept as array, not merged.
329
+ # Example: merged_hash={namedTypeOrRename: A}, array=[{namedTypeOrRename: B}]
330
+ # → should produce [{namedTypeOrRename: A}, {namedTypeOrRename: B}]
331
+ existing_keys = merged_hash.keys
332
+ shares_keys = item.any? do |sub_item|
333
+ sub_item.is_a?(Hash) && sub_item.keys.intersect?(existing_keys)
334
+ end
335
+
336
+ if shares_keys
337
+ has_non_empty_array = true
338
+ item.each do |sub_item|
339
+ hash_count += 1 if sub_item.is_a?(Hash)
340
+ end
341
+ total_items += 1
342
+ else
343
+ item.each do |sub_item|
344
+ merged_hash.merge!(sub_item) if sub_item.is_a?(Hash)
345
+ end
329
346
  end
330
347
  else
331
348
  # Non-empty repetition with non-hash items - mark that we should keep as array
@@ -57,6 +57,27 @@ module Parsanol
57
57
  grammar_atom)
58
58
  end
59
59
 
60
+ # Memory-bounded parsing without packrat cache.
61
+ #
62
+ # This creates a fresh arena and empty cache per call, bounding memory
63
+ # to AST size rather than input × atoms. Use for large files.
64
+ #
65
+ # @param grammar [Parsanol::Atoms::Base] Ruby grammar definition
66
+ # @param input [String] Input string to parse
67
+ # @return [Hash, Array, Parsanol::Slice] Transformed AST
68
+ def parse_fresh(grammar, input)
69
+ raise LoadError, "Native parser not available" unless available?
70
+
71
+ grammar_json = if grammar.is_a?(String)
72
+ grammar
73
+ else
74
+ Parser.serialize_grammar(grammar)
75
+ end
76
+
77
+ raw_ast = _parse_fresh_raw(grammar_json, input)
78
+ BatchDecoder.decode_and_flatten(raw_ast, input, Parsanol::Slice, grammar)
79
+ end
80
+
60
81
  # Parse and return RAW AST without transformation.
61
82
  #
62
83
  # This returns the raw Parslet intermediate format before any transformation.
@@ -67,6 +67,10 @@ module Parsanol
67
67
 
68
68
  alias length size
69
69
 
70
+ def empty?
71
+ content.empty?
72
+ end
73
+
70
74
  def +(other)
71
75
  self.class.new(@byte_position, content + other.to_s, @input)
72
76
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Parsanol
4
- VERSION = "1.3.7"
4
+ VERSION = "1.3.9"
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.7
4
+ version: 1.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.