edn-abnf 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/edn-abnf +1 -1
- data/edn-abnf.gemspec +2 -2
- data/lib/cbor-diagnostic-app/b64.rb +1 -1
- data/lib/cbor-diagnostic-app/b64grammar.rb +195 -16
- data/lib/cbor-diagnostic-app/hgrammar.rb +42 -2
- data/lib/parser/edngrammar.rb +449 -107
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85b82b93fb1a2682e147c29fc1012e178c48f8eae6d60243a7d87abd82c15a3f
|
4
|
+
data.tar.gz: d87f8ca88bc659c58629540a5f7fdefab86c53b09662e64e0851dbaadb8525cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc9cedb1fb36395595382a787268954d887bcf240a92379be884224dd383331750ebcbb3e97b6966364476cb26563357e9e15bc2f443936ee9d6cda6835ff77c
|
7
|
+
data.tar.gz: ae270987f189617657a5484824b44ef4468dfcd3911dc345492e0c2a56c9710af74086145fe55b5f4291c6373f5b0744a8c4ad4e637a426473a13866c189d042
|
data/bin/edn-abnf
CHANGED
data/edn-abnf.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "edn-abnf"
|
3
|
-
s.version = "0.1.
|
4
|
-
s.summary = "CBOR Extended Diagnostic Notation implemented in ABNF"
|
3
|
+
s.version = "0.1.3"
|
4
|
+
s.summary = "CBOR Extended Diagnostic Notation (EDN) implemented in ABNF"
|
5
5
|
s.description = %q{edn-abnf implements converters and miscellaneous tools for CBOR EDN's ABNF}
|
6
6
|
s.author = "Carsten Bormann"
|
7
7
|
s.email = "cabo@tzi.org"
|
@@ -8,7 +8,7 @@ class CBOR_DIAG::App_b64
|
|
8
8
|
raise ArgumentError, "cbor-diagnostic: Parse Error in b64'#{s}':\n" << EDN.reason(parser, s)
|
9
9
|
end
|
10
10
|
# lazy -- not using parse tree...:
|
11
|
-
t = s.gsub(/\s/, '').chars.each_slice(4).map(&:join)
|
11
|
+
t = s.gsub(/\s|#[^\n]*(?:\n|\z)/, '').chars.each_slice(4).map(&:join)
|
12
12
|
if last = t[-1]
|
13
13
|
last << "=" * (4 - last.size)
|
14
14
|
end
|
@@ -60,6 +60,9 @@ module B64GRAMMAR
|
|
60
60
|
end
|
61
61
|
|
62
62
|
module AppStringB644
|
63
|
+
end
|
64
|
+
|
65
|
+
module AppStringB645
|
63
66
|
def B
|
64
67
|
elements[0]
|
65
68
|
end
|
@@ -238,11 +241,48 @@ module B64GRAMMAR
|
|
238
241
|
r7 = instantiate_node(SyntaxNode,input, index...index)
|
239
242
|
end
|
240
243
|
s0 << r7
|
244
|
+
if r7
|
245
|
+
i26, s26 = index, []
|
246
|
+
if (match_len = has_terminal?("#", false, index))
|
247
|
+
r27 = true
|
248
|
+
@index += match_len
|
249
|
+
else
|
250
|
+
terminal_parse_failure('"#"')
|
251
|
+
r27 = nil
|
252
|
+
end
|
253
|
+
s26 << r27
|
254
|
+
if r27
|
255
|
+
s28, i28 = [], index
|
256
|
+
loop do
|
257
|
+
r29 = _nt_inon_lf
|
258
|
+
if r29
|
259
|
+
s28 << r29
|
260
|
+
else
|
261
|
+
break
|
262
|
+
end
|
263
|
+
end
|
264
|
+
r28 = instantiate_node(SyntaxNode,input, i28...index, s28)
|
265
|
+
s26 << r28
|
266
|
+
end
|
267
|
+
if s26.last
|
268
|
+
r26 = instantiate_node(SyntaxNode,input, i26...index, s26)
|
269
|
+
r26.extend(AppStringB644)
|
270
|
+
else
|
271
|
+
@index = i26
|
272
|
+
r26 = nil
|
273
|
+
end
|
274
|
+
if r26
|
275
|
+
r25 = r26
|
276
|
+
else
|
277
|
+
r25 = instantiate_node(SyntaxNode,input, index...index)
|
278
|
+
end
|
279
|
+
s0 << r25
|
280
|
+
end
|
241
281
|
end
|
242
282
|
end
|
243
283
|
if s0.last
|
244
284
|
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
245
|
-
r0.extend(
|
285
|
+
r0.extend(AppStringB645)
|
246
286
|
else
|
247
287
|
@index = i0
|
248
288
|
r0 = nil
|
@@ -333,6 +373,16 @@ module B64GRAMMAR
|
|
333
373
|
r0
|
334
374
|
end
|
335
375
|
|
376
|
+
module B0
|
377
|
+
def icomment
|
378
|
+
elements[0]
|
379
|
+
end
|
380
|
+
|
381
|
+
end
|
382
|
+
|
383
|
+
module B1
|
384
|
+
end
|
385
|
+
|
336
386
|
def _nt_B
|
337
387
|
start_index = index
|
338
388
|
if node_cache[:B].has_key?(index)
|
@@ -344,16 +394,60 @@ module B64GRAMMAR
|
|
344
394
|
return cached
|
345
395
|
end
|
346
396
|
|
347
|
-
|
397
|
+
i0, s0 = index, []
|
398
|
+
s1, i1 = [], index
|
348
399
|
loop do
|
349
|
-
|
350
|
-
if
|
351
|
-
|
400
|
+
r2 = _nt_iblank
|
401
|
+
if r2
|
402
|
+
s1 << r2
|
352
403
|
else
|
353
404
|
break
|
354
405
|
end
|
355
406
|
end
|
356
|
-
|
407
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
408
|
+
s0 << r1
|
409
|
+
if r1
|
410
|
+
s3, i3 = [], index
|
411
|
+
loop do
|
412
|
+
i4, s4 = index, []
|
413
|
+
r5 = _nt_icomment
|
414
|
+
s4 << r5
|
415
|
+
if r5
|
416
|
+
s6, i6 = [], index
|
417
|
+
loop do
|
418
|
+
r7 = _nt_iblank
|
419
|
+
if r7
|
420
|
+
s6 << r7
|
421
|
+
else
|
422
|
+
break
|
423
|
+
end
|
424
|
+
end
|
425
|
+
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
426
|
+
s4 << r6
|
427
|
+
end
|
428
|
+
if s4.last
|
429
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
430
|
+
r4.extend(B0)
|
431
|
+
else
|
432
|
+
@index = i4
|
433
|
+
r4 = nil
|
434
|
+
end
|
435
|
+
if r4
|
436
|
+
s3 << r4
|
437
|
+
else
|
438
|
+
break
|
439
|
+
end
|
440
|
+
end
|
441
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
442
|
+
s0 << r3
|
443
|
+
end
|
444
|
+
if s0.last
|
445
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
446
|
+
r0.extend(B1)
|
447
|
+
else
|
448
|
+
@index = i0
|
449
|
+
r0 = nil
|
450
|
+
end
|
357
451
|
|
358
452
|
node_cache[:B][start_index] = r0
|
359
453
|
|
@@ -404,26 +498,105 @@ module B64GRAMMAR
|
|
404
498
|
r0
|
405
499
|
end
|
406
500
|
|
407
|
-
|
501
|
+
module Icomment0
|
502
|
+
end
|
503
|
+
|
504
|
+
def _nt_icomment
|
408
505
|
start_index = index
|
409
|
-
if node_cache[:
|
410
|
-
cached = node_cache[:
|
506
|
+
if node_cache[:icomment].has_key?(index)
|
507
|
+
cached = node_cache[:icomment][index]
|
411
508
|
if cached
|
412
|
-
node_cache[:
|
509
|
+
node_cache[:icomment][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
413
510
|
@index = cached.interval.end
|
414
511
|
end
|
415
512
|
return cached
|
416
513
|
end
|
417
514
|
|
418
|
-
|
419
|
-
|
420
|
-
|
515
|
+
i0, s0 = index, []
|
516
|
+
if (match_len = has_terminal?("#", false, index))
|
517
|
+
r1 = true
|
518
|
+
@index += match_len
|
519
|
+
else
|
520
|
+
terminal_parse_failure('"#"')
|
521
|
+
r1 = nil
|
522
|
+
end
|
523
|
+
s0 << r1
|
524
|
+
if r1
|
525
|
+
s2, i2 = [], index
|
526
|
+
loop do
|
527
|
+
r3 = _nt_inon_lf
|
528
|
+
if r3
|
529
|
+
s2 << r3
|
530
|
+
else
|
531
|
+
break
|
532
|
+
end
|
533
|
+
end
|
534
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
535
|
+
s0 << r2
|
536
|
+
if r2
|
537
|
+
if (match_len = has_terminal?("\n", false, index))
|
538
|
+
r4 = true
|
539
|
+
@index += match_len
|
540
|
+
else
|
541
|
+
terminal_parse_failure('"\\n"')
|
542
|
+
r4 = nil
|
543
|
+
end
|
544
|
+
s0 << r4
|
545
|
+
end
|
546
|
+
end
|
547
|
+
if s0.last
|
548
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
549
|
+
r0.extend(Icomment0)
|
421
550
|
else
|
422
|
-
|
551
|
+
@index = i0
|
423
552
|
r0 = nil
|
424
553
|
end
|
425
554
|
|
426
|
-
node_cache[:
|
555
|
+
node_cache[:icomment][start_index] = r0
|
556
|
+
|
557
|
+
r0
|
558
|
+
end
|
559
|
+
|
560
|
+
def _nt_inon_lf
|
561
|
+
start_index = index
|
562
|
+
if node_cache[:inon_lf].has_key?(index)
|
563
|
+
cached = node_cache[:inon_lf][index]
|
564
|
+
if cached
|
565
|
+
node_cache[:inon_lf][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
566
|
+
@index = cached.interval.end
|
567
|
+
end
|
568
|
+
return cached
|
569
|
+
end
|
570
|
+
|
571
|
+
i0 = index
|
572
|
+
if has_terminal?(@regexps[gr = '\A[\\ -]'] ||= Regexp.new(gr), :regexp, index)
|
573
|
+
r1 = true
|
574
|
+
@index += 1
|
575
|
+
else
|
576
|
+
terminal_parse_failure('[\\ -]')
|
577
|
+
r1 = nil
|
578
|
+
end
|
579
|
+
if r1
|
580
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
581
|
+
r0 = r1
|
582
|
+
else
|
583
|
+
if has_terminal?(@regexps[gr = '\A[-]'] ||= Regexp.new(gr), :regexp, index)
|
584
|
+
r2 = true
|
585
|
+
@index += 1
|
586
|
+
else
|
587
|
+
terminal_parse_failure('[-]')
|
588
|
+
r2 = nil
|
589
|
+
end
|
590
|
+
if r2
|
591
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
592
|
+
r0 = r2
|
593
|
+
else
|
594
|
+
@index = i0
|
595
|
+
r0 = nil
|
596
|
+
end
|
597
|
+
end
|
598
|
+
|
599
|
+
node_cache[:inon_lf][start_index] = r0
|
427
600
|
|
428
601
|
r0
|
429
602
|
end
|
@@ -451,7 +624,13 @@ module B64GRAMMAR
|
|
451
624
|
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
452
625
|
r0 = r1
|
453
626
|
else
|
454
|
-
|
627
|
+
if has_terminal?(@regexps[gr = '\A[a-z]'] ||= Regexp.new(gr), :regexp, index)
|
628
|
+
r2 = true
|
629
|
+
@index += 1
|
630
|
+
else
|
631
|
+
terminal_parse_failure('[a-z]')
|
632
|
+
r2 = nil
|
633
|
+
end
|
455
634
|
if r2
|
456
635
|
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
457
636
|
r0 = r2
|
@@ -48,13 +48,16 @@ module HGRAMMAR
|
|
48
48
|
end
|
49
49
|
|
50
50
|
module AppStringH4
|
51
|
+
end
|
52
|
+
|
53
|
+
module AppStringH5
|
51
54
|
def S
|
52
55
|
elements[0]
|
53
56
|
end
|
54
57
|
|
55
58
|
end
|
56
59
|
|
57
|
-
module
|
60
|
+
module AppStringH6
|
58
61
|
def unpack_thread(s)
|
59
62
|
case s[0]
|
60
63
|
when CBOR::Tagged
|
@@ -161,11 +164,48 @@ module HGRAMMAR
|
|
161
164
|
end
|
162
165
|
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
163
166
|
s0 << r2
|
167
|
+
if r2
|
168
|
+
i13, s13 = index, []
|
169
|
+
if (match_len = has_terminal?("#", false, index))
|
170
|
+
r14 = true
|
171
|
+
@index += match_len
|
172
|
+
else
|
173
|
+
terminal_parse_failure('"#"')
|
174
|
+
r14 = nil
|
175
|
+
end
|
176
|
+
s13 << r14
|
177
|
+
if r14
|
178
|
+
s15, i15 = [], index
|
179
|
+
loop do
|
180
|
+
r16 = _nt_non_lf
|
181
|
+
if r16
|
182
|
+
s15 << r16
|
183
|
+
else
|
184
|
+
break
|
185
|
+
end
|
186
|
+
end
|
187
|
+
r15 = instantiate_node(SyntaxNode,input, i15...index, s15)
|
188
|
+
s13 << r15
|
189
|
+
end
|
190
|
+
if s13.last
|
191
|
+
r13 = instantiate_node(SyntaxNode,input, i13...index, s13)
|
192
|
+
r13.extend(AppStringH4)
|
193
|
+
else
|
194
|
+
@index = i13
|
195
|
+
r13 = nil
|
196
|
+
end
|
197
|
+
if r13
|
198
|
+
r12 = r13
|
199
|
+
else
|
200
|
+
r12 = instantiate_node(SyntaxNode,input, index...index)
|
201
|
+
end
|
202
|
+
s0 << r12
|
203
|
+
end
|
164
204
|
end
|
165
205
|
if s0.last
|
166
206
|
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
167
|
-
r0.extend(AppStringH4)
|
168
207
|
r0.extend(AppStringH5)
|
208
|
+
r0.extend(AppStringH6)
|
169
209
|
else
|
170
210
|
@index = i0
|
171
211
|
r0 = nil
|
data/lib/parser/edngrammar.rb
CHANGED
@@ -222,73 +222,6 @@ module EDNGRAMMAR
|
|
222
222
|
r0
|
223
223
|
end
|
224
224
|
|
225
|
-
module Number0
|
226
|
-
def spec
|
227
|
-
elements[1]
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
module Number1
|
232
|
-
def ast
|
233
|
-
if ei = spec.text_value[1..-1]
|
234
|
-
warn "*** ignoring unimplemented encoding indicator #{ei.inspect} for #{elements[0].text_value}"
|
235
|
-
end
|
236
|
-
elements[0].ast
|
237
|
-
end
|
238
|
-
end
|
239
|
-
|
240
|
-
def _nt_number
|
241
|
-
start_index = index
|
242
|
-
if node_cache[:number].has_key?(index)
|
243
|
-
cached = node_cache[:number][index]
|
244
|
-
if cached
|
245
|
-
node_cache[:number][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
246
|
-
@index = cached.interval.end
|
247
|
-
end
|
248
|
-
return cached
|
249
|
-
end
|
250
|
-
|
251
|
-
i0, s0 = index, []
|
252
|
-
i1 = index
|
253
|
-
r2 = _nt_basenumber
|
254
|
-
if r2
|
255
|
-
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
256
|
-
r1 = r2
|
257
|
-
else
|
258
|
-
r3 = _nt_decnumber
|
259
|
-
if r3
|
260
|
-
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
261
|
-
r1 = r3
|
262
|
-
else
|
263
|
-
r4 = _nt_infin
|
264
|
-
if r4
|
265
|
-
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
266
|
-
r1 = r4
|
267
|
-
else
|
268
|
-
@index = i1
|
269
|
-
r1 = nil
|
270
|
-
end
|
271
|
-
end
|
272
|
-
end
|
273
|
-
s0 << r1
|
274
|
-
if r1
|
275
|
-
r5 = _nt_spec
|
276
|
-
s0 << r5
|
277
|
-
end
|
278
|
-
if s0.last
|
279
|
-
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
280
|
-
r0.extend(Number0)
|
281
|
-
r0.extend(Number1)
|
282
|
-
else
|
283
|
-
@index = i0
|
284
|
-
r0 = nil
|
285
|
-
end
|
286
|
-
|
287
|
-
node_cache[:number][start_index] = r0
|
288
|
-
|
289
|
-
r0
|
290
|
-
end
|
291
|
-
|
292
225
|
module String10
|
293
226
|
def spec
|
294
227
|
elements[1]
|
@@ -522,6 +455,73 @@ module EDNGRAMMAR
|
|
522
455
|
r0
|
523
456
|
end
|
524
457
|
|
458
|
+
module Number0
|
459
|
+
def spec
|
460
|
+
elements[1]
|
461
|
+
end
|
462
|
+
end
|
463
|
+
|
464
|
+
module Number1
|
465
|
+
def ast
|
466
|
+
if ei = spec.text_value[1..-1]
|
467
|
+
warn "*** ignoring unimplemented encoding indicator #{ei.inspect} for #{elements[0].text_value}"
|
468
|
+
end
|
469
|
+
elements[0].ast
|
470
|
+
end
|
471
|
+
end
|
472
|
+
|
473
|
+
def _nt_number
|
474
|
+
start_index = index
|
475
|
+
if node_cache[:number].has_key?(index)
|
476
|
+
cached = node_cache[:number][index]
|
477
|
+
if cached
|
478
|
+
node_cache[:number][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
479
|
+
@index = cached.interval.end
|
480
|
+
end
|
481
|
+
return cached
|
482
|
+
end
|
483
|
+
|
484
|
+
i0, s0 = index, []
|
485
|
+
i1 = index
|
486
|
+
r2 = _nt_basenumber
|
487
|
+
if r2
|
488
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
489
|
+
r1 = r2
|
490
|
+
else
|
491
|
+
r3 = _nt_decnumber
|
492
|
+
if r3
|
493
|
+
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
494
|
+
r1 = r3
|
495
|
+
else
|
496
|
+
r4 = _nt_infin
|
497
|
+
if r4
|
498
|
+
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
499
|
+
r1 = r4
|
500
|
+
else
|
501
|
+
@index = i1
|
502
|
+
r1 = nil
|
503
|
+
end
|
504
|
+
end
|
505
|
+
end
|
506
|
+
s0 << r1
|
507
|
+
if r1
|
508
|
+
r5 = _nt_spec
|
509
|
+
s0 << r5
|
510
|
+
end
|
511
|
+
if s0.last
|
512
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
513
|
+
r0.extend(Number0)
|
514
|
+
r0.extend(Number1)
|
515
|
+
else
|
516
|
+
@index = i0
|
517
|
+
r0 = nil
|
518
|
+
end
|
519
|
+
|
520
|
+
node_cache[:number][start_index] = r0
|
521
|
+
|
522
|
+
r0
|
523
|
+
end
|
524
|
+
|
525
525
|
def _nt_sign
|
526
526
|
start_index = index
|
527
527
|
if node_cache[:sign].has_key?(index)
|
@@ -3251,10 +3251,20 @@ module EDNGRAMMAR
|
|
3251
3251
|
end
|
3252
3252
|
|
3253
3253
|
module Hexchar0
|
3254
|
-
def ast; hex_value.chr(Encoding::UTF_8) end
|
3255
3254
|
end
|
3256
3255
|
|
3257
3256
|
module Hexchar1
|
3257
|
+
end
|
3258
|
+
|
3259
|
+
module Hexchar2
|
3260
|
+
def ast; elements[1].hex_value.chr(Encoding::UTF_8) end
|
3261
|
+
end
|
3262
|
+
|
3263
|
+
module Hexchar3
|
3264
|
+
def ast; hex_value.chr(Encoding::UTF_8) end
|
3265
|
+
end
|
3266
|
+
|
3267
|
+
module Hexchar4
|
3258
3268
|
def high_surrogate
|
3259
3269
|
elements[0]
|
3260
3270
|
end
|
@@ -3264,7 +3274,7 @@ module EDNGRAMMAR
|
|
3264
3274
|
end
|
3265
3275
|
end
|
3266
3276
|
|
3267
|
-
module
|
3277
|
+
module Hexchar5
|
3268
3278
|
def ast
|
3269
3279
|
((high_surrogate.ast << 10) + low_surrogate.ast + 0x10000).chr(Encoding::UTF_8)
|
3270
3280
|
end
|
@@ -3282,54 +3292,142 @@ module EDNGRAMMAR
|
|
3282
3292
|
end
|
3283
3293
|
|
3284
3294
|
i0 = index
|
3285
|
-
|
3286
|
-
|
3287
|
-
|
3288
|
-
|
3289
|
-
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
3290
|
-
r0 = r1
|
3295
|
+
i1, s1 = index, []
|
3296
|
+
if (match_len = has_terminal?("{", false, index))
|
3297
|
+
r2 = true
|
3298
|
+
@index += match_len
|
3291
3299
|
else
|
3292
|
-
|
3293
|
-
|
3294
|
-
|
3300
|
+
terminal_parse_failure('"{"')
|
3301
|
+
r2 = nil
|
3302
|
+
end
|
3303
|
+
s1 << r2
|
3304
|
+
if r2
|
3305
|
+
i3 = index
|
3306
|
+
i4, s4 = index, []
|
3307
|
+
s5, i5 = [], index
|
3308
|
+
loop do
|
3309
|
+
if (match_len = has_terminal?("0", false, index))
|
3310
|
+
r6 = true
|
3311
|
+
@index += match_len
|
3312
|
+
else
|
3313
|
+
terminal_parse_failure('"0"')
|
3314
|
+
r6 = nil
|
3315
|
+
end
|
3316
|
+
if r6
|
3317
|
+
s5 << r6
|
3318
|
+
else
|
3319
|
+
break
|
3320
|
+
end
|
3321
|
+
end
|
3322
|
+
if s5.empty?
|
3323
|
+
@index = i5
|
3324
|
+
r5 = nil
|
3325
|
+
else
|
3326
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
3327
|
+
end
|
3328
|
+
s4 << r5
|
3329
|
+
if r5
|
3330
|
+
r8 = _nt_hexscalar
|
3331
|
+
if r8
|
3332
|
+
r7 = r8
|
3333
|
+
else
|
3334
|
+
r7 = instantiate_node(SyntaxNode,input, index...index)
|
3335
|
+
end
|
3336
|
+
s4 << r7
|
3337
|
+
end
|
3338
|
+
if s4.last
|
3339
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
3340
|
+
r4.extend(Hexchar0)
|
3341
|
+
else
|
3342
|
+
@index = i4
|
3343
|
+
r4 = nil
|
3344
|
+
end
|
3345
|
+
if r4
|
3346
|
+
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
3347
|
+
r3 = r4
|
3348
|
+
else
|
3349
|
+
r9 = _nt_hexscalar
|
3350
|
+
if r9
|
3351
|
+
r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
|
3352
|
+
r3 = r9
|
3353
|
+
else
|
3354
|
+
@index = i3
|
3355
|
+
r3 = nil
|
3356
|
+
end
|
3357
|
+
end
|
3358
|
+
s1 << r3
|
3295
3359
|
if r3
|
3296
|
-
if (match_len = has_terminal?("
|
3297
|
-
|
3360
|
+
if (match_len = has_terminal?("}", false, index))
|
3361
|
+
r10 = true
|
3298
3362
|
@index += match_len
|
3299
3363
|
else
|
3300
|
-
terminal_parse_failure('"
|
3301
|
-
|
3364
|
+
terminal_parse_failure('"}"')
|
3365
|
+
r10 = nil
|
3302
3366
|
end
|
3303
|
-
|
3304
|
-
|
3305
|
-
|
3306
|
-
|
3367
|
+
s1 << r10
|
3368
|
+
end
|
3369
|
+
end
|
3370
|
+
if s1.last
|
3371
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
3372
|
+
r1.extend(Hexchar1)
|
3373
|
+
r1.extend(Hexchar2)
|
3374
|
+
else
|
3375
|
+
@index = i1
|
3376
|
+
r1 = nil
|
3377
|
+
end
|
3378
|
+
if r1
|
3379
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
3380
|
+
r0 = r1
|
3381
|
+
else
|
3382
|
+
r11 = _nt_non_surrogate
|
3383
|
+
r11.extend(Hexchar3)
|
3384
|
+
r11.extend(Hexchar3)
|
3385
|
+
if r11
|
3386
|
+
r11 = SyntaxNode.new(input, (index-1)...index) if r11 == true
|
3387
|
+
r0 = r11
|
3388
|
+
else
|
3389
|
+
i12, s12 = index, []
|
3390
|
+
r13 = _nt_high_surrogate
|
3391
|
+
s12 << r13
|
3392
|
+
if r13
|
3393
|
+
if (match_len = has_terminal?("\\", false, index))
|
3394
|
+
r14 = true
|
3307
3395
|
@index += match_len
|
3308
3396
|
else
|
3309
|
-
terminal_parse_failure('"
|
3310
|
-
|
3397
|
+
terminal_parse_failure('"\\\\"')
|
3398
|
+
r14 = nil
|
3311
3399
|
end
|
3312
|
-
|
3313
|
-
if
|
3314
|
-
|
3315
|
-
|
3400
|
+
s12 << r14
|
3401
|
+
if r14
|
3402
|
+
if (match_len = has_terminal?("u", false, index))
|
3403
|
+
r15 = true
|
3404
|
+
@index += match_len
|
3405
|
+
else
|
3406
|
+
terminal_parse_failure('"u"')
|
3407
|
+
r15 = nil
|
3408
|
+
end
|
3409
|
+
s12 << r15
|
3410
|
+
if r15
|
3411
|
+
r16 = _nt_low_surrogate
|
3412
|
+
s12 << r16
|
3413
|
+
end
|
3316
3414
|
end
|
3317
3415
|
end
|
3318
|
-
|
3319
|
-
|
3320
|
-
|
3321
|
-
|
3322
|
-
|
3323
|
-
|
3324
|
-
|
3325
|
-
|
3326
|
-
|
3327
|
-
|
3328
|
-
|
3329
|
-
|
3330
|
-
|
3331
|
-
|
3332
|
-
|
3416
|
+
if s12.last
|
3417
|
+
r12 = instantiate_node(SyntaxNode,input, i12...index, s12)
|
3418
|
+
r12.extend(Hexchar4)
|
3419
|
+
r12.extend(Hexchar5)
|
3420
|
+
else
|
3421
|
+
@index = i12
|
3422
|
+
r12 = nil
|
3423
|
+
end
|
3424
|
+
if r12
|
3425
|
+
r12 = SyntaxNode.new(input, (index-1)...index) if r12 == true
|
3426
|
+
r0 = r12
|
3427
|
+
else
|
3428
|
+
@index = i0
|
3429
|
+
r0 = nil
|
3430
|
+
end
|
3333
3431
|
end
|
3334
3432
|
end
|
3335
3433
|
|
@@ -3762,6 +3860,152 @@ module EDNGRAMMAR
|
|
3762
3860
|
r0
|
3763
3861
|
end
|
3764
3862
|
|
3863
|
+
module Hexscalar0
|
3864
|
+
end
|
3865
|
+
|
3866
|
+
module Hexscalar1
|
3867
|
+
def HEXDIG1
|
3868
|
+
elements[0]
|
3869
|
+
end
|
3870
|
+
|
3871
|
+
end
|
3872
|
+
|
3873
|
+
def _nt_hexscalar
|
3874
|
+
start_index = index
|
3875
|
+
if node_cache[:hexscalar].has_key?(index)
|
3876
|
+
cached = node_cache[:hexscalar][index]
|
3877
|
+
if cached
|
3878
|
+
node_cache[:hexscalar][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
3879
|
+
@index = cached.interval.end
|
3880
|
+
end
|
3881
|
+
return cached
|
3882
|
+
end
|
3883
|
+
|
3884
|
+
i0 = index
|
3885
|
+
i1, s1 = index, []
|
3886
|
+
if (match_len = has_terminal?("10", false, index))
|
3887
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
3888
|
+
@index += match_len
|
3889
|
+
else
|
3890
|
+
terminal_parse_failure('"10"')
|
3891
|
+
r2 = nil
|
3892
|
+
end
|
3893
|
+
s1 << r2
|
3894
|
+
if r2
|
3895
|
+
s3, i3 = [], index
|
3896
|
+
loop do
|
3897
|
+
r4 = _nt_HEXDIG
|
3898
|
+
if r4
|
3899
|
+
s3 << r4
|
3900
|
+
else
|
3901
|
+
break
|
3902
|
+
end
|
3903
|
+
if s3.size == 4
|
3904
|
+
break
|
3905
|
+
end
|
3906
|
+
end
|
3907
|
+
if s3.size < 4
|
3908
|
+
@index = i3
|
3909
|
+
r3 = nil
|
3910
|
+
else
|
3911
|
+
if s3.size < 4
|
3912
|
+
@terminal_failures.pop
|
3913
|
+
end
|
3914
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
3915
|
+
end
|
3916
|
+
s1 << r3
|
3917
|
+
end
|
3918
|
+
if s1.last
|
3919
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
3920
|
+
r1.extend(Hexscalar0)
|
3921
|
+
else
|
3922
|
+
@index = i1
|
3923
|
+
r1 = nil
|
3924
|
+
end
|
3925
|
+
if r1
|
3926
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
3927
|
+
r0 = r1
|
3928
|
+
else
|
3929
|
+
i5, s5 = index, []
|
3930
|
+
r6 = _nt_HEXDIG1
|
3931
|
+
s5 << r6
|
3932
|
+
if r6
|
3933
|
+
s7, i7 = [], index
|
3934
|
+
loop do
|
3935
|
+
r8 = _nt_HEXDIG
|
3936
|
+
if r8
|
3937
|
+
s7 << r8
|
3938
|
+
else
|
3939
|
+
break
|
3940
|
+
end
|
3941
|
+
if s7.size == 4
|
3942
|
+
break
|
3943
|
+
end
|
3944
|
+
end
|
3945
|
+
if s7.size < 4
|
3946
|
+
@index = i7
|
3947
|
+
r7 = nil
|
3948
|
+
else
|
3949
|
+
if s7.size < 4
|
3950
|
+
@terminal_failures.pop
|
3951
|
+
end
|
3952
|
+
r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
|
3953
|
+
end
|
3954
|
+
s5 << r7
|
3955
|
+
end
|
3956
|
+
if s5.last
|
3957
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
3958
|
+
r5.extend(Hexscalar1)
|
3959
|
+
else
|
3960
|
+
@index = i5
|
3961
|
+
r5 = nil
|
3962
|
+
end
|
3963
|
+
if r5
|
3964
|
+
r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
|
3965
|
+
r0 = r5
|
3966
|
+
else
|
3967
|
+
r9 = _nt_non_surrogate
|
3968
|
+
if r9
|
3969
|
+
r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
|
3970
|
+
r0 = r9
|
3971
|
+
else
|
3972
|
+
s10, i10 = [], index
|
3973
|
+
loop do
|
3974
|
+
r11 = _nt_HEXDIG
|
3975
|
+
if r11
|
3976
|
+
s10 << r11
|
3977
|
+
else
|
3978
|
+
break
|
3979
|
+
end
|
3980
|
+
if s10.size == 3
|
3981
|
+
break
|
3982
|
+
end
|
3983
|
+
end
|
3984
|
+
if s10.size < 1
|
3985
|
+
@index = i10
|
3986
|
+
r10 = nil
|
3987
|
+
else
|
3988
|
+
if s10.size < 3
|
3989
|
+
@terminal_failures.pop
|
3990
|
+
end
|
3991
|
+
r10 = instantiate_node(SyntaxNode,input, i10...index, s10)
|
3992
|
+
end
|
3993
|
+
if r10
|
3994
|
+
r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
|
3995
|
+
r0 = r10
|
3996
|
+
else
|
3997
|
+
@index = i0
|
3998
|
+
r0 = nil
|
3999
|
+
end
|
4000
|
+
end
|
4001
|
+
end
|
4002
|
+
end
|
4003
|
+
|
4004
|
+
node_cache[:hexscalar][start_index] = r0
|
4005
|
+
|
4006
|
+
r0
|
4007
|
+
end
|
4008
|
+
|
3765
4009
|
def _nt_unescaped
|
3766
4010
|
start_index = index
|
3767
4011
|
if node_cache[:unescaped].has_key?(index)
|
@@ -4084,6 +4328,104 @@ module EDNGRAMMAR
|
|
4084
4328
|
r0
|
4085
4329
|
end
|
4086
4330
|
|
4331
|
+
def _nt_HEXDIG1
|
4332
|
+
start_index = index
|
4333
|
+
if node_cache[:HEXDIG1].has_key?(index)
|
4334
|
+
cached = node_cache[:HEXDIG1][index]
|
4335
|
+
if cached
|
4336
|
+
node_cache[:HEXDIG1][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
4337
|
+
@index = cached.interval.end
|
4338
|
+
end
|
4339
|
+
return cached
|
4340
|
+
end
|
4341
|
+
|
4342
|
+
i0 = index
|
4343
|
+
r1 = _nt_DIGIT1
|
4344
|
+
if r1
|
4345
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
4346
|
+
r0 = r1
|
4347
|
+
else
|
4348
|
+
if (match_len = has_terminal?("a", :insens, index))
|
4349
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
4350
|
+
@index += match_len
|
4351
|
+
else
|
4352
|
+
terminal_parse_failure('"A"')
|
4353
|
+
r2 = nil
|
4354
|
+
end
|
4355
|
+
if r2
|
4356
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
4357
|
+
r0 = r2
|
4358
|
+
else
|
4359
|
+
if (match_len = has_terminal?("b", :insens, index))
|
4360
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
4361
|
+
@index += match_len
|
4362
|
+
else
|
4363
|
+
terminal_parse_failure('"B"')
|
4364
|
+
r3 = nil
|
4365
|
+
end
|
4366
|
+
if r3
|
4367
|
+
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
4368
|
+
r0 = r3
|
4369
|
+
else
|
4370
|
+
if (match_len = has_terminal?("c", :insens, index))
|
4371
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
4372
|
+
@index += match_len
|
4373
|
+
else
|
4374
|
+
terminal_parse_failure('"C"')
|
4375
|
+
r4 = nil
|
4376
|
+
end
|
4377
|
+
if r4
|
4378
|
+
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
4379
|
+
r0 = r4
|
4380
|
+
else
|
4381
|
+
if (match_len = has_terminal?("d", :insens, index))
|
4382
|
+
r5 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
4383
|
+
@index += match_len
|
4384
|
+
else
|
4385
|
+
terminal_parse_failure('"D"')
|
4386
|
+
r5 = nil
|
4387
|
+
end
|
4388
|
+
if r5
|
4389
|
+
r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
|
4390
|
+
r0 = r5
|
4391
|
+
else
|
4392
|
+
if (match_len = has_terminal?("e", :insens, index))
|
4393
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
4394
|
+
@index += match_len
|
4395
|
+
else
|
4396
|
+
terminal_parse_failure('"E"')
|
4397
|
+
r6 = nil
|
4398
|
+
end
|
4399
|
+
if r6
|
4400
|
+
r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
|
4401
|
+
r0 = r6
|
4402
|
+
else
|
4403
|
+
if (match_len = has_terminal?("f", :insens, index))
|
4404
|
+
r7 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
4405
|
+
@index += match_len
|
4406
|
+
else
|
4407
|
+
terminal_parse_failure('"F"')
|
4408
|
+
r7 = nil
|
4409
|
+
end
|
4410
|
+
if r7
|
4411
|
+
r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
|
4412
|
+
r0 = r7
|
4413
|
+
else
|
4414
|
+
@index = i0
|
4415
|
+
r0 = nil
|
4416
|
+
end
|
4417
|
+
end
|
4418
|
+
end
|
4419
|
+
end
|
4420
|
+
end
|
4421
|
+
end
|
4422
|
+
end
|
4423
|
+
|
4424
|
+
node_cache[:HEXDIG1][start_index] = r0
|
4425
|
+
|
4426
|
+
r0
|
4427
|
+
end
|
4428
|
+
|
4087
4429
|
def _nt_lcalpha
|
4088
4430
|
start_index = index
|
4089
4431
|
if node_cache[:lcalpha].has_key?(index)
|
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.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -125,5 +125,5 @@ requirements: []
|
|
125
125
|
rubygems_version: 3.4.10
|
126
126
|
signing_key:
|
127
127
|
specification_version: 4
|
128
|
-
summary: CBOR Extended Diagnostic Notation implemented in ABNF
|
128
|
+
summary: CBOR Extended Diagnostic Notation (EDN) implemented in ABNF
|
129
129
|
test_files: []
|