edn-abnf 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/edn-abnf.gemspec +1 -1
- data/lib/parser/edngrammar.rb +332 -291
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad6ca6781c8f1fab8f4be83db41604619f4a38049b13e934f4eea8ab3a2fe757
|
4
|
+
data.tar.gz: b8d503680fffa8e5a81232ce301026f9780df6c35aaec80598549fd81fea63ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50ad3b1462112822df91e51617ef5dc0ba704e896be060562d6a42cd6c7f67980121b250ccfd080f11be9f51e406c005b1e37133f41156d1684ba13f07c80e78
|
7
|
+
data.tar.gz: 28d52a6d4f5b1e55b85d4cc8534341de042834fb36bb5b6962609332ead01bd66629fc664d4e88adcc0eb6b74948d357be979c4b5266524b61af44a6feee26c4
|
data/edn-abnf.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "edn-abnf"
|
3
|
-
s.version = "0.0.
|
3
|
+
s.version = "0.0.8"
|
4
4
|
s.summary = "CDDL (Concise Data Definition Language) converters and miscellaneous tools"
|
5
5
|
s.description = %q{edn-abnf implements converters and miscellaneous tools for CBOR EDN's ABNF}
|
6
6
|
s.author = "Carsten Bormann"
|
data/lib/parser/edngrammar.rb
CHANGED
@@ -187,52 +187,28 @@ module EDNGRAMMAR
|
|
187
187
|
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
188
188
|
r0 = r3
|
189
189
|
else
|
190
|
-
r4 =
|
190
|
+
r4 = _nt_number
|
191
191
|
if r4
|
192
192
|
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
193
193
|
r0 = r4
|
194
194
|
else
|
195
|
-
r5 =
|
195
|
+
r5 = _nt_simple
|
196
196
|
if r5
|
197
197
|
r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
|
198
198
|
r0 = r5
|
199
199
|
else
|
200
|
-
r6 =
|
200
|
+
r6 = _nt_string
|
201
201
|
if r6
|
202
202
|
r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
|
203
203
|
r0 = r6
|
204
204
|
else
|
205
|
-
r7 =
|
205
|
+
r7 = _nt_streamstring
|
206
206
|
if r7
|
207
207
|
r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
|
208
208
|
r0 = r7
|
209
209
|
else
|
210
|
-
|
211
|
-
|
212
|
-
r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true
|
213
|
-
r0 = r8
|
214
|
-
else
|
215
|
-
r9 = _nt_bstr
|
216
|
-
if r9
|
217
|
-
r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
|
218
|
-
r0 = r9
|
219
|
-
else
|
220
|
-
r10 = _nt_embedded
|
221
|
-
if r10
|
222
|
-
r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
|
223
|
-
r0 = r10
|
224
|
-
else
|
225
|
-
r11 = _nt_streamstring
|
226
|
-
if r11
|
227
|
-
r11 = SyntaxNode.new(input, (index-1)...index) if r11 == true
|
228
|
-
r0 = r11
|
229
|
-
else
|
230
|
-
@index = i0
|
231
|
-
r0 = nil
|
232
|
-
end
|
233
|
-
end
|
234
|
-
end
|
235
|
-
end
|
210
|
+
@index = i0
|
211
|
+
r0 = nil
|
236
212
|
end
|
237
213
|
end
|
238
214
|
end
|
@@ -246,6 +222,128 @@ module EDNGRAMMAR
|
|
246
222
|
r0
|
247
223
|
end
|
248
224
|
|
225
|
+
module Number0
|
226
|
+
def spec
|
227
|
+
elements[1]
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
module Number1
|
232
|
+
def ast
|
233
|
+
elements[0].ast
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
def _nt_number
|
238
|
+
start_index = index
|
239
|
+
if node_cache[:number].has_key?(index)
|
240
|
+
cached = node_cache[:number][index]
|
241
|
+
if cached
|
242
|
+
node_cache[:number][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
243
|
+
@index = cached.interval.end
|
244
|
+
end
|
245
|
+
return cached
|
246
|
+
end
|
247
|
+
|
248
|
+
i0, s0 = index, []
|
249
|
+
i1 = index
|
250
|
+
r2 = _nt_basenumber
|
251
|
+
if r2
|
252
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
253
|
+
r1 = r2
|
254
|
+
else
|
255
|
+
r3 = _nt_decnumber
|
256
|
+
if r3
|
257
|
+
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
258
|
+
r1 = r3
|
259
|
+
else
|
260
|
+
r4 = _nt_infin
|
261
|
+
if r4
|
262
|
+
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
263
|
+
r1 = r4
|
264
|
+
else
|
265
|
+
@index = i1
|
266
|
+
r1 = nil
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
270
|
+
s0 << r1
|
271
|
+
if r1
|
272
|
+
r5 = _nt_spec
|
273
|
+
s0 << r5
|
274
|
+
end
|
275
|
+
if s0.last
|
276
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
277
|
+
r0.extend(Number0)
|
278
|
+
r0.extend(Number1)
|
279
|
+
else
|
280
|
+
@index = i0
|
281
|
+
r0 = nil
|
282
|
+
end
|
283
|
+
|
284
|
+
node_cache[:number][start_index] = r0
|
285
|
+
|
286
|
+
r0
|
287
|
+
end
|
288
|
+
|
289
|
+
module String0
|
290
|
+
def spec
|
291
|
+
elements[1]
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
module String1
|
296
|
+
def ast
|
297
|
+
elements[0].ast
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
def _nt_string
|
302
|
+
start_index = index
|
303
|
+
if node_cache[:string].has_key?(index)
|
304
|
+
cached = node_cache[:string][index]
|
305
|
+
if cached
|
306
|
+
node_cache[:string][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
307
|
+
@index = cached.interval.end
|
308
|
+
end
|
309
|
+
return cached
|
310
|
+
end
|
311
|
+
|
312
|
+
i0, s0 = index, []
|
313
|
+
i1 = index
|
314
|
+
r2 = _nt_tstr
|
315
|
+
if r2
|
316
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
317
|
+
r1 = r2
|
318
|
+
else
|
319
|
+
r3 = _nt_bstr
|
320
|
+
if r3
|
321
|
+
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
322
|
+
r1 = r3
|
323
|
+
else
|
324
|
+
@index = i1
|
325
|
+
r1 = nil
|
326
|
+
end
|
327
|
+
end
|
328
|
+
s0 << r1
|
329
|
+
if r1
|
330
|
+
r4 = _nt_spec
|
331
|
+
s0 << r4
|
332
|
+
end
|
333
|
+
if s0.last
|
334
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
335
|
+
r0.extend(String0)
|
336
|
+
r0.extend(String1)
|
337
|
+
else
|
338
|
+
@index = i0
|
339
|
+
r0 = nil
|
340
|
+
end
|
341
|
+
|
342
|
+
node_cache[:string][start_index] = r0
|
343
|
+
|
344
|
+
r0
|
345
|
+
end
|
346
|
+
|
249
347
|
def _nt_sign
|
250
348
|
start_index = index
|
251
349
|
if node_cache[:sign].has_key?(index)
|
@@ -1026,16 +1124,20 @@ module EDNGRAMMAR
|
|
1026
1124
|
elements[0]
|
1027
1125
|
end
|
1028
1126
|
|
1127
|
+
def spec
|
1128
|
+
elements[1]
|
1129
|
+
end
|
1130
|
+
|
1029
1131
|
def S1
|
1030
|
-
elements[
|
1132
|
+
elements[3]
|
1031
1133
|
end
|
1032
1134
|
|
1033
1135
|
def item
|
1034
|
-
elements[
|
1136
|
+
elements[4]
|
1035
1137
|
end
|
1036
1138
|
|
1037
1139
|
def S2
|
1038
|
-
elements[
|
1140
|
+
elements[5]
|
1039
1141
|
end
|
1040
1142
|
|
1041
1143
|
end
|
@@ -1061,32 +1163,36 @@ module EDNGRAMMAR
|
|
1061
1163
|
r1 = _nt_uint
|
1062
1164
|
s0 << r1
|
1063
1165
|
if r1
|
1064
|
-
|
1065
|
-
r2 = true
|
1066
|
-
@index += match_len
|
1067
|
-
else
|
1068
|
-
terminal_parse_failure('"("')
|
1069
|
-
r2 = nil
|
1070
|
-
end
|
1166
|
+
r2 = _nt_spec
|
1071
1167
|
s0 << r2
|
1072
1168
|
if r2
|
1073
|
-
|
1169
|
+
if (match_len = has_terminal?("(", false, index))
|
1170
|
+
r3 = true
|
1171
|
+
@index += match_len
|
1172
|
+
else
|
1173
|
+
terminal_parse_failure('"("')
|
1174
|
+
r3 = nil
|
1175
|
+
end
|
1074
1176
|
s0 << r3
|
1075
1177
|
if r3
|
1076
|
-
r4 =
|
1178
|
+
r4 = _nt_S
|
1077
1179
|
s0 << r4
|
1078
1180
|
if r4
|
1079
|
-
r5 =
|
1181
|
+
r5 = _nt_item
|
1080
1182
|
s0 << r5
|
1081
1183
|
if r5
|
1082
|
-
|
1083
|
-
r6 = true
|
1084
|
-
@index += match_len
|
1085
|
-
else
|
1086
|
-
terminal_parse_failure('")"')
|
1087
|
-
r6 = nil
|
1088
|
-
end
|
1184
|
+
r6 = _nt_S
|
1089
1185
|
s0 << r6
|
1186
|
+
if r6
|
1187
|
+
if (match_len = has_terminal?(")", false, index))
|
1188
|
+
r7 = true
|
1189
|
+
@index += match_len
|
1190
|
+
else
|
1191
|
+
terminal_parse_failure('")"')
|
1192
|
+
r7 = nil
|
1193
|
+
end
|
1194
|
+
s0 << r7
|
1195
|
+
end
|
1090
1196
|
end
|
1091
1197
|
end
|
1092
1198
|
end
|
@@ -1298,8 +1404,14 @@ module EDNGRAMMAR
|
|
1298
1404
|
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
1299
1405
|
r0 = r2
|
1300
1406
|
else
|
1301
|
-
|
1302
|
-
|
1407
|
+
r3 = _nt_embedded
|
1408
|
+
if r3
|
1409
|
+
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
1410
|
+
r0 = r3
|
1411
|
+
else
|
1412
|
+
@index = i0
|
1413
|
+
r0 = nil
|
1414
|
+
end
|
1303
1415
|
end
|
1304
1416
|
end
|
1305
1417
|
|
@@ -1477,8 +1589,12 @@ module EDNGRAMMAR
|
|
1477
1589
|
else
|
1478
1590
|
[]
|
1479
1591
|
end
|
1480
|
-
if spec.ast
|
1481
|
-
|
1592
|
+
if ei = spec.ast
|
1593
|
+
if ei == ""
|
1594
|
+
r.cbor_stream!
|
1595
|
+
else
|
1596
|
+
warn "*** ignoring unimplemented encoding indicator #{ei.inspect} after ["
|
1597
|
+
end
|
1482
1598
|
end
|
1483
1599
|
r
|
1484
1600
|
end
|
@@ -1640,8 +1756,12 @@ module EDNGRAMMAR
|
|
1640
1756
|
else
|
1641
1757
|
{}
|
1642
1758
|
end
|
1643
|
-
if spec.ast
|
1644
|
-
|
1759
|
+
if ei = spec.ast
|
1760
|
+
if ei == ""
|
1761
|
+
r.cbor_stream!
|
1762
|
+
else
|
1763
|
+
warn "*** ignoring unimplemented encoding indicator #{ei.inspect} after \x7b"
|
1764
|
+
end
|
1645
1765
|
end
|
1646
1766
|
r
|
1647
1767
|
end
|
@@ -2281,7 +2401,7 @@ module EDNGRAMMAR
|
|
2281
2401
|
elements[1]
|
2282
2402
|
end
|
2283
2403
|
|
2284
|
-
def
|
2404
|
+
def string
|
2285
2405
|
elements[2]
|
2286
2406
|
end
|
2287
2407
|
|
@@ -2295,7 +2415,7 @@ module EDNGRAMMAR
|
|
2295
2415
|
elements[1]
|
2296
2416
|
end
|
2297
2417
|
|
2298
|
-
def
|
2418
|
+
def string
|
2299
2419
|
elements[2]
|
2300
2420
|
end
|
2301
2421
|
|
@@ -2310,36 +2430,13 @@ module EDNGRAMMAR
|
|
2310
2430
|
end
|
2311
2431
|
|
2312
2432
|
module Streamstring2
|
2313
|
-
def
|
2314
|
-
elements[
|
2315
|
-
|
2316
|
-
|
2317
|
-
|
2318
|
-
|
2319
|
-
end
|
2320
|
-
|
2321
|
-
def S2
|
2322
|
-
elements[3]
|
2323
|
-
end
|
2324
|
-
end
|
2325
|
-
|
2326
|
-
module Streamstring3
|
2327
|
-
def spec1
|
2328
|
-
elements[1]
|
2329
|
-
end
|
2330
|
-
|
2331
|
-
def bstr
|
2332
|
-
elements[2]
|
2333
|
-
end
|
2334
|
-
|
2335
|
-
def S
|
2336
|
-
elements[3]
|
2337
|
-
end
|
2338
|
-
|
2339
|
-
def OC
|
2340
|
-
elements[5]
|
2433
|
+
def ast
|
2434
|
+
strings = [elements[2].ast] + elements[4].elements.map {|x| x.string.ast }
|
2435
|
+
unless Set[*strings.map(&:encoding)].size == 1
|
2436
|
+
warn "*** mixed streamstring #{strings.cbor_diagnostic}"
|
2437
|
+
end
|
2438
|
+
strings.join.cbor_stream!(strings.map(&:size))
|
2341
2439
|
end
|
2342
|
-
|
2343
2440
|
end
|
2344
2441
|
|
2345
2442
|
def _nt_streamstring
|
@@ -2353,182 +2450,88 @@ module EDNGRAMMAR
|
|
2353
2450
|
return cached
|
2354
2451
|
end
|
2355
2452
|
|
2356
|
-
i0 = index
|
2357
|
-
i1, s1 = index, []
|
2453
|
+
i0, s0 = index, []
|
2358
2454
|
if (match_len = has_terminal?("(", false, index))
|
2359
|
-
|
2455
|
+
r1 = true
|
2360
2456
|
@index += match_len
|
2361
2457
|
else
|
2362
2458
|
terminal_parse_failure('"("')
|
2363
|
-
|
2459
|
+
r1 = nil
|
2364
2460
|
end
|
2365
|
-
|
2366
|
-
if
|
2367
|
-
|
2368
|
-
|
2369
|
-
if
|
2370
|
-
|
2371
|
-
|
2372
|
-
if
|
2373
|
-
|
2374
|
-
|
2375
|
-
if
|
2376
|
-
|
2461
|
+
s0 << r1
|
2462
|
+
if r1
|
2463
|
+
r2 = _nt_spec1
|
2464
|
+
s0 << r2
|
2465
|
+
if r2
|
2466
|
+
r3 = _nt_string
|
2467
|
+
s0 << r3
|
2468
|
+
if r3
|
2469
|
+
r4 = _nt_S
|
2470
|
+
s0 << r4
|
2471
|
+
if r4
|
2472
|
+
s5, i5 = [], index
|
2377
2473
|
loop do
|
2378
|
-
|
2474
|
+
i6, s6 = index, []
|
2379
2475
|
if (match_len = has_terminal?(",", false, index))
|
2380
|
-
|
2476
|
+
r7 = true
|
2381
2477
|
@index += match_len
|
2382
2478
|
else
|
2383
2479
|
terminal_parse_failure('","')
|
2384
|
-
|
2480
|
+
r7 = nil
|
2385
2481
|
end
|
2386
|
-
|
2387
|
-
if
|
2388
|
-
|
2389
|
-
|
2390
|
-
if
|
2391
|
-
|
2392
|
-
|
2393
|
-
if
|
2394
|
-
|
2395
|
-
|
2482
|
+
s6 << r7
|
2483
|
+
if r7
|
2484
|
+
r8 = _nt_S
|
2485
|
+
s6 << r8
|
2486
|
+
if r8
|
2487
|
+
r9 = _nt_string
|
2488
|
+
s6 << r9
|
2489
|
+
if r9
|
2490
|
+
r10 = _nt_S
|
2491
|
+
s6 << r10
|
2396
2492
|
end
|
2397
2493
|
end
|
2398
2494
|
end
|
2399
|
-
if
|
2400
|
-
|
2401
|
-
|
2495
|
+
if s6.last
|
2496
|
+
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
2497
|
+
r6.extend(Streamstring0)
|
2402
2498
|
else
|
2403
|
-
@index =
|
2404
|
-
|
2499
|
+
@index = i6
|
2500
|
+
r6 = nil
|
2405
2501
|
end
|
2406
|
-
if
|
2407
|
-
|
2502
|
+
if r6
|
2503
|
+
s5 << r6
|
2408
2504
|
else
|
2409
2505
|
break
|
2410
2506
|
end
|
2411
2507
|
end
|
2412
|
-
|
2413
|
-
|
2414
|
-
if
|
2415
|
-
|
2416
|
-
|
2417
|
-
if
|
2508
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
2509
|
+
s0 << r5
|
2510
|
+
if r5
|
2511
|
+
r11 = _nt_OC
|
2512
|
+
s0 << r11
|
2513
|
+
if r11
|
2418
2514
|
if (match_len = has_terminal?(")", false, index))
|
2419
|
-
|
2515
|
+
r12 = true
|
2420
2516
|
@index += match_len
|
2421
2517
|
else
|
2422
2518
|
terminal_parse_failure('")"')
|
2423
|
-
|
2519
|
+
r12 = nil
|
2424
2520
|
end
|
2425
|
-
|
2521
|
+
s0 << r12
|
2426
2522
|
end
|
2427
2523
|
end
|
2428
2524
|
end
|
2429
2525
|
end
|
2430
2526
|
end
|
2431
2527
|
end
|
2432
|
-
if
|
2433
|
-
|
2434
|
-
|
2435
|
-
|
2436
|
-
@index = i1
|
2437
|
-
r1 = nil
|
2438
|
-
end
|
2439
|
-
if r1
|
2440
|
-
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
2441
|
-
r0 = r1
|
2528
|
+
if s0.last
|
2529
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
2530
|
+
r0.extend(Streamstring1)
|
2531
|
+
r0.extend(Streamstring2)
|
2442
2532
|
else
|
2443
|
-
|
2444
|
-
|
2445
|
-
r15 = true
|
2446
|
-
@index += match_len
|
2447
|
-
else
|
2448
|
-
terminal_parse_failure('"("')
|
2449
|
-
r15 = nil
|
2450
|
-
end
|
2451
|
-
s14 << r15
|
2452
|
-
if r15
|
2453
|
-
r16 = _nt_spec1
|
2454
|
-
s14 << r16
|
2455
|
-
if r16
|
2456
|
-
r17 = _nt_bstr
|
2457
|
-
s14 << r17
|
2458
|
-
if r17
|
2459
|
-
r18 = _nt_S
|
2460
|
-
s14 << r18
|
2461
|
-
if r18
|
2462
|
-
s19, i19 = [], index
|
2463
|
-
loop do
|
2464
|
-
i20, s20 = index, []
|
2465
|
-
if (match_len = has_terminal?(",", false, index))
|
2466
|
-
r21 = true
|
2467
|
-
@index += match_len
|
2468
|
-
else
|
2469
|
-
terminal_parse_failure('","')
|
2470
|
-
r21 = nil
|
2471
|
-
end
|
2472
|
-
s20 << r21
|
2473
|
-
if r21
|
2474
|
-
r22 = _nt_S
|
2475
|
-
s20 << r22
|
2476
|
-
if r22
|
2477
|
-
r23 = _nt_bstr
|
2478
|
-
s20 << r23
|
2479
|
-
if r23
|
2480
|
-
r24 = _nt_S
|
2481
|
-
s20 << r24
|
2482
|
-
end
|
2483
|
-
end
|
2484
|
-
end
|
2485
|
-
if s20.last
|
2486
|
-
r20 = instantiate_node(SyntaxNode,input, i20...index, s20)
|
2487
|
-
r20.extend(Streamstring2)
|
2488
|
-
else
|
2489
|
-
@index = i20
|
2490
|
-
r20 = nil
|
2491
|
-
end
|
2492
|
-
if r20
|
2493
|
-
s19 << r20
|
2494
|
-
else
|
2495
|
-
break
|
2496
|
-
end
|
2497
|
-
end
|
2498
|
-
r19 = instantiate_node(SyntaxNode,input, i19...index, s19)
|
2499
|
-
s14 << r19
|
2500
|
-
if r19
|
2501
|
-
r25 = _nt_OC
|
2502
|
-
s14 << r25
|
2503
|
-
if r25
|
2504
|
-
if (match_len = has_terminal?(")", false, index))
|
2505
|
-
r26 = true
|
2506
|
-
@index += match_len
|
2507
|
-
else
|
2508
|
-
terminal_parse_failure('")"')
|
2509
|
-
r26 = nil
|
2510
|
-
end
|
2511
|
-
s14 << r26
|
2512
|
-
end
|
2513
|
-
end
|
2514
|
-
end
|
2515
|
-
end
|
2516
|
-
end
|
2517
|
-
end
|
2518
|
-
if s14.last
|
2519
|
-
r14 = instantiate_node(SyntaxNode,input, i14...index, s14)
|
2520
|
-
r14.extend(Streamstring3)
|
2521
|
-
else
|
2522
|
-
@index = i14
|
2523
|
-
r14 = nil
|
2524
|
-
end
|
2525
|
-
if r14
|
2526
|
-
r14 = SyntaxNode.new(input, (index-1)...index) if r14 == true
|
2527
|
-
r0 = r14
|
2528
|
-
else
|
2529
|
-
@index = i0
|
2530
|
-
r0 = nil
|
2531
|
-
end
|
2533
|
+
@index = i0
|
2534
|
+
r0 = nil
|
2532
2535
|
end
|
2533
2536
|
|
2534
2537
|
node_cache[:streamstring][start_index] = r0
|
@@ -2538,19 +2541,16 @@ module EDNGRAMMAR
|
|
2538
2541
|
|
2539
2542
|
module Spec0
|
2540
2543
|
def S
|
2541
|
-
elements[
|
2544
|
+
elements[2]
|
2542
2545
|
end
|
2543
2546
|
end
|
2544
2547
|
|
2545
2548
|
module Spec1
|
2546
|
-
def
|
2547
|
-
|
2548
|
-
|
2549
|
-
|
2550
|
-
|
2551
|
-
|
2552
|
-
module Spec2
|
2553
|
-
def ast; (e1 = elements[1].elements) && !e1[0].empty? end
|
2549
|
+
def ast;
|
2550
|
+
if (e1 = elements[1].elements) && !e1[0].empty?
|
2551
|
+
e1[1].text_value
|
2552
|
+
end
|
2553
|
+
end
|
2554
2554
|
end
|
2555
2555
|
|
2556
2556
|
def _nt_spec
|
@@ -2564,44 +2564,43 @@ module EDNGRAMMAR
|
|
2564
2564
|
return cached
|
2565
2565
|
end
|
2566
2566
|
|
2567
|
-
|
2568
|
-
|
2569
|
-
|
2570
|
-
|
2571
|
-
|
2572
|
-
|
2573
|
-
|
2574
|
-
|
2575
|
-
|
2576
|
-
|
2577
|
-
|
2578
|
-
|
2579
|
-
|
2580
|
-
|
2581
|
-
|
2582
|
-
|
2583
|
-
|
2584
|
-
|
2585
|
-
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
2586
|
-
r3.extend(Spec0)
|
2587
|
-
else
|
2588
|
-
@index = i3
|
2589
|
-
r3 = nil
|
2567
|
+
i1, s1 = index, []
|
2568
|
+
if (match_len = has_terminal?("_", false, index))
|
2569
|
+
r2 = true
|
2570
|
+
@index += match_len
|
2571
|
+
else
|
2572
|
+
terminal_parse_failure('"_"')
|
2573
|
+
r2 = nil
|
2574
|
+
end
|
2575
|
+
s1 << r2
|
2576
|
+
if r2
|
2577
|
+
s3, i3 = [], index
|
2578
|
+
loop do
|
2579
|
+
r4 = _nt_wordchar
|
2580
|
+
if r4
|
2581
|
+
s3 << r4
|
2582
|
+
else
|
2583
|
+
break
|
2584
|
+
end
|
2590
2585
|
end
|
2586
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
2587
|
+
s1 << r3
|
2591
2588
|
if r3
|
2592
|
-
|
2593
|
-
|
2594
|
-
r2 = instantiate_node(SyntaxNode,input, index...index)
|
2589
|
+
r5 = _nt_S
|
2590
|
+
s1 << r5
|
2595
2591
|
end
|
2596
|
-
s0 << r2
|
2597
2592
|
end
|
2598
|
-
if
|
2599
|
-
|
2600
|
-
|
2601
|
-
r0.extend(Spec2)
|
2593
|
+
if s1.last
|
2594
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
2595
|
+
r1.extend(Spec0)
|
2602
2596
|
else
|
2603
|
-
@index =
|
2604
|
-
|
2597
|
+
@index = i1
|
2598
|
+
r1 = nil
|
2599
|
+
end
|
2600
|
+
if r1
|
2601
|
+
r0 = r1
|
2602
|
+
else
|
2603
|
+
r0 = instantiate_node(SyntaxNode,input, index...index)
|
2605
2604
|
end
|
2606
2605
|
|
2607
2606
|
node_cache[:spec][start_index] = r0
|
@@ -2610,12 +2609,8 @@ module EDNGRAMMAR
|
|
2610
2609
|
end
|
2611
2610
|
|
2612
2611
|
module Spec10
|
2613
|
-
def
|
2614
|
-
elements[
|
2615
|
-
end
|
2616
|
-
|
2617
|
-
def S2
|
2618
|
-
elements[2]
|
2612
|
+
def S
|
2613
|
+
elements[1]
|
2619
2614
|
end
|
2620
2615
|
end
|
2621
2616
|
|
@@ -2631,21 +2626,17 @@ module EDNGRAMMAR
|
|
2631
2626
|
end
|
2632
2627
|
|
2633
2628
|
i0, s0 = index, []
|
2634
|
-
|
2629
|
+
if (match_len = has_terminal?("_", false, index))
|
2630
|
+
r1 = true
|
2631
|
+
@index += match_len
|
2632
|
+
else
|
2633
|
+
terminal_parse_failure('"_"')
|
2634
|
+
r1 = nil
|
2635
|
+
end
|
2635
2636
|
s0 << r1
|
2636
2637
|
if r1
|
2637
|
-
|
2638
|
-
r2 = true
|
2639
|
-
@index += match_len
|
2640
|
-
else
|
2641
|
-
terminal_parse_failure('"_"')
|
2642
|
-
r2 = nil
|
2643
|
-
end
|
2638
|
+
r2 = _nt_S
|
2644
2639
|
s0 << r2
|
2645
|
-
if r2
|
2646
|
-
r3 = _nt_S
|
2647
|
-
s0 << r3
|
2648
|
-
end
|
2649
2640
|
end
|
2650
2641
|
if s0.last
|
2651
2642
|
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
@@ -3965,6 +3956,56 @@ module EDNGRAMMAR
|
|
3965
3956
|
r0
|
3966
3957
|
end
|
3967
3958
|
|
3959
|
+
def _nt_wordchar
|
3960
|
+
start_index = index
|
3961
|
+
if node_cache[:wordchar].has_key?(index)
|
3962
|
+
cached = node_cache[:wordchar][index]
|
3963
|
+
if cached
|
3964
|
+
node_cache[:wordchar][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
3965
|
+
@index = cached.interval.end
|
3966
|
+
end
|
3967
|
+
return cached
|
3968
|
+
end
|
3969
|
+
|
3970
|
+
i0 = index
|
3971
|
+
if (match_len = has_terminal?("_", false, index))
|
3972
|
+
r1 = true
|
3973
|
+
@index += match_len
|
3974
|
+
else
|
3975
|
+
terminal_parse_failure('"_"')
|
3976
|
+
r1 = nil
|
3977
|
+
end
|
3978
|
+
if r1
|
3979
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
3980
|
+
r0 = r1
|
3981
|
+
else
|
3982
|
+
r2 = _nt_lcalnum
|
3983
|
+
if r2
|
3984
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
3985
|
+
r0 = r2
|
3986
|
+
else
|
3987
|
+
if has_terminal?(@regexps[gr = '\A[A-Z]'] ||= Regexp.new(gr), :regexp, index)
|
3988
|
+
r3 = true
|
3989
|
+
@index += 1
|
3990
|
+
else
|
3991
|
+
terminal_parse_failure('[A-Z]')
|
3992
|
+
r3 = nil
|
3993
|
+
end
|
3994
|
+
if r3
|
3995
|
+
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
3996
|
+
r0 = r3
|
3997
|
+
else
|
3998
|
+
@index = i0
|
3999
|
+
r0 = nil
|
4000
|
+
end
|
4001
|
+
end
|
4002
|
+
end
|
4003
|
+
|
4004
|
+
node_cache[:wordchar][start_index] = r0
|
4005
|
+
|
4006
|
+
r0
|
4007
|
+
end
|
4008
|
+
|
3968
4009
|
end
|
3969
4010
|
|
3970
4011
|
class EDNGRAMMARParser < Treetop::Runtime::CompiledParser
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: edn-abnf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|