parsanol 1.3.8-x86_64-linux → 1.3.9-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: 73478e020a8c4de496b3e9844d04d073776025fbca58718280d7830301727249
4
- data.tar.gz: f4b44dfea49a3b2f1f772957630a98e064792bcd636d41b23de96d80e71dcea3
3
+ metadata.gz: 920fc5933c1c669e58313a67ca15069071d3cc8bebd7fb252e6436d1954f958c
4
+ data.tar.gz: 667c599072cafd75f3c6fa2922c6bb4039694c21524ecb288aecd27e665ed761
5
5
  SHA512:
6
- metadata.gz: b736a4e97c49595aaafca6f5440d03a1d5a74e6b021aabf0820a6d6998c8968a3430f231d6a93d1a8e6bd44924304b0704c5f56abef8045c862326866b815de5
7
- data.tar.gz: e7489c76599a161428fe25db3ac92e3fa58d4f3d5132a725c7ea0909179c3474187d931a90050a3033424d2ce8cdf2aa2096aad13fc35051b2e9f2f118dfc2ae
6
+ metadata.gz: 58e47f46067ceb15b7310286ac69234e17b0b3a87ea5ae03f4bbbd9db3bab257c4269e917fe676727f9b4751d1e83c7ff44e72241bfc451275f26d53b73a7930
7
+ data.tar.gz: 83d3455b48b81b847c5b5bdfbbb40e1d42587cb0a0f34bc27748ab755ed9f9c221f4cb5eef51dffe2676bf52661dc1c1ca2e938ccb00f731811b6c5fb6f5f956
Binary file
Binary file
Binary file
Binary file
@@ -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.8"
4
+ VERSION = "1.3.9"
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.8
4
+ version: 1.3.9
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-03-26 00:00:00.000000000 Z
11
+ date: 2026-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake