parsanol 1.3.8 → 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 -22
- 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,8 +305,8 @@ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
|
305
305
|
|
|
306
306
|
[[package]]
|
|
307
307
|
name = "parsanol"
|
|
308
|
-
version = "0.
|
|
309
|
-
source = "git+https://github.com/parsanol/parsanol-rs?
|
|
308
|
+
version = "0.5.0"
|
|
309
|
+
source = "git+https://github.com/parsanol/parsanol-rs?branch=main#99a5a2f3fa292ce506cda9ea7a6d5403abd5e8a0"
|
|
310
310
|
dependencies = [
|
|
311
311
|
"ahash",
|
|
312
312
|
"getrandom 0.3.4",
|
|
@@ -322,8 +322,8 @@ dependencies = [
|
|
|
322
322
|
|
|
323
323
|
[[package]]
|
|
324
324
|
name = "parsanol-derive"
|
|
325
|
-
version = "0.
|
|
326
|
-
source = "git+https://github.com/parsanol/parsanol-rs?
|
|
325
|
+
version = "0.5.0"
|
|
326
|
+
source = "git+https://github.com/parsanol/parsanol-rs?branch=main#99a5a2f3fa292ce506cda9ea7a6d5403abd5e8a0"
|
|
327
327
|
dependencies = [
|
|
328
328
|
"proc-macro2",
|
|
329
329
|
"quote",
|
|
@@ -439,9 +439,9 @@ checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a"
|
|
|
439
439
|
|
|
440
440
|
[[package]]
|
|
441
441
|
name = "rustc-hash"
|
|
442
|
-
version = "2.1.
|
|
442
|
+
version = "2.1.2"
|
|
443
443
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
444
|
-
checksum = "
|
|
444
|
+
checksum = "94300abf3f1ae2e2b8ffb7b58043de3d399c73fa6f4b73826402a5c457614dbe"
|
|
445
445
|
|
|
446
446
|
[[package]]
|
|
447
447
|
name = "rustversion"
|
|
@@ -565,9 +565,9 @@ dependencies = [
|
|
|
565
565
|
|
|
566
566
|
[[package]]
|
|
567
567
|
name = "wasm-bindgen"
|
|
568
|
-
version = "0.2.
|
|
568
|
+
version = "0.2.115"
|
|
569
569
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
570
|
-
checksum = "
|
|
570
|
+
checksum = "6523d69017b7633e396a89c5efab138161ed5aafcbc8d3e5c5a42ae38f50495a"
|
|
571
571
|
dependencies = [
|
|
572
572
|
"cfg-if",
|
|
573
573
|
"once_cell",
|
|
@@ -578,9 +578,9 @@ dependencies = [
|
|
|
578
578
|
|
|
579
579
|
[[package]]
|
|
580
580
|
name = "wasm-bindgen-macro"
|
|
581
|
-
version = "0.2.
|
|
581
|
+
version = "0.2.115"
|
|
582
582
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
583
|
-
checksum = "
|
|
583
|
+
checksum = "4e3a6c758eb2f701ed3d052ff5737f5bfe6614326ea7f3bbac7156192dc32e67"
|
|
584
584
|
dependencies = [
|
|
585
585
|
"quote",
|
|
586
586
|
"wasm-bindgen-macro-support",
|
|
@@ -588,9 +588,9 @@ dependencies = [
|
|
|
588
588
|
|
|
589
589
|
[[package]]
|
|
590
590
|
name = "wasm-bindgen-macro-support"
|
|
591
|
-
version = "0.2.
|
|
591
|
+
version = "0.2.115"
|
|
592
592
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
593
|
-
checksum = "
|
|
593
|
+
checksum = "921de2737904886b52bcbb237301552d05969a6f9c40d261eb0533c8b055fedf"
|
|
594
594
|
dependencies = [
|
|
595
595
|
"bumpalo",
|
|
596
596
|
"proc-macro2",
|
|
@@ -601,9 +601,9 @@ dependencies = [
|
|
|
601
601
|
|
|
602
602
|
[[package]]
|
|
603
603
|
name = "wasm-bindgen-shared"
|
|
604
|
-
version = "0.2.
|
|
604
|
+
version = "0.2.115"
|
|
605
605
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
606
|
-
checksum = "
|
|
606
|
+
checksum = "a93e946af942b58934c604527337bad9ae33ba1d5c6900bbb41c2c07c2364a93"
|
|
607
607
|
dependencies = [
|
|
608
608
|
"unicode-ident",
|
|
609
609
|
]
|
|
@@ -738,18 +738,18 @@ dependencies = [
|
|
|
738
738
|
|
|
739
739
|
[[package]]
|
|
740
740
|
name = "zerocopy"
|
|
741
|
-
version = "0.8.
|
|
741
|
+
version = "0.8.48"
|
|
742
742
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
743
|
-
checksum = "
|
|
743
|
+
checksum = "eed437bf9d6692032087e337407a86f04cd8d6a16a37199ed57949d415bd68e9"
|
|
744
744
|
dependencies = [
|
|
745
745
|
"zerocopy-derive",
|
|
746
746
|
]
|
|
747
747
|
|
|
748
748
|
[[package]]
|
|
749
749
|
name = "zerocopy-derive"
|
|
750
|
-
version = "0.8.
|
|
750
|
+
version = "0.8.48"
|
|
751
751
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
752
|
-
checksum = "
|
|
752
|
+
checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4"
|
|
753
753
|
dependencies = [
|
|
754
754
|
"proc-macro2",
|
|
755
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