parsanol 1.3.10 → 1.3.12
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 +90 -279
- data/Cargo.toml +6 -3
- data/lib/parsanol/atoms/context.rb +33 -17
- data/lib/parsanol/native/serializer.rb +1 -0
- data/lib/parsanol/native/transformer.rb +24 -9
- data/lib/parsanol/native.rb +26 -2
- data/lib/parsanol/parser.rb +12 -3
- data/lib/parsanol/pools/buffer_pool.rb +8 -1
- data/lib/parsanol/source.rb +1 -1
- 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: 2823fc70ed3c3aa76423806779ea8ab42ad1a5360e1b8a3b3b25fb66677ae807
|
|
4
|
+
data.tar.gz: 49872edb17bdf0a8d50a2a7767a33664f2e7bae50ecbad4bcc0c3b86f43985a8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 57e15c208f426efb93148423c8a1a74053af5d0712f6c84c3e3c0cc5e30163625f85423d2f0c6581713baef56b0638467efb45d3bda15dc655a7c2e27b99011c
|
|
7
|
+
data.tar.gz: b73a51b1d8edbac2a7c1a63475135ea44b76bfe6d7f428bd2699ee756a44085f6926c6f943f5e868cf9d9fca1ff9ddaa039c866dad94d4e0ba78b0f669b6cf7c
|
data/Cargo.lock
CHANGED
|
@@ -17,9 +17,9 @@ dependencies = [
|
|
|
17
17
|
|
|
18
18
|
[[package]]
|
|
19
19
|
name = "aho-corasick"
|
|
20
|
-
version = "1.1.
|
|
20
|
+
version = "1.1.5"
|
|
21
21
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
22
|
-
checksum = "
|
|
22
|
+
checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba"
|
|
23
23
|
dependencies = [
|
|
24
24
|
"memchr",
|
|
25
25
|
]
|
|
@@ -30,12 +30,6 @@ version = "0.2.21"
|
|
|
30
30
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
31
31
|
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
|
|
32
32
|
|
|
33
|
-
[[package]]
|
|
34
|
-
name = "anyhow"
|
|
35
|
-
version = "1.0.102"
|
|
36
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
37
|
-
checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c"
|
|
38
|
-
|
|
39
33
|
[[package]]
|
|
40
34
|
name = "bindgen"
|
|
41
35
|
version = "0.72.1"
|
|
@@ -51,20 +45,20 @@ dependencies = [
|
|
|
51
45
|
"regex",
|
|
52
46
|
"rustc-hash",
|
|
53
47
|
"shlex",
|
|
54
|
-
"syn",
|
|
48
|
+
"syn 2.0.119",
|
|
55
49
|
]
|
|
56
50
|
|
|
57
51
|
[[package]]
|
|
58
52
|
name = "bitflags"
|
|
59
|
-
version = "2.
|
|
53
|
+
version = "2.13.2"
|
|
60
54
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
61
|
-
checksum = "
|
|
55
|
+
checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
|
|
62
56
|
|
|
63
57
|
[[package]]
|
|
64
58
|
name = "bumpalo"
|
|
65
|
-
version = "3.20.
|
|
59
|
+
version = "3.20.3"
|
|
66
60
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
67
|
-
checksum = "
|
|
61
|
+
checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"
|
|
68
62
|
|
|
69
63
|
[[package]]
|
|
70
64
|
name = "cexpr"
|
|
@@ -83,9 +77,9 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
|
|
83
77
|
|
|
84
78
|
[[package]]
|
|
85
79
|
name = "clang-sys"
|
|
86
|
-
version = "1.
|
|
80
|
+
version = "1.9.1"
|
|
87
81
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
88
|
-
checksum = "
|
|
82
|
+
checksum = "157a8ba7b480713b56f4c09fd13fc3e0a22a5dfab8097ba61cbc5feef950788a"
|
|
89
83
|
dependencies = [
|
|
90
84
|
"glob",
|
|
91
85
|
"libc",
|
|
@@ -94,9 +88,9 @@ dependencies = [
|
|
|
94
88
|
|
|
95
89
|
[[package]]
|
|
96
90
|
name = "either"
|
|
97
|
-
version = "1.
|
|
91
|
+
version = "1.18.0"
|
|
98
92
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
99
|
-
checksum = "
|
|
93
|
+
checksum = "252afb9ae5eaa683babdc6a068b3f5726eb19e05070c731f9b2a23a7c3e8ed34"
|
|
100
94
|
|
|
101
95
|
[[package]]
|
|
102
96
|
name = "equivalent"
|
|
@@ -104,12 +98,6 @@ version = "1.0.2"
|
|
|
104
98
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
105
99
|
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
|
|
106
100
|
|
|
107
|
-
[[package]]
|
|
108
|
-
name = "foldhash"
|
|
109
|
-
version = "0.1.5"
|
|
110
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
111
|
-
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
|
|
112
|
-
|
|
113
101
|
[[package]]
|
|
114
102
|
name = "foldhash"
|
|
115
103
|
version = "0.2.0"
|
|
@@ -132,33 +120,22 @@ dependencies = [
|
|
|
132
120
|
|
|
133
121
|
[[package]]
|
|
134
122
|
name = "getrandom"
|
|
135
|
-
version = "0.4.
|
|
123
|
+
version = "0.4.3"
|
|
136
124
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
137
|
-
checksum = "
|
|
125
|
+
checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
|
|
138
126
|
dependencies = [
|
|
139
127
|
"cfg-if",
|
|
140
128
|
"js-sys",
|
|
141
129
|
"libc",
|
|
142
130
|
"r-efi 6.0.0",
|
|
143
|
-
"wasip2",
|
|
144
|
-
"wasip3",
|
|
145
131
|
"wasm-bindgen",
|
|
146
132
|
]
|
|
147
133
|
|
|
148
134
|
[[package]]
|
|
149
135
|
name = "glob"
|
|
150
|
-
version = "0.3.
|
|
151
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
152
|
-
checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280"
|
|
153
|
-
|
|
154
|
-
[[package]]
|
|
155
|
-
name = "hashbrown"
|
|
156
|
-
version = "0.15.5"
|
|
136
|
+
version = "0.3.4"
|
|
157
137
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
158
|
-
checksum = "
|
|
159
|
-
dependencies = [
|
|
160
|
-
"foldhash 0.1.5",
|
|
161
|
-
]
|
|
138
|
+
checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b"
|
|
162
139
|
|
|
163
140
|
[[package]]
|
|
164
141
|
name = "hashbrown"
|
|
@@ -168,31 +145,7 @@ checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
|
|
|
168
145
|
dependencies = [
|
|
169
146
|
"allocator-api2",
|
|
170
147
|
"equivalent",
|
|
171
|
-
"foldhash
|
|
172
|
-
]
|
|
173
|
-
|
|
174
|
-
[[package]]
|
|
175
|
-
name = "heck"
|
|
176
|
-
version = "0.5.0"
|
|
177
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
178
|
-
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
179
|
-
|
|
180
|
-
[[package]]
|
|
181
|
-
name = "id-arena"
|
|
182
|
-
version = "2.3.0"
|
|
183
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
184
|
-
checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"
|
|
185
|
-
|
|
186
|
-
[[package]]
|
|
187
|
-
name = "indexmap"
|
|
188
|
-
version = "2.13.0"
|
|
189
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
190
|
-
checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017"
|
|
191
|
-
dependencies = [
|
|
192
|
-
"equivalent",
|
|
193
|
-
"hashbrown 0.16.1",
|
|
194
|
-
"serde",
|
|
195
|
-
"serde_core",
|
|
148
|
+
"foldhash",
|
|
196
149
|
]
|
|
197
150
|
|
|
198
151
|
[[package]]
|
|
@@ -212,11 +165,11 @@ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
|
|
|
212
165
|
|
|
213
166
|
[[package]]
|
|
214
167
|
name = "js-sys"
|
|
215
|
-
version = "0.3.
|
|
168
|
+
version = "0.3.105"
|
|
216
169
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
217
|
-
checksum = "
|
|
170
|
+
checksum = "ce57d20d1ea864ce2ac172ab472d409214f4fd359f0b2a2775abdf522e2af99e"
|
|
218
171
|
dependencies = [
|
|
219
|
-
"
|
|
172
|
+
"cfg-if",
|
|
220
173
|
"wasm-bindgen",
|
|
221
174
|
]
|
|
222
175
|
|
|
@@ -226,17 +179,11 @@ version = "1.5.0"
|
|
|
226
179
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
227
180
|
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
|
228
181
|
|
|
229
|
-
[[package]]
|
|
230
|
-
name = "leb128fmt"
|
|
231
|
-
version = "0.1.0"
|
|
232
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
233
|
-
checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2"
|
|
234
|
-
|
|
235
182
|
[[package]]
|
|
236
183
|
name = "libc"
|
|
237
|
-
version = "0.2.
|
|
184
|
+
version = "0.2.189"
|
|
238
185
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
239
|
-
checksum = "
|
|
186
|
+
checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
|
|
240
187
|
|
|
241
188
|
[[package]]
|
|
242
189
|
name = "libloading"
|
|
@@ -250,14 +197,14 @@ dependencies = [
|
|
|
250
197
|
|
|
251
198
|
[[package]]
|
|
252
199
|
name = "log"
|
|
253
|
-
version = "0.4.
|
|
200
|
+
version = "0.4.34"
|
|
254
201
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
255
|
-
checksum = "
|
|
202
|
+
checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"
|
|
256
203
|
|
|
257
204
|
[[package]]
|
|
258
205
|
name = "magnus"
|
|
259
206
|
version = "0.9.0"
|
|
260
|
-
source = "git+https://github.com/matsadler/magnus?rev=
|
|
207
|
+
source = "git+https://github.com/matsadler/magnus?rev=9407bd9#9407bd98afef6692edca706426c15ea6bef60d0e"
|
|
261
208
|
dependencies = [
|
|
262
209
|
"magnus-macros",
|
|
263
210
|
"rb-sys",
|
|
@@ -268,18 +215,18 @@ dependencies = [
|
|
|
268
215
|
[[package]]
|
|
269
216
|
name = "magnus-macros"
|
|
270
217
|
version = "0.9.0"
|
|
271
|
-
source = "git+https://github.com/matsadler/magnus?rev=
|
|
218
|
+
source = "git+https://github.com/matsadler/magnus?rev=9407bd9#9407bd98afef6692edca706426c15ea6bef60d0e"
|
|
272
219
|
dependencies = [
|
|
273
220
|
"proc-macro2",
|
|
274
221
|
"quote",
|
|
275
|
-
"syn",
|
|
222
|
+
"syn 2.0.119",
|
|
276
223
|
]
|
|
277
224
|
|
|
278
225
|
[[package]]
|
|
279
226
|
name = "memchr"
|
|
280
|
-
version = "2.8.
|
|
227
|
+
version = "2.8.3"
|
|
281
228
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
282
|
-
checksum = "
|
|
229
|
+
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
|
283
230
|
|
|
284
231
|
[[package]]
|
|
285
232
|
name = "minimal-lexical"
|
|
@@ -306,12 +253,12 @@ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
|
306
253
|
[[package]]
|
|
307
254
|
name = "parsanol"
|
|
308
255
|
version = "0.5.1"
|
|
309
|
-
source = "git+https://github.com/parsanol/parsanol-rs?branch=main#
|
|
256
|
+
source = "git+https://github.com/parsanol/parsanol-rs?branch=main#1a141f1a3471ba6ce83a768354a917d4ab83d172"
|
|
310
257
|
dependencies = [
|
|
311
258
|
"ahash",
|
|
312
259
|
"getrandom 0.3.4",
|
|
313
|
-
"getrandom 0.4.
|
|
314
|
-
"hashbrown
|
|
260
|
+
"getrandom 0.4.3",
|
|
261
|
+
"hashbrown",
|
|
315
262
|
"magnus",
|
|
316
263
|
"memchr",
|
|
317
264
|
"parsanol-derive",
|
|
@@ -323,11 +270,11 @@ dependencies = [
|
|
|
323
270
|
[[package]]
|
|
324
271
|
name = "parsanol-derive"
|
|
325
272
|
version = "0.5.1"
|
|
326
|
-
source = "git+https://github.com/parsanol/parsanol-rs?branch=main#
|
|
273
|
+
source = "git+https://github.com/parsanol/parsanol-rs?branch=main#1a141f1a3471ba6ce83a768354a917d4ab83d172"
|
|
327
274
|
dependencies = [
|
|
328
275
|
"proc-macro2",
|
|
329
276
|
"quote",
|
|
330
|
-
"syn",
|
|
277
|
+
"syn 2.0.119",
|
|
331
278
|
]
|
|
332
279
|
|
|
333
280
|
[[package]]
|
|
@@ -340,30 +287,20 @@ dependencies = [
|
|
|
340
287
|
"rb-sys",
|
|
341
288
|
]
|
|
342
289
|
|
|
343
|
-
[[package]]
|
|
344
|
-
name = "prettyplease"
|
|
345
|
-
version = "0.2.37"
|
|
346
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
347
|
-
checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b"
|
|
348
|
-
dependencies = [
|
|
349
|
-
"proc-macro2",
|
|
350
|
-
"syn",
|
|
351
|
-
]
|
|
352
|
-
|
|
353
290
|
[[package]]
|
|
354
291
|
name = "proc-macro2"
|
|
355
|
-
version = "1.0.
|
|
292
|
+
version = "1.0.107"
|
|
356
293
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
357
|
-
checksum = "
|
|
294
|
+
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
358
295
|
dependencies = [
|
|
359
296
|
"unicode-ident",
|
|
360
297
|
]
|
|
361
298
|
|
|
362
299
|
[[package]]
|
|
363
300
|
name = "quote"
|
|
364
|
-
version = "1.0.
|
|
301
|
+
version = "1.0.47"
|
|
365
302
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
366
|
-
checksum = "
|
|
303
|
+
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
367
304
|
dependencies = [
|
|
368
305
|
"proc-macro2",
|
|
369
306
|
]
|
|
@@ -399,7 +336,7 @@ dependencies = [
|
|
|
399
336
|
"quote",
|
|
400
337
|
"regex",
|
|
401
338
|
"shell-words",
|
|
402
|
-
"syn",
|
|
339
|
+
"syn 2.0.119",
|
|
403
340
|
]
|
|
404
341
|
|
|
405
342
|
[[package]]
|
|
@@ -410,9 +347,9 @@ checksum = "cca7ad6a7e21e72151d56fe2495a259b5670e204c3adac41ee7ef676ea08117a"
|
|
|
410
347
|
|
|
411
348
|
[[package]]
|
|
412
349
|
name = "regex"
|
|
413
|
-
version = "1.
|
|
350
|
+
version = "1.13.1"
|
|
414
351
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
415
|
-
checksum = "
|
|
352
|
+
checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d"
|
|
416
353
|
dependencies = [
|
|
417
354
|
"aho-corasick",
|
|
418
355
|
"memchr",
|
|
@@ -422,9 +359,9 @@ dependencies = [
|
|
|
422
359
|
|
|
423
360
|
[[package]]
|
|
424
361
|
name = "regex-automata"
|
|
425
|
-
version = "0.4.
|
|
362
|
+
version = "0.4.18"
|
|
426
363
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
427
|
-
checksum = "
|
|
364
|
+
checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2"
|
|
428
365
|
dependencies = [
|
|
429
366
|
"aho-corasick",
|
|
430
367
|
"memchr",
|
|
@@ -433,27 +370,21 @@ dependencies = [
|
|
|
433
370
|
|
|
434
371
|
[[package]]
|
|
435
372
|
name = "regex-syntax"
|
|
436
|
-
version = "0.8.
|
|
373
|
+
version = "0.8.11"
|
|
437
374
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
438
|
-
checksum = "
|
|
375
|
+
checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
|
|
439
376
|
|
|
440
377
|
[[package]]
|
|
441
378
|
name = "rustc-hash"
|
|
442
|
-
version = "2.1.
|
|
379
|
+
version = "2.1.3"
|
|
443
380
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
444
|
-
checksum = "
|
|
381
|
+
checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"
|
|
445
382
|
|
|
446
383
|
[[package]]
|
|
447
384
|
name = "rustversion"
|
|
448
|
-
version = "1.0.
|
|
385
|
+
version = "1.0.23"
|
|
449
386
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
450
|
-
checksum = "
|
|
451
|
-
|
|
452
|
-
[[package]]
|
|
453
|
-
name = "semver"
|
|
454
|
-
version = "1.0.27"
|
|
455
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
456
|
-
checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2"
|
|
387
|
+
checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
|
|
457
388
|
|
|
458
389
|
[[package]]
|
|
459
390
|
name = "seq-macro"
|
|
@@ -463,9 +394,9 @@ checksum = "1bc711410fbe7399f390ca1c3b60ad0f53f80e95c5eb935e52268a0e2cd49acc"
|
|
|
463
394
|
|
|
464
395
|
[[package]]
|
|
465
396
|
name = "serde"
|
|
466
|
-
version = "1.0.
|
|
397
|
+
version = "1.0.229"
|
|
467
398
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
468
|
-
checksum = "
|
|
399
|
+
checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
|
|
469
400
|
dependencies = [
|
|
470
401
|
"serde_core",
|
|
471
402
|
"serde_derive",
|
|
@@ -473,29 +404,29 @@ dependencies = [
|
|
|
473
404
|
|
|
474
405
|
[[package]]
|
|
475
406
|
name = "serde_core"
|
|
476
|
-
version = "1.0.
|
|
407
|
+
version = "1.0.229"
|
|
477
408
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
478
|
-
checksum = "
|
|
409
|
+
checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
|
|
479
410
|
dependencies = [
|
|
480
411
|
"serde_derive",
|
|
481
412
|
]
|
|
482
413
|
|
|
483
414
|
[[package]]
|
|
484
415
|
name = "serde_derive"
|
|
485
|
-
version = "1.0.
|
|
416
|
+
version = "1.0.229"
|
|
486
417
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
487
|
-
checksum = "
|
|
418
|
+
checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
|
|
488
419
|
dependencies = [
|
|
489
420
|
"proc-macro2",
|
|
490
421
|
"quote",
|
|
491
|
-
"syn",
|
|
422
|
+
"syn 3.0.5",
|
|
492
423
|
]
|
|
493
424
|
|
|
494
425
|
[[package]]
|
|
495
426
|
name = "serde_json"
|
|
496
|
-
version = "1.0.
|
|
427
|
+
version = "1.0.151"
|
|
497
428
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
498
|
-
checksum = "
|
|
429
|
+
checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14"
|
|
499
430
|
dependencies = [
|
|
500
431
|
"itoa",
|
|
501
432
|
"memchr",
|
|
@@ -518,9 +449,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
|
|
518
449
|
|
|
519
450
|
[[package]]
|
|
520
451
|
name = "syn"
|
|
521
|
-
version = "2.0.
|
|
452
|
+
version = "2.0.119"
|
|
522
453
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
523
|
-
checksum = "
|
|
454
|
+
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
|
|
524
455
|
dependencies = [
|
|
525
456
|
"proc-macro2",
|
|
526
457
|
"quote",
|
|
@@ -528,16 +459,21 @@ dependencies = [
|
|
|
528
459
|
]
|
|
529
460
|
|
|
530
461
|
[[package]]
|
|
531
|
-
name = "
|
|
532
|
-
version = "
|
|
462
|
+
name = "syn"
|
|
463
|
+
version = "3.0.5"
|
|
533
464
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
534
|
-
checksum = "
|
|
465
|
+
checksum = "12df2e0110f65b775f769bb17ef989067a1d931b2eb822bd4346631eeada89f9"
|
|
466
|
+
dependencies = [
|
|
467
|
+
"proc-macro2",
|
|
468
|
+
"quote",
|
|
469
|
+
"unicode-ident",
|
|
470
|
+
]
|
|
535
471
|
|
|
536
472
|
[[package]]
|
|
537
|
-
name = "unicode-
|
|
538
|
-
version = "0.
|
|
473
|
+
name = "unicode-ident"
|
|
474
|
+
version = "1.0.24"
|
|
539
475
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
540
|
-
checksum = "
|
|
476
|
+
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
|
541
477
|
|
|
542
478
|
[[package]]
|
|
543
479
|
name = "version_check"
|
|
@@ -547,27 +483,18 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
|
|
547
483
|
|
|
548
484
|
[[package]]
|
|
549
485
|
name = "wasip2"
|
|
550
|
-
version = "1.0.
|
|
486
|
+
version = "1.0.4+wasi-0.2.12"
|
|
551
487
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
552
|
-
checksum = "
|
|
553
|
-
dependencies = [
|
|
554
|
-
"wit-bindgen",
|
|
555
|
-
]
|
|
556
|
-
|
|
557
|
-
[[package]]
|
|
558
|
-
name = "wasip3"
|
|
559
|
-
version = "0.4.0+wasi-0.3.0-rc-2026-01-06"
|
|
560
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
561
|
-
checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5"
|
|
488
|
+
checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487"
|
|
562
489
|
dependencies = [
|
|
563
490
|
"wit-bindgen",
|
|
564
491
|
]
|
|
565
492
|
|
|
566
493
|
[[package]]
|
|
567
494
|
name = "wasm-bindgen"
|
|
568
|
-
version = "0.2.
|
|
495
|
+
version = "0.2.128"
|
|
569
496
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
570
|
-
checksum = "
|
|
497
|
+
checksum = "aecb87a33d3b0c5e3b7aa46336eaf486cffafbd281b195e4c8b80d50df2351bf"
|
|
571
498
|
dependencies = [
|
|
572
499
|
"cfg-if",
|
|
573
500
|
"once_cell",
|
|
@@ -578,9 +505,9 @@ dependencies = [
|
|
|
578
505
|
|
|
579
506
|
[[package]]
|
|
580
507
|
name = "wasm-bindgen-macro"
|
|
581
|
-
version = "0.2.
|
|
508
|
+
version = "0.2.128"
|
|
582
509
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
583
|
-
checksum = "
|
|
510
|
+
checksum = "a690d511e3c1a8b3a55e33511e3c2c00c78415cd23650f32b808627f5696b9ed"
|
|
584
511
|
dependencies = [
|
|
585
512
|
"quote",
|
|
586
513
|
"wasm-bindgen-macro-support",
|
|
@@ -588,60 +515,26 @@ dependencies = [
|
|
|
588
515
|
|
|
589
516
|
[[package]]
|
|
590
517
|
name = "wasm-bindgen-macro-support"
|
|
591
|
-
version = "0.2.
|
|
518
|
+
version = "0.2.128"
|
|
592
519
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
593
|
-
checksum = "
|
|
520
|
+
checksum = "411e4887f0071ef2d2164a9d5fdf2d20efbef78fccd3a78b0c10a1dc5295e48a"
|
|
594
521
|
dependencies = [
|
|
595
522
|
"bumpalo",
|
|
596
523
|
"proc-macro2",
|
|
597
524
|
"quote",
|
|
598
|
-
"syn",
|
|
525
|
+
"syn 3.0.5",
|
|
599
526
|
"wasm-bindgen-shared",
|
|
600
527
|
]
|
|
601
528
|
|
|
602
529
|
[[package]]
|
|
603
530
|
name = "wasm-bindgen-shared"
|
|
604
|
-
version = "0.2.
|
|
531
|
+
version = "0.2.128"
|
|
605
532
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
606
|
-
checksum = "
|
|
533
|
+
checksum = "81941cd78d0c92026c33e5e01312845a4cb1e9af3407f9134b100dd03144103e"
|
|
607
534
|
dependencies = [
|
|
608
535
|
"unicode-ident",
|
|
609
536
|
]
|
|
610
537
|
|
|
611
|
-
[[package]]
|
|
612
|
-
name = "wasm-encoder"
|
|
613
|
-
version = "0.244.0"
|
|
614
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
615
|
-
checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319"
|
|
616
|
-
dependencies = [
|
|
617
|
-
"leb128fmt",
|
|
618
|
-
"wasmparser",
|
|
619
|
-
]
|
|
620
|
-
|
|
621
|
-
[[package]]
|
|
622
|
-
name = "wasm-metadata"
|
|
623
|
-
version = "0.244.0"
|
|
624
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
625
|
-
checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909"
|
|
626
|
-
dependencies = [
|
|
627
|
-
"anyhow",
|
|
628
|
-
"indexmap",
|
|
629
|
-
"wasm-encoder",
|
|
630
|
-
"wasmparser",
|
|
631
|
-
]
|
|
632
|
-
|
|
633
|
-
[[package]]
|
|
634
|
-
name = "wasmparser"
|
|
635
|
-
version = "0.244.0"
|
|
636
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
637
|
-
checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe"
|
|
638
|
-
dependencies = [
|
|
639
|
-
"bitflags",
|
|
640
|
-
"hashbrown 0.15.5",
|
|
641
|
-
"indexmap",
|
|
642
|
-
"semver",
|
|
643
|
-
]
|
|
644
|
-
|
|
645
538
|
[[package]]
|
|
646
539
|
name = "windows-link"
|
|
647
540
|
version = "0.2.1"
|
|
@@ -650,114 +543,32 @@ checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
|
|
650
543
|
|
|
651
544
|
[[package]]
|
|
652
545
|
name = "wit-bindgen"
|
|
653
|
-
version = "0.
|
|
654
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
655
|
-
checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5"
|
|
656
|
-
dependencies = [
|
|
657
|
-
"wit-bindgen-rust-macro",
|
|
658
|
-
]
|
|
659
|
-
|
|
660
|
-
[[package]]
|
|
661
|
-
name = "wit-bindgen-core"
|
|
662
|
-
version = "0.51.0"
|
|
663
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
664
|
-
checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc"
|
|
665
|
-
dependencies = [
|
|
666
|
-
"anyhow",
|
|
667
|
-
"heck",
|
|
668
|
-
"wit-parser",
|
|
669
|
-
]
|
|
670
|
-
|
|
671
|
-
[[package]]
|
|
672
|
-
name = "wit-bindgen-rust"
|
|
673
|
-
version = "0.51.0"
|
|
546
|
+
version = "0.57.1"
|
|
674
547
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
675
|
-
checksum = "
|
|
676
|
-
dependencies = [
|
|
677
|
-
"anyhow",
|
|
678
|
-
"heck",
|
|
679
|
-
"indexmap",
|
|
680
|
-
"prettyplease",
|
|
681
|
-
"syn",
|
|
682
|
-
"wasm-metadata",
|
|
683
|
-
"wit-bindgen-core",
|
|
684
|
-
"wit-component",
|
|
685
|
-
]
|
|
686
|
-
|
|
687
|
-
[[package]]
|
|
688
|
-
name = "wit-bindgen-rust-macro"
|
|
689
|
-
version = "0.51.0"
|
|
690
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
691
|
-
checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a"
|
|
692
|
-
dependencies = [
|
|
693
|
-
"anyhow",
|
|
694
|
-
"prettyplease",
|
|
695
|
-
"proc-macro2",
|
|
696
|
-
"quote",
|
|
697
|
-
"syn",
|
|
698
|
-
"wit-bindgen-core",
|
|
699
|
-
"wit-bindgen-rust",
|
|
700
|
-
]
|
|
701
|
-
|
|
702
|
-
[[package]]
|
|
703
|
-
name = "wit-component"
|
|
704
|
-
version = "0.244.0"
|
|
705
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
706
|
-
checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2"
|
|
707
|
-
dependencies = [
|
|
708
|
-
"anyhow",
|
|
709
|
-
"bitflags",
|
|
710
|
-
"indexmap",
|
|
711
|
-
"log",
|
|
712
|
-
"serde",
|
|
713
|
-
"serde_derive",
|
|
714
|
-
"serde_json",
|
|
715
|
-
"wasm-encoder",
|
|
716
|
-
"wasm-metadata",
|
|
717
|
-
"wasmparser",
|
|
718
|
-
"wit-parser",
|
|
719
|
-
]
|
|
720
|
-
|
|
721
|
-
[[package]]
|
|
722
|
-
name = "wit-parser"
|
|
723
|
-
version = "0.244.0"
|
|
724
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
725
|
-
checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736"
|
|
726
|
-
dependencies = [
|
|
727
|
-
"anyhow",
|
|
728
|
-
"id-arena",
|
|
729
|
-
"indexmap",
|
|
730
|
-
"log",
|
|
731
|
-
"semver",
|
|
732
|
-
"serde",
|
|
733
|
-
"serde_derive",
|
|
734
|
-
"serde_json",
|
|
735
|
-
"unicode-xid",
|
|
736
|
-
"wasmparser",
|
|
737
|
-
]
|
|
548
|
+
checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e"
|
|
738
549
|
|
|
739
550
|
[[package]]
|
|
740
551
|
name = "zerocopy"
|
|
741
|
-
version = "0.8.
|
|
552
|
+
version = "0.8.57"
|
|
742
553
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
743
|
-
checksum = "
|
|
554
|
+
checksum = "d35102a9f36d089ccae9e4c6802bc118be4487b80aaffc0ab4e0cf5ce92d2873"
|
|
744
555
|
dependencies = [
|
|
745
556
|
"zerocopy-derive",
|
|
746
557
|
]
|
|
747
558
|
|
|
748
559
|
[[package]]
|
|
749
560
|
name = "zerocopy-derive"
|
|
750
|
-
version = "0.8.
|
|
561
|
+
version = "0.8.57"
|
|
751
562
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
752
|
-
checksum = "
|
|
563
|
+
checksum = "146c01f5ab44258da43cf276c74a2763db2ff3969c9c652c3f2de07041d0b2bc"
|
|
753
564
|
dependencies = [
|
|
754
565
|
"proc-macro2",
|
|
755
566
|
"quote",
|
|
756
|
-
"syn",
|
|
567
|
+
"syn 2.0.119",
|
|
757
568
|
]
|
|
758
569
|
|
|
759
570
|
[[package]]
|
|
760
571
|
name = "zmij"
|
|
761
|
-
version = "1.0.
|
|
572
|
+
version = "1.0.23"
|
|
762
573
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
763
|
-
checksum = "
|
|
574
|
+
checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
|
data/Cargo.toml
CHANGED
|
@@ -8,8 +8,11 @@ lto = "off"
|
|
|
8
8
|
codegen-units = 1
|
|
9
9
|
debug = true
|
|
10
10
|
|
|
11
|
-
# Patches for Ruby 4.0 support (
|
|
11
|
+
# Patches for Ruby 4.0 support and 32-bit musl (magnus timespec fix).
|
|
12
|
+
# magnus 0.9 is not on crates.io yet; pin a git rev that includes
|
|
13
|
+
# https://github.com/matsadler/magnus/pull/183 (32-bit musl timespec).
|
|
14
|
+
# parsanol-rs must use the same rev (direct git dep, not patchable here).
|
|
12
15
|
[patch.crates-io]
|
|
13
|
-
magnus = { git = "https://github.com/matsadler/magnus", rev = "
|
|
14
|
-
magnus-macros = { git = "https://github.com/matsadler/magnus", rev = "
|
|
16
|
+
magnus = { git = "https://github.com/matsadler/magnus", rev = "9407bd9" }
|
|
17
|
+
magnus-macros = { git = "https://github.com/matsadler/magnus", rev = "9407bd9" }
|
|
15
18
|
rb-sys = { git = "https://github.com/oxidize-rb/rb-sys.git", rev = "daa12b6521a0c442a705d7f9a929029119aab1d6" }
|
|
@@ -28,6 +28,9 @@ module Parsanol
|
|
|
28
28
|
:default => 1000,
|
|
29
29
|
}.freeze
|
|
30
30
|
|
|
31
|
+
# Number of observed backtrack events before packrat caching engages.
|
|
32
|
+
BACKTRACK_ACTIVATION_LIMIT = 64
|
|
33
|
+
|
|
31
34
|
# Creates a new parsing context.
|
|
32
35
|
#
|
|
33
36
|
# @param error_reporter [#err, #err_at] error reporter instance
|
|
@@ -40,7 +43,7 @@ module Parsanol
|
|
|
40
43
|
adaptive_cache_threshold: nil,
|
|
41
44
|
parser_class: nil)
|
|
42
45
|
# Core memoization cache: position -> { atom_id -> [result, advance] }
|
|
43
|
-
@memo =
|
|
46
|
+
@memo = {}
|
|
44
47
|
|
|
45
48
|
# Error reporting delegate
|
|
46
49
|
@reporter = error_reporter
|
|
@@ -55,7 +58,7 @@ module Parsanol
|
|
|
55
58
|
@evict_interval = 100
|
|
56
59
|
|
|
57
60
|
# Object pools for reducing allocations
|
|
58
|
-
@array_pool = Parsanol::Pools::ArrayPool.new(size: 10_000)
|
|
61
|
+
@array_pool = Parsanol::Pools::ArrayPool.new(size: 10_000, preallocate: false)
|
|
59
62
|
@buffer_pool = Parsanol::Pools::BufferPool.new(pool_size: 100)
|
|
60
63
|
|
|
61
64
|
# Selective memoization tracking
|
|
@@ -85,7 +88,8 @@ module Parsanol
|
|
|
85
88
|
|
|
86
89
|
@adaptive_threshold = threshold
|
|
87
90
|
@input_len = nil
|
|
88
|
-
@caching_active =
|
|
91
|
+
@caching_active = false
|
|
92
|
+
@backtrack_events = 0
|
|
89
93
|
end
|
|
90
94
|
|
|
91
95
|
# Attempts to parse using memoization. Returns cached result if available,
|
|
@@ -100,21 +104,18 @@ module Parsanol
|
|
|
100
104
|
# Skip caching for atoms that don't benefit from it
|
|
101
105
|
return atom.try(src, self, must_consume_all) unless atom.cached?
|
|
102
106
|
|
|
103
|
-
# Determine if caching should be active (lazy initialization)
|
|
104
|
-
if @caching_active.nil?
|
|
105
|
-
total_len = src.bytepos + src.chars_left
|
|
106
|
-
@input_len = total_len
|
|
107
|
-
@caching_active = total_len >= @adaptive_threshold
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
# For small inputs, skip caching overhead
|
|
111
|
-
return atom.try(src, self, must_consume_all) unless @caching_active
|
|
112
|
-
|
|
113
107
|
# Use interval-based caching if enabled
|
|
114
108
|
return try_with_interval(atom, src, must_consume_all) if @use_intervals
|
|
115
109
|
|
|
110
|
+
# Adaptive activation: packrat memoization costs more than it saves
|
|
111
|
+
# on deterministic forward-only grammars, so start uncached and only
|
|
112
|
+
# engage once real backtracking (re-parsing behind the progress
|
|
113
|
+
# frontier) is observed.
|
|
114
|
+
return try_uncached_probe(atom, src, must_consume_all) unless @caching_active
|
|
115
|
+
|
|
116
116
|
pos = src.bytepos
|
|
117
117
|
key = atom.object_id
|
|
118
|
+
entry = @memo[pos]
|
|
118
119
|
|
|
119
120
|
# Periodic cache eviction to prevent unbounded growth
|
|
120
121
|
if pos > @furthest_pos
|
|
@@ -128,10 +129,10 @@ module Parsanol
|
|
|
128
129
|
end
|
|
129
130
|
end
|
|
130
131
|
|
|
131
|
-
# Check for cache hit
|
|
132
|
-
if
|
|
132
|
+
# Check for cache hit (avoid default-block Hash allocation per probe)
|
|
133
|
+
if entry&.key?(key)
|
|
133
134
|
@hit_stats[key] += 1
|
|
134
|
-
outcome, delta =
|
|
135
|
+
outcome, delta = entry[key]
|
|
135
136
|
src.bytepos = pos + delta
|
|
136
137
|
return outcome
|
|
137
138
|
end
|
|
@@ -144,7 +145,7 @@ module Parsanol
|
|
|
144
145
|
# Only cache if beneficial (heuristic)
|
|
145
146
|
attempts = @hit_stats[key] + @miss_stats[key]
|
|
146
147
|
if attempts <= @min_hits_for_cache || @hit_stats[key].positive?
|
|
147
|
-
@memo[pos][key] =
|
|
148
|
+
(@memo[pos] ||= {})[key] =
|
|
148
149
|
[outcome,
|
|
149
150
|
delta]
|
|
150
151
|
end
|
|
@@ -327,6 +328,21 @@ module Parsanol
|
|
|
327
328
|
|
|
328
329
|
private
|
|
329
330
|
|
|
331
|
+
# Executes an atom without memoization while watching for backtracking.
|
|
332
|
+
# A failed attempt at a position behind the progress frontier means work
|
|
333
|
+
# is being re-done; once that repeats, packrat caching engages.
|
|
334
|
+
def try_uncached_probe(atom, src, must_consume_all)
|
|
335
|
+
pos = src.bytepos
|
|
336
|
+
outcome = atom.try(src, self, must_consume_all)
|
|
337
|
+
if pos > @furthest_pos
|
|
338
|
+
@furthest_pos = pos
|
|
339
|
+
elsif !outcome[0] && pos < @furthest_pos
|
|
340
|
+
@backtrack_events += 1
|
|
341
|
+
@caching_active = true if @backtrack_events >= BACKTRACK_ACTIVATION_LIMIT
|
|
342
|
+
end
|
|
343
|
+
outcome
|
|
344
|
+
end
|
|
345
|
+
|
|
330
346
|
# Lookup cached result (uses object_id for speed)
|
|
331
347
|
def lookup(atom, pos)
|
|
332
348
|
@memo[pos][atom.object_id]
|
|
@@ -28,10 +28,19 @@ module Parsanol
|
|
|
28
28
|
# This is a class variable to share across all transformations
|
|
29
29
|
@@symbol_cache = {}
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
# Symbol tags from native parser
|
|
32
|
+
SEQUENCE_SYM = :sequence
|
|
33
|
+
REPETITION_SYM = :repetition
|
|
34
|
+
MAYBE_SYM = :maybe
|
|
35
|
+
MAYBE_TAG = ":maybe"
|
|
36
|
+
|
|
37
|
+
# `named` mirrors CanFlatten#flatten's named flag: inside a Named
|
|
38
|
+
# result (.as), an absent maybe flattens to nil; unnamed it flattens
|
|
39
|
+
# to "".
|
|
40
|
+
def self.transform(ast, named: false)
|
|
32
41
|
case ast
|
|
33
42
|
when Array
|
|
34
|
-
transform_array(ast)
|
|
43
|
+
transform_array(ast, named: named)
|
|
35
44
|
when Hash
|
|
36
45
|
transform_hash(ast)
|
|
37
46
|
else
|
|
@@ -52,11 +61,7 @@ module Parsanol
|
|
|
52
61
|
@@symbol_cache[key] ||= key.to_sym
|
|
53
62
|
end
|
|
54
63
|
|
|
55
|
-
|
|
56
|
-
SEQUENCE_SYM = :sequence
|
|
57
|
-
REPETITION_SYM = :repetition
|
|
58
|
-
|
|
59
|
-
def self.transform_array(arr)
|
|
64
|
+
def self.transform_array(arr, named: false)
|
|
60
65
|
return EMPTY_ARRAY if arr.empty? # Match Parsanol Ruby mode behavior
|
|
61
66
|
|
|
62
67
|
# Check if this is a tagged array from native parser
|
|
@@ -87,6 +92,16 @@ module Parsanol
|
|
|
87
92
|
i += 1
|
|
88
93
|
end
|
|
89
94
|
flatten_repetition(items)
|
|
95
|
+
elsif [MAYBE_SYM, MAYBE_TAG].include?(first)
|
|
96
|
+
# Maybe flattens to nil-or-value (named) or ""-or-value (unnamed),
|
|
97
|
+
# never to an array
|
|
98
|
+
len = arr.length
|
|
99
|
+
if len == 1
|
|
100
|
+
named ? nil : EMPTY_STRING
|
|
101
|
+
else
|
|
102
|
+
flattened = transform(arr[1])
|
|
103
|
+
named ? flattened : (flattened || EMPTY_STRING)
|
|
104
|
+
end
|
|
90
105
|
elsif first.is_a?(Symbol) || (first.is_a?(String) && first.start_with?(":"))
|
|
91
106
|
# Other tagged arrays - pass through
|
|
92
107
|
arr.map { |item| transform(item) }
|
|
@@ -115,7 +130,7 @@ module Parsanol
|
|
|
115
130
|
sym_key = cached_symbol(key)
|
|
116
131
|
|
|
117
132
|
# Transform the value
|
|
118
|
-
transformed = transform(value)
|
|
133
|
+
transformed = transform(value, named: true)
|
|
119
134
|
|
|
120
135
|
# Check if value is a tagged repetition from native parser
|
|
121
136
|
is_tagged_repetition = value.is_a?(Array) && !value.empty? &&
|
|
@@ -240,7 +255,7 @@ module Parsanol
|
|
|
240
255
|
is_repetition = value.is_a?(Array) && !value.empty? &&
|
|
241
256
|
value.first.is_a?(String) && value.first == REPETITION_TAG
|
|
242
257
|
|
|
243
|
-
transformed = transform(value)
|
|
258
|
+
transformed = transform(value, named: true)
|
|
244
259
|
|
|
245
260
|
result[sym_key] = if is_repetition
|
|
246
261
|
if transformed.is_a?(Array)
|
data/lib/parsanol/native.rb
CHANGED
|
@@ -48,7 +48,11 @@ module Parsanol
|
|
|
48
48
|
# Use _parse_raw which returns properly tagged Ruby arrays via transform_ast.
|
|
49
49
|
# The batch format doesn't preserve :repetition/:sequence tags, so we use
|
|
50
50
|
# the direct FFI path. Apply the Ruby transformer to handle tags correctly.
|
|
51
|
-
|
|
51
|
+
begin
|
|
52
|
+
raw_ast = _parse_raw(grammar_json, input)
|
|
53
|
+
rescue RuntimeError => e
|
|
54
|
+
raise_native_parse_error(e, grammar, input)
|
|
55
|
+
end
|
|
52
56
|
BatchDecoder.decode_and_flatten(raw_ast, input, Parsanol::Slice)
|
|
53
57
|
end
|
|
54
58
|
|
|
@@ -69,7 +73,11 @@ module Parsanol
|
|
|
69
73
|
Parser.serialize_grammar(grammar)
|
|
70
74
|
end
|
|
71
75
|
|
|
72
|
-
|
|
76
|
+
begin
|
|
77
|
+
raw_ast = _parse_fresh_raw(grammar_json, input)
|
|
78
|
+
rescue RuntimeError => e
|
|
79
|
+
raise_native_parse_error(e, grammar, input)
|
|
80
|
+
end
|
|
73
81
|
BatchDecoder.decode_and_flatten(raw_ast, input, Parsanol::Slice)
|
|
74
82
|
end
|
|
75
83
|
|
|
@@ -182,6 +190,22 @@ module Parsanol
|
|
|
182
190
|
end
|
|
183
191
|
stats
|
|
184
192
|
end
|
|
193
|
+
|
|
194
|
+
# Translates a native backend failure into the Parsanol error protocol.
|
|
195
|
+
#
|
|
196
|
+
# When the grammar atom is at hand, reparses through the pure Ruby
|
|
197
|
+
# backend: a Ruby failure raises Parsanol::ParseFailed with the full
|
|
198
|
+
# cause-tree diagnostics, and a Ruby success recovers grammars the
|
|
199
|
+
# native serializer cannot express (e.g. custom atoms). For
|
|
200
|
+
# pre-serialized JSON grammars the native message is wrapped in a
|
|
201
|
+
# Parsanol::ParseFailed directly.
|
|
202
|
+
def raise_native_parse_error(error, grammar, input)
|
|
203
|
+
return grammar.parse(input) if grammar.respond_to?(:parse)
|
|
204
|
+
|
|
205
|
+
source = Parsanol::Source.new(input)
|
|
206
|
+
cause = Parsanol::Cause.new(error.message, source, source.bytepos)
|
|
207
|
+
raise Parsanol::ParseFailed.new(cause.to_s, cause)
|
|
208
|
+
end
|
|
185
209
|
end
|
|
186
210
|
end
|
|
187
211
|
end
|
data/lib/parsanol/parser.rb
CHANGED
|
@@ -112,10 +112,18 @@ module Parsanol
|
|
|
112
112
|
if mode_or_opts.is_a?(Hash) && !kwargs.key?(:mode)
|
|
113
113
|
# Legacy API: parse(input, options={})
|
|
114
114
|
merged = mode_or_opts.merge(kwargs)
|
|
115
|
-
|
|
115
|
+
if Parsanol::Native.available? && !merged.key?(:prefix) &&
|
|
116
|
+
!merged.key?(:reporter)
|
|
117
|
+
# Native backend by default; falls back to pure Ruby inside
|
|
118
|
+
# parse_native when the extension is missing.
|
|
119
|
+
parse_native(input, merged)
|
|
120
|
+
else
|
|
121
|
+
super(input, merged)
|
|
122
|
+
end
|
|
116
123
|
else
|
|
117
124
|
# New API: parse(input, mode:, **options)
|
|
118
|
-
mode = kwargs.delete(:mode) ||
|
|
125
|
+
mode = kwargs.delete(:mode) ||
|
|
126
|
+
(Parsanol::Native.available? ? :native : :ruby)
|
|
119
127
|
case mode
|
|
120
128
|
when :ruby
|
|
121
129
|
super(input, kwargs)
|
|
@@ -209,7 +217,8 @@ module Parsanol
|
|
|
209
217
|
if Parsanol::Native.available?
|
|
210
218
|
Parsanol::Native.parse(root, input)
|
|
211
219
|
else
|
|
212
|
-
|
|
220
|
+
Parsanol::Atoms::Base.instance_method(:parse).bind_call(self, input,
|
|
221
|
+
opts)
|
|
213
222
|
end
|
|
214
223
|
end
|
|
215
224
|
|
|
@@ -151,7 +151,14 @@ module Parsanol
|
|
|
151
151
|
# @return [Integer] Size class
|
|
152
152
|
#
|
|
153
153
|
def select_size_class(size)
|
|
154
|
-
|
|
154
|
+
i = 0
|
|
155
|
+
n = SIZE_CLASSES.length
|
|
156
|
+
while i < n
|
|
157
|
+
return SIZE_CLASSES[i] if SIZE_CLASSES[i] >= size
|
|
158
|
+
|
|
159
|
+
i += 1
|
|
160
|
+
end
|
|
161
|
+
next_power_of_2(size)
|
|
155
162
|
end
|
|
156
163
|
|
|
157
164
|
# Find next power of 2 greater than or equal to n.
|
data/lib/parsanol/source.rb
CHANGED
|
@@ -53,7 +53,7 @@ module Parsanol
|
|
|
53
53
|
|
|
54
54
|
# Object pools for memory efficiency
|
|
55
55
|
# SlicePool: reduces Slice allocations during matching
|
|
56
|
-
@slice_pool = Parsanol::Pools::SlicePool.new(size: 5000)
|
|
56
|
+
@slice_pool = Parsanol::Pools::SlicePool.new(size: 5000, preallocate: false)
|
|
57
57
|
|
|
58
58
|
# PositionPool: reduces Position allocations for error reporting
|
|
59
59
|
@position_pool = Parsanol::Pools::PositionPool.new(size: 1000)
|
data/lib/parsanol/version.rb
CHANGED