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 +4 -4
- data/Cargo.lock +22 -20
- data/ext/parsanol_native/Cargo.toml +1 -1
- data/lib/parsanol/native/transformer.rb +20 -3
- data/lib/parsanol/native.rb +21 -0
- data/lib/parsanol/slice.rb +4 -0
- data/lib/parsanol/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eb19c18264a1e1c6e26dfb2bab0ff9c9fd005f631423b918240a321e2470848a
|
|
4
|
+
data.tar.gz: 49af7d190c09e38ec7c46a168e0f2a20bbbfd4afe1d63b006becbe20b69e14f5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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.
|
|
209
|
+
version = "1.0.18"
|
|
210
210
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
211
|
-
checksum = "
|
|
211
|
+
checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
|
|
212
212
|
|
|
213
213
|
[[package]]
|
|
214
214
|
name = "js-sys"
|
|
215
|
-
version = "0.3.
|
|
215
|
+
version = "0.3.92"
|
|
216
216
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
217
|
-
checksum = "
|
|
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.
|
|
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.
|
|
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.
|
|
442
|
+
version = "2.1.2"
|
|
441
443
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
442
|
-
checksum = "
|
|
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.
|
|
568
|
+
version = "0.2.115"
|
|
567
569
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
568
|
-
checksum = "
|
|
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.
|
|
581
|
+
version = "0.2.115"
|
|
580
582
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
581
|
-
checksum = "
|
|
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.
|
|
591
|
+
version = "0.2.115"
|
|
590
592
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
591
|
-
checksum = "
|
|
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.
|
|
604
|
+
version = "0.2.115"
|
|
603
605
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
604
|
-
checksum = "
|
|
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.
|
|
741
|
+
version = "0.8.48"
|
|
740
742
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
741
|
-
checksum = "
|
|
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.
|
|
750
|
+
version = "0.8.48"
|
|
749
751
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
750
|
-
checksum = "
|
|
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",
|
|
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
|
-
#
|
|
327
|
-
item
|
|
328
|
-
|
|
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
|
data/lib/parsanol/native.rb
CHANGED
|
@@ -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.
|
data/lib/parsanol/slice.rb
CHANGED
data/lib/parsanol/version.rb
CHANGED