edn-abnf 0.0.9 → 0.0.11
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/cbor-diagnostic-app/hgrammar.rb +327 -53
- data/lib/parser/edngrammar.rb +179 -7
- 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: 4dd67fd4813a8adf98e4bbffd069e9d9e40a9c8d4c51c9f1ef1226497d3e7e9b
|
4
|
+
data.tar.gz: 524e68b7bb39b5acb883ddcbbbf3afd6531dfbc3892abfdf7346e8a97452e51d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 132445c4a4c05bd1ce60d552c0c6809df5c92cb850c79243cd26fd5552f5db73e3a1b93dbce1585cddec77ff764d33b1bfb7a868d1907dfa37145a1762530729
|
7
|
+
data.tar.gz: e399041d7bf61d00d80fe824daeb72e8d008927cd8cd5958aedce23f100e53ecef2887393d0aca753bafc9fed1c4330bd8696ffdcd6a6e69829331efd28e8e22
|
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.11"
|
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"
|
@@ -28,16 +28,60 @@ module HGRAMMAR
|
|
28
28
|
end
|
29
29
|
|
30
30
|
module AppStringH1
|
31
|
+
def ast
|
32
|
+
Integer(elements[0].text_value + elements[2].text_value, 16).chr("BINARY")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
module AppStringH2
|
37
|
+
def ellipsis
|
38
|
+
elements[0]
|
39
|
+
end
|
40
|
+
|
41
|
+
def S
|
42
|
+
elements[1]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
module AppStringH3
|
47
|
+
def ast; ellipsis.ast end
|
48
|
+
end
|
49
|
+
|
50
|
+
module AppStringH4
|
31
51
|
def S
|
32
52
|
elements[0]
|
33
53
|
end
|
34
54
|
|
35
55
|
end
|
36
56
|
|
37
|
-
module
|
57
|
+
module AppStringH5
|
58
|
+
def unpack_thread(s)
|
59
|
+
case s[0]
|
60
|
+
when CBOR::Tagged
|
61
|
+
s[0]
|
62
|
+
when String
|
63
|
+
s.join
|
64
|
+
else
|
65
|
+
raise "@@@ unpack_thread #{s.inspect}"
|
66
|
+
end
|
67
|
+
end
|
38
68
|
def ast
|
39
|
-
e1 = elements[1].elements
|
40
|
-
|
69
|
+
e1 = elements[1].elements.map {|e| e.ast}
|
70
|
+
out = []
|
71
|
+
curr = []
|
72
|
+
e1.each { |el|
|
73
|
+
if curr.size == 0 || curr[0].class == el.class
|
74
|
+
curr << el
|
75
|
+
else
|
76
|
+
out << curr
|
77
|
+
curr = [el]
|
78
|
+
end
|
79
|
+
}
|
80
|
+
if out.size == 0 && String === curr[0]
|
81
|
+
curr.join # unpack_thread(curr)
|
82
|
+
else
|
83
|
+
CBOR::Tagged.new(888, (out << curr).map {|x| unpack_thread(x)})
|
84
|
+
end
|
41
85
|
end
|
42
86
|
end
|
43
87
|
|
@@ -58,27 +102,56 @@ module HGRAMMAR
|
|
58
102
|
if r1
|
59
103
|
s2, i2 = [], index
|
60
104
|
loop do
|
61
|
-
i3
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
105
|
+
i3 = index
|
106
|
+
i4, s4 = index, []
|
107
|
+
r5 = _nt_HEXDIG
|
108
|
+
s4 << r5
|
109
|
+
if r5
|
110
|
+
r6 = _nt_S
|
111
|
+
s4 << r6
|
112
|
+
if r6
|
113
|
+
r7 = _nt_HEXDIG
|
114
|
+
s4 << r7
|
115
|
+
if r7
|
116
|
+
r8 = _nt_S
|
117
|
+
s4 << r8
|
73
118
|
end
|
74
119
|
end
|
75
120
|
end
|
76
|
-
if
|
77
|
-
|
78
|
-
|
121
|
+
if s4.last
|
122
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
123
|
+
r4.extend(AppStringH0)
|
124
|
+
r4.extend(AppStringH1)
|
79
125
|
else
|
80
|
-
@index =
|
81
|
-
|
126
|
+
@index = i4
|
127
|
+
r4 = nil
|
128
|
+
end
|
129
|
+
if r4
|
130
|
+
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
131
|
+
r3 = r4
|
132
|
+
else
|
133
|
+
i9, s9 = index, []
|
134
|
+
r10 = _nt_ellipsis
|
135
|
+
s9 << r10
|
136
|
+
if r10
|
137
|
+
r11 = _nt_S
|
138
|
+
s9 << r11
|
139
|
+
end
|
140
|
+
if s9.last
|
141
|
+
r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
|
142
|
+
r9.extend(AppStringH2)
|
143
|
+
r9.extend(AppStringH3)
|
144
|
+
else
|
145
|
+
@index = i9
|
146
|
+
r9 = nil
|
147
|
+
end
|
148
|
+
if r9
|
149
|
+
r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
|
150
|
+
r3 = r9
|
151
|
+
else
|
152
|
+
@index = i3
|
153
|
+
r3 = nil
|
154
|
+
end
|
82
155
|
end
|
83
156
|
if r3
|
84
157
|
s2 << r3
|
@@ -91,8 +164,8 @@ module HGRAMMAR
|
|
91
164
|
end
|
92
165
|
if s0.last
|
93
166
|
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
94
|
-
r0.extend(
|
95
|
-
r0.extend(
|
167
|
+
r0.extend(AppStringH4)
|
168
|
+
r0.extend(AppStringH5)
|
96
169
|
else
|
97
170
|
@index = i0
|
98
171
|
r0 = nil
|
@@ -103,6 +176,50 @@ module HGRAMMAR
|
|
103
176
|
r0
|
104
177
|
end
|
105
178
|
|
179
|
+
module Ellipsis0
|
180
|
+
def ast; CBOR::Tagged.new(888, nil) end
|
181
|
+
end
|
182
|
+
|
183
|
+
def _nt_ellipsis
|
184
|
+
start_index = index
|
185
|
+
if node_cache[:ellipsis].has_key?(index)
|
186
|
+
cached = node_cache[:ellipsis][index]
|
187
|
+
if cached
|
188
|
+
node_cache[:ellipsis][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
189
|
+
@index = cached.interval.end
|
190
|
+
end
|
191
|
+
return cached
|
192
|
+
end
|
193
|
+
|
194
|
+
s0, i0 = [], index
|
195
|
+
loop do
|
196
|
+
if (match_len = has_terminal?(".", false, index))
|
197
|
+
r1 = true
|
198
|
+
@index += match_len
|
199
|
+
else
|
200
|
+
terminal_parse_failure('"."')
|
201
|
+
r1 = nil
|
202
|
+
end
|
203
|
+
if r1
|
204
|
+
s0 << r1
|
205
|
+
else
|
206
|
+
break
|
207
|
+
end
|
208
|
+
end
|
209
|
+
if s0.size < 3
|
210
|
+
@index = i0
|
211
|
+
r0 = nil
|
212
|
+
else
|
213
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
214
|
+
r0.extend(Ellipsis0)
|
215
|
+
r0.extend(Ellipsis0)
|
216
|
+
end
|
217
|
+
|
218
|
+
node_cache[:ellipsis][start_index] = r0
|
219
|
+
|
220
|
+
r0
|
221
|
+
end
|
222
|
+
|
106
223
|
def _nt_HEXDIG
|
107
224
|
start_index = index
|
108
225
|
if node_cache[:HEXDIG].has_key?(index)
|
@@ -343,7 +460,79 @@ module HGRAMMAR
|
|
343
460
|
r0
|
344
461
|
end
|
345
462
|
|
463
|
+
def _nt_non_lf
|
464
|
+
start_index = index
|
465
|
+
if node_cache[:non_lf].has_key?(index)
|
466
|
+
cached = node_cache[:non_lf][index]
|
467
|
+
if cached
|
468
|
+
node_cache[:non_lf][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
469
|
+
@index = cached.interval.end
|
470
|
+
end
|
471
|
+
return cached
|
472
|
+
end
|
473
|
+
|
474
|
+
i0 = index
|
475
|
+
if (match_len = has_terminal?("\t", false, index))
|
476
|
+
r1 = true
|
477
|
+
@index += match_len
|
478
|
+
else
|
479
|
+
terminal_parse_failure('"\\t"')
|
480
|
+
r1 = nil
|
481
|
+
end
|
482
|
+
if r1
|
483
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
484
|
+
r0 = r1
|
485
|
+
else
|
486
|
+
if (match_len = has_terminal?("\r", false, index))
|
487
|
+
r2 = true
|
488
|
+
@index += match_len
|
489
|
+
else
|
490
|
+
terminal_parse_failure('"\\r"')
|
491
|
+
r2 = nil
|
492
|
+
end
|
493
|
+
if r2
|
494
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
495
|
+
r0 = r2
|
496
|
+
else
|
497
|
+
if has_terminal?(@regexps[gr = '\A[\\ -]'] ||= Regexp.new(gr), :regexp, index)
|
498
|
+
r3 = true
|
499
|
+
@index += 1
|
500
|
+
else
|
501
|
+
terminal_parse_failure('[\\ -]')
|
502
|
+
r3 = nil
|
503
|
+
end
|
504
|
+
if r3
|
505
|
+
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
506
|
+
r0 = r3
|
507
|
+
else
|
508
|
+
if has_terminal?(@regexps[gr = '\A[-]'] ||= Regexp.new(gr), :regexp, index)
|
509
|
+
r4 = true
|
510
|
+
@index += 1
|
511
|
+
else
|
512
|
+
terminal_parse_failure('[-]')
|
513
|
+
r4 = nil
|
514
|
+
end
|
515
|
+
if r4
|
516
|
+
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
517
|
+
r0 = r4
|
518
|
+
else
|
519
|
+
@index = i0
|
520
|
+
r0 = nil
|
521
|
+
end
|
522
|
+
end
|
523
|
+
end
|
524
|
+
end
|
525
|
+
|
526
|
+
node_cache[:non_lf][start_index] = r0
|
527
|
+
|
528
|
+
r0
|
529
|
+
end
|
530
|
+
|
346
531
|
module S0
|
532
|
+
def comment
|
533
|
+
elements[0]
|
534
|
+
end
|
535
|
+
|
347
536
|
end
|
348
537
|
|
349
538
|
module S1
|
@@ -376,18 +565,12 @@ module HGRAMMAR
|
|
376
565
|
s3, i3 = [], index
|
377
566
|
loop do
|
378
567
|
i4, s4 = index, []
|
379
|
-
|
380
|
-
r5 = true
|
381
|
-
@index += match_len
|
382
|
-
else
|
383
|
-
terminal_parse_failure('"/"')
|
384
|
-
r5 = nil
|
385
|
-
end
|
568
|
+
r5 = _nt_comment
|
386
569
|
s4 << r5
|
387
570
|
if r5
|
388
571
|
s6, i6 = [], index
|
389
572
|
loop do
|
390
|
-
r7 =
|
573
|
+
r7 = _nt_blank
|
391
574
|
if r7
|
392
575
|
s6 << r7
|
393
576
|
else
|
@@ -396,29 +579,6 @@ module HGRAMMAR
|
|
396
579
|
end
|
397
580
|
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
398
581
|
s4 << r6
|
399
|
-
if r6
|
400
|
-
if (match_len = has_terminal?("/", false, index))
|
401
|
-
r8 = true
|
402
|
-
@index += match_len
|
403
|
-
else
|
404
|
-
terminal_parse_failure('"/"')
|
405
|
-
r8 = nil
|
406
|
-
end
|
407
|
-
s4 << r8
|
408
|
-
if r8
|
409
|
-
s9, i9 = [], index
|
410
|
-
loop do
|
411
|
-
r10 = _nt_blank
|
412
|
-
if r10
|
413
|
-
s9 << r10
|
414
|
-
else
|
415
|
-
break
|
416
|
-
end
|
417
|
-
end
|
418
|
-
r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
|
419
|
-
s4 << r9
|
420
|
-
end
|
421
|
-
end
|
422
582
|
end
|
423
583
|
if s4.last
|
424
584
|
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
@@ -449,6 +609,120 @@ module HGRAMMAR
|
|
449
609
|
r0
|
450
610
|
end
|
451
611
|
|
612
|
+
module Comment0
|
613
|
+
end
|
614
|
+
|
615
|
+
module Comment1
|
616
|
+
end
|
617
|
+
|
618
|
+
def _nt_comment
|
619
|
+
start_index = index
|
620
|
+
if node_cache[:comment].has_key?(index)
|
621
|
+
cached = node_cache[:comment][index]
|
622
|
+
if cached
|
623
|
+
node_cache[:comment][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
624
|
+
@index = cached.interval.end
|
625
|
+
end
|
626
|
+
return cached
|
627
|
+
end
|
628
|
+
|
629
|
+
i0 = index
|
630
|
+
i1, s1 = index, []
|
631
|
+
if (match_len = has_terminal?("/", false, index))
|
632
|
+
r2 = true
|
633
|
+
@index += match_len
|
634
|
+
else
|
635
|
+
terminal_parse_failure('"/"')
|
636
|
+
r2 = nil
|
637
|
+
end
|
638
|
+
s1 << r2
|
639
|
+
if r2
|
640
|
+
s3, i3 = [], index
|
641
|
+
loop do
|
642
|
+
r4 = _nt_non_slash
|
643
|
+
if r4
|
644
|
+
s3 << r4
|
645
|
+
else
|
646
|
+
break
|
647
|
+
end
|
648
|
+
end
|
649
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
650
|
+
s1 << r3
|
651
|
+
if r3
|
652
|
+
if (match_len = has_terminal?("/", false, index))
|
653
|
+
r5 = true
|
654
|
+
@index += match_len
|
655
|
+
else
|
656
|
+
terminal_parse_failure('"/"')
|
657
|
+
r5 = nil
|
658
|
+
end
|
659
|
+
s1 << r5
|
660
|
+
end
|
661
|
+
end
|
662
|
+
if s1.last
|
663
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
664
|
+
r1.extend(Comment0)
|
665
|
+
else
|
666
|
+
@index = i1
|
667
|
+
r1 = nil
|
668
|
+
end
|
669
|
+
if r1
|
670
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
671
|
+
r0 = r1
|
672
|
+
else
|
673
|
+
i6, s6 = index, []
|
674
|
+
if (match_len = has_terminal?("#", false, index))
|
675
|
+
r7 = true
|
676
|
+
@index += match_len
|
677
|
+
else
|
678
|
+
terminal_parse_failure('"#"')
|
679
|
+
r7 = nil
|
680
|
+
end
|
681
|
+
s6 << r7
|
682
|
+
if r7
|
683
|
+
s8, i8 = [], index
|
684
|
+
loop do
|
685
|
+
r9 = _nt_non_lf
|
686
|
+
if r9
|
687
|
+
s8 << r9
|
688
|
+
else
|
689
|
+
break
|
690
|
+
end
|
691
|
+
end
|
692
|
+
r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
|
693
|
+
s6 << r8
|
694
|
+
if r8
|
695
|
+
if (match_len = has_terminal?("\n", false, index))
|
696
|
+
r10 = true
|
697
|
+
@index += match_len
|
698
|
+
else
|
699
|
+
terminal_parse_failure('"\\n"')
|
700
|
+
r10 = nil
|
701
|
+
end
|
702
|
+
s6 << r10
|
703
|
+
end
|
704
|
+
end
|
705
|
+
if s6.last
|
706
|
+
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
707
|
+
r6.extend(Comment1)
|
708
|
+
else
|
709
|
+
@index = i6
|
710
|
+
r6 = nil
|
711
|
+
end
|
712
|
+
if r6
|
713
|
+
r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
|
714
|
+
r0 = r6
|
715
|
+
else
|
716
|
+
@index = i0
|
717
|
+
r0 = nil
|
718
|
+
end
|
719
|
+
end
|
720
|
+
|
721
|
+
node_cache[:comment][start_index] = r0
|
722
|
+
|
723
|
+
r0
|
724
|
+
end
|
725
|
+
|
452
726
|
end
|
453
727
|
|
454
728
|
class HGRAMMARParser < Treetop::Runtime::CompiledParser
|
data/lib/parser/edngrammar.rb
CHANGED
@@ -289,13 +289,13 @@ module EDNGRAMMAR
|
|
289
289
|
r0
|
290
290
|
end
|
291
291
|
|
292
|
-
module
|
292
|
+
module String10
|
293
293
|
def spec
|
294
294
|
elements[1]
|
295
295
|
end
|
296
296
|
end
|
297
297
|
|
298
|
-
module
|
298
|
+
module String11
|
299
299
|
def ast
|
300
300
|
if ei = spec.text_value[1..-1]
|
301
301
|
warn "*** ignoring unimplemented encoding indicator #{ei.inspect} for #{elements[0].text_value}"
|
@@ -304,12 +304,12 @@ module EDNGRAMMAR
|
|
304
304
|
end
|
305
305
|
end
|
306
306
|
|
307
|
-
def
|
307
|
+
def _nt_string1
|
308
308
|
start_index = index
|
309
|
-
if node_cache[:
|
310
|
-
cached = node_cache[:
|
309
|
+
if node_cache[:string1].has_key?(index)
|
310
|
+
cached = node_cache[:string1][index]
|
311
311
|
if cached
|
312
|
-
node_cache[:
|
312
|
+
node_cache[:string1][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
313
313
|
@index = cached.interval.end
|
314
314
|
end
|
315
315
|
return cached
|
@@ -338,8 +338,180 @@ module EDNGRAMMAR
|
|
338
338
|
end
|
339
339
|
if s0.last
|
340
340
|
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
341
|
-
r0.extend(
|
341
|
+
r0.extend(String10)
|
342
|
+
r0.extend(String11)
|
343
|
+
else
|
344
|
+
@index = i0
|
345
|
+
r0 = nil
|
346
|
+
end
|
347
|
+
|
348
|
+
node_cache[:string1][start_index] = r0
|
349
|
+
|
350
|
+
r0
|
351
|
+
end
|
352
|
+
|
353
|
+
def _nt_string1e
|
354
|
+
start_index = index
|
355
|
+
if node_cache[:string1e].has_key?(index)
|
356
|
+
cached = node_cache[:string1e][index]
|
357
|
+
if cached
|
358
|
+
node_cache[:string1e][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
359
|
+
@index = cached.interval.end
|
360
|
+
end
|
361
|
+
return cached
|
362
|
+
end
|
363
|
+
|
364
|
+
i0 = index
|
365
|
+
r1 = _nt_string1
|
366
|
+
if r1
|
367
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
368
|
+
r0 = r1
|
369
|
+
else
|
370
|
+
r2 = _nt_ellipsis
|
371
|
+
if r2
|
372
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
373
|
+
r0 = r2
|
374
|
+
else
|
375
|
+
@index = i0
|
376
|
+
r0 = nil
|
377
|
+
end
|
378
|
+
end
|
379
|
+
|
380
|
+
node_cache[:string1e][start_index] = r0
|
381
|
+
|
382
|
+
r0
|
383
|
+
end
|
384
|
+
|
385
|
+
module Ellipsis0
|
386
|
+
def ast; CBOR::Tagged.new(888, nil) end
|
387
|
+
end
|
388
|
+
|
389
|
+
def _nt_ellipsis
|
390
|
+
start_index = index
|
391
|
+
if node_cache[:ellipsis].has_key?(index)
|
392
|
+
cached = node_cache[:ellipsis][index]
|
393
|
+
if cached
|
394
|
+
node_cache[:ellipsis][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
395
|
+
@index = cached.interval.end
|
396
|
+
end
|
397
|
+
return cached
|
398
|
+
end
|
399
|
+
|
400
|
+
s0, i0 = [], index
|
401
|
+
loop do
|
402
|
+
if (match_len = has_terminal?(".", false, index))
|
403
|
+
r1 = true
|
404
|
+
@index += match_len
|
405
|
+
else
|
406
|
+
terminal_parse_failure('"."')
|
407
|
+
r1 = nil
|
408
|
+
end
|
409
|
+
if r1
|
410
|
+
s0 << r1
|
411
|
+
else
|
412
|
+
break
|
413
|
+
end
|
414
|
+
end
|
415
|
+
if s0.size < 3
|
416
|
+
@index = i0
|
417
|
+
r0 = nil
|
418
|
+
else
|
419
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
420
|
+
r0.extend(Ellipsis0)
|
421
|
+
r0.extend(Ellipsis0)
|
422
|
+
end
|
423
|
+
|
424
|
+
node_cache[:ellipsis][start_index] = r0
|
425
|
+
|
426
|
+
r0
|
427
|
+
end
|
428
|
+
|
429
|
+
module String0
|
430
|
+
def S
|
431
|
+
elements[0]
|
432
|
+
end
|
433
|
+
|
434
|
+
def string1e
|
435
|
+
elements[1]
|
436
|
+
end
|
437
|
+
end
|
438
|
+
|
439
|
+
module String1
|
440
|
+
def string1e
|
441
|
+
elements[0]
|
442
|
+
end
|
443
|
+
|
444
|
+
end
|
445
|
+
|
446
|
+
module String2
|
447
|
+
def join1(s)
|
448
|
+
s.join # XXX -- look at encoding and ei
|
449
|
+
end
|
450
|
+
def unpack_chunk(c, s)
|
451
|
+
if c == String
|
452
|
+
join1(s)
|
453
|
+
else
|
454
|
+
unless c == CBOR::Tagged && s.first.tag == 888 && s.first.value == nil # XXX check all values?
|
455
|
+
raise "*** unjoinable chunks #{c.inspect} #{s.inspect}" if s.size != 1
|
456
|
+
end
|
457
|
+
s.first
|
458
|
+
end
|
459
|
+
end
|
460
|
+
def ast
|
461
|
+
arr = [elements[0].ast] + elements[1].elements.map {|x| x.elements[1].ast}
|
462
|
+
charr = arr.chunk(&:class).to_a
|
463
|
+
if charr.size == 1
|
464
|
+
unpack_chunk(*charr.first)
|
465
|
+
else
|
466
|
+
CBOR::Tagged.new(888, charr.map {|x| unpack_chunk(*x)})
|
467
|
+
end
|
468
|
+
end
|
469
|
+
end
|
470
|
+
|
471
|
+
def _nt_string
|
472
|
+
start_index = index
|
473
|
+
if node_cache[:string].has_key?(index)
|
474
|
+
cached = node_cache[:string][index]
|
475
|
+
if cached
|
476
|
+
node_cache[:string][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
477
|
+
@index = cached.interval.end
|
478
|
+
end
|
479
|
+
return cached
|
480
|
+
end
|
481
|
+
|
482
|
+
i0, s0 = index, []
|
483
|
+
r1 = _nt_string1e
|
484
|
+
s0 << r1
|
485
|
+
if r1
|
486
|
+
s2, i2 = [], index
|
487
|
+
loop do
|
488
|
+
i3, s3 = index, []
|
489
|
+
r4 = _nt_S
|
490
|
+
s3 << r4
|
491
|
+
if r4
|
492
|
+
r5 = _nt_string1e
|
493
|
+
s3 << r5
|
494
|
+
end
|
495
|
+
if s3.last
|
496
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
497
|
+
r3.extend(String0)
|
498
|
+
else
|
499
|
+
@index = i3
|
500
|
+
r3 = nil
|
501
|
+
end
|
502
|
+
if r3
|
503
|
+
s2 << r3
|
504
|
+
else
|
505
|
+
break
|
506
|
+
end
|
507
|
+
end
|
508
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
509
|
+
s0 << r2
|
510
|
+
end
|
511
|
+
if s0.last
|
512
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
342
513
|
r0.extend(String1)
|
514
|
+
r0.extend(String2)
|
343
515
|
else
|
344
516
|
@index = i0
|
345
517
|
r0 = nil
|
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.11
|
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-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|