edn-abnf 0.0.8 → 0.0.10
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 +158 -190
- 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: 932c447340ccec81fa10c0b51f802906872bdbd544473aa6301f98b490ef8aef
|
4
|
+
data.tar.gz: fa2e2062c8eb6243029011b790e519dd5d24b3fe61960e12cefc4d253d92dd1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df16c6657287cdd6c3c1a717dd7e2e6ab20e64d53a910dc77b9b8f3b7a6dd9a20c3c9330e4d272ce3230f497ef1a936de184a41b35105af15c7a6d27f50c4c90
|
7
|
+
data.tar.gz: 0ea2cd3c43c44d3ec0c6881558f407fbf0368abceeb66f022f121a45be16aa49d7e23b64f5c66479b9ad804dc07ba36fce78952de603a17f6bc2185ed3fac69d
|
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.10"
|
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
@@ -230,6 +230,9 @@ module EDNGRAMMAR
|
|
230
230
|
|
231
231
|
module Number1
|
232
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
|
233
236
|
elements[0].ast
|
234
237
|
end
|
235
238
|
end
|
@@ -294,6 +297,9 @@ module EDNGRAMMAR
|
|
294
297
|
|
295
298
|
module String1
|
296
299
|
def ast
|
300
|
+
if ei = spec.text_value[1..-1]
|
301
|
+
warn "*** ignoring unimplemented encoding indicator #{ei.inspect} for #{elements[0].text_value}"
|
302
|
+
end
|
297
303
|
elements[0].ast
|
298
304
|
end
|
299
305
|
end
|
@@ -1144,6 +1150,9 @@ module EDNGRAMMAR
|
|
1144
1150
|
|
1145
1151
|
module Tagged1
|
1146
1152
|
def ast
|
1153
|
+
if ei = spec.text_value[1..-1]
|
1154
|
+
warn "*** ignoring unimplemented encoding indicator #{ei.inspect} after tag number #{uint.text_value}"
|
1155
|
+
end
|
1147
1156
|
CBOR::Tagged.new(uint.text_value.to_i, item.ast)
|
1148
1157
|
end
|
1149
1158
|
end
|
@@ -1580,16 +1589,21 @@ module EDNGRAMMAR
|
|
1580
1589
|
elements[1]
|
1581
1590
|
end
|
1582
1591
|
|
1592
|
+
def S
|
1593
|
+
elements[2]
|
1594
|
+
end
|
1595
|
+
|
1583
1596
|
end
|
1584
1597
|
|
1585
1598
|
module Array3
|
1586
1599
|
def ast
|
1587
|
-
r = if e = elements[
|
1600
|
+
r = if e = elements[3].elements
|
1588
1601
|
[e[0].ast] + e[2].elements.map {|x| x.item.ast }
|
1589
1602
|
else
|
1590
1603
|
[]
|
1591
1604
|
end
|
1592
|
-
if ei = spec.
|
1605
|
+
if ei = spec.text_value[1..-1]
|
1606
|
+
# warn "** ei #{ei.inspect}"
|
1593
1607
|
if ei == ""
|
1594
1608
|
r.cbor_stream!
|
1595
1609
|
else
|
@@ -1624,79 +1638,83 @@ module EDNGRAMMAR
|
|
1624
1638
|
r2 = _nt_spec
|
1625
1639
|
s0 << r2
|
1626
1640
|
if r2
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1631
|
-
r6 =
|
1632
|
-
|
1641
|
+
r3 = _nt_S
|
1642
|
+
s0 << r3
|
1643
|
+
if r3
|
1644
|
+
i5, s5 = index, []
|
1645
|
+
r6 = _nt_item
|
1646
|
+
s5 << r6
|
1633
1647
|
if r6
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
+
r7 = _nt_S
|
1649
|
+
s5 << r7
|
1650
|
+
if r7
|
1651
|
+
s8, i8 = [], index
|
1652
|
+
loop do
|
1653
|
+
i9, s9 = index, []
|
1654
|
+
if (match_len = has_terminal?(",", false, index))
|
1655
|
+
r10 = true
|
1656
|
+
@index += match_len
|
1657
|
+
else
|
1658
|
+
terminal_parse_failure('","')
|
1659
|
+
r10 = nil
|
1660
|
+
end
|
1661
|
+
s9 << r10
|
1648
1662
|
if r10
|
1649
|
-
r11 =
|
1650
|
-
|
1663
|
+
r11 = _nt_S
|
1664
|
+
s9 << r11
|
1651
1665
|
if r11
|
1652
|
-
r12 =
|
1653
|
-
|
1666
|
+
r12 = _nt_item
|
1667
|
+
s9 << r12
|
1668
|
+
if r12
|
1669
|
+
r13 = _nt_S
|
1670
|
+
s9 << r13
|
1671
|
+
end
|
1654
1672
|
end
|
1655
1673
|
end
|
1674
|
+
if s9.last
|
1675
|
+
r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
|
1676
|
+
r9.extend(Array0)
|
1677
|
+
else
|
1678
|
+
@index = i9
|
1679
|
+
r9 = nil
|
1680
|
+
end
|
1681
|
+
if r9
|
1682
|
+
s8 << r9
|
1683
|
+
else
|
1684
|
+
break
|
1685
|
+
end
|
1656
1686
|
end
|
1657
|
-
|
1658
|
-
|
1659
|
-
r8.extend(Array0)
|
1660
|
-
else
|
1661
|
-
@index = i8
|
1662
|
-
r8 = nil
|
1663
|
-
end
|
1687
|
+
r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
|
1688
|
+
s5 << r8
|
1664
1689
|
if r8
|
1665
|
-
|
1666
|
-
|
1667
|
-
break
|
1690
|
+
r14 = _nt_OC
|
1691
|
+
s5 << r14
|
1668
1692
|
end
|
1669
1693
|
end
|
1670
|
-
r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
|
1671
|
-
s4 << r7
|
1672
|
-
if r7
|
1673
|
-
r13 = _nt_OC
|
1674
|
-
s4 << r13
|
1675
|
-
end
|
1676
1694
|
end
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
r4.extend(Array1)
|
1681
|
-
else
|
1682
|
-
@index = i4
|
1683
|
-
r4 = nil
|
1684
|
-
end
|
1685
|
-
if r4
|
1686
|
-
r3 = r4
|
1687
|
-
else
|
1688
|
-
r3 = instantiate_node(SyntaxNode,input, index...index)
|
1689
|
-
end
|
1690
|
-
s0 << r3
|
1691
|
-
if r3
|
1692
|
-
if (match_len = has_terminal?("]", false, index))
|
1693
|
-
r14 = true
|
1694
|
-
@index += match_len
|
1695
|
+
if s5.last
|
1696
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
1697
|
+
r5.extend(Array1)
|
1695
1698
|
else
|
1696
|
-
|
1697
|
-
|
1699
|
+
@index = i5
|
1700
|
+
r5 = nil
|
1701
|
+
end
|
1702
|
+
if r5
|
1703
|
+
r4 = r5
|
1704
|
+
else
|
1705
|
+
r4 = instantiate_node(SyntaxNode,input, index...index)
|
1706
|
+
end
|
1707
|
+
s0 << r4
|
1708
|
+
if r4
|
1709
|
+
if (match_len = has_terminal?("]", false, index))
|
1710
|
+
r15 = true
|
1711
|
+
@index += match_len
|
1712
|
+
else
|
1713
|
+
terminal_parse_failure('"]"')
|
1714
|
+
r15 = nil
|
1715
|
+
end
|
1716
|
+
s0 << r15
|
1698
1717
|
end
|
1699
|
-
s0 << r14
|
1700
1718
|
end
|
1701
1719
|
end
|
1702
1720
|
end
|
@@ -1747,16 +1765,20 @@ module EDNGRAMMAR
|
|
1747
1765
|
elements[1]
|
1748
1766
|
end
|
1749
1767
|
|
1768
|
+
def S
|
1769
|
+
elements[2]
|
1770
|
+
end
|
1771
|
+
|
1750
1772
|
end
|
1751
1773
|
|
1752
1774
|
module Map3
|
1753
1775
|
def ast
|
1754
|
-
r = if e = elements[
|
1776
|
+
r = if e = elements[3].elements
|
1755
1777
|
Hash[ [e[0].ast] + e[2].elements.map {|x| x.kp.ast } ]
|
1756
1778
|
else
|
1757
1779
|
{}
|
1758
1780
|
end
|
1759
|
-
if ei = spec.
|
1781
|
+
if ei = spec.text_value[1..-1]
|
1760
1782
|
if ei == ""
|
1761
1783
|
r.cbor_stream!
|
1762
1784
|
else
|
@@ -1791,79 +1813,83 @@ module EDNGRAMMAR
|
|
1791
1813
|
r2 = _nt_spec
|
1792
1814
|
s0 << r2
|
1793
1815
|
if r2
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
r6 =
|
1799
|
-
|
1816
|
+
r3 = _nt_S
|
1817
|
+
s0 << r3
|
1818
|
+
if r3
|
1819
|
+
i5, s5 = index, []
|
1820
|
+
r6 = _nt_kp
|
1821
|
+
s5 << r6
|
1800
1822
|
if r6
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
1814
|
-
|
1823
|
+
r7 = _nt_S
|
1824
|
+
s5 << r7
|
1825
|
+
if r7
|
1826
|
+
s8, i8 = [], index
|
1827
|
+
loop do
|
1828
|
+
i9, s9 = index, []
|
1829
|
+
if (match_len = has_terminal?(",", false, index))
|
1830
|
+
r10 = true
|
1831
|
+
@index += match_len
|
1832
|
+
else
|
1833
|
+
terminal_parse_failure('","')
|
1834
|
+
r10 = nil
|
1835
|
+
end
|
1836
|
+
s9 << r10
|
1815
1837
|
if r10
|
1816
|
-
r11 =
|
1817
|
-
|
1838
|
+
r11 = _nt_S
|
1839
|
+
s9 << r11
|
1818
1840
|
if r11
|
1819
|
-
r12 =
|
1820
|
-
|
1841
|
+
r12 = _nt_kp
|
1842
|
+
s9 << r12
|
1843
|
+
if r12
|
1844
|
+
r13 = _nt_S
|
1845
|
+
s9 << r13
|
1846
|
+
end
|
1821
1847
|
end
|
1822
1848
|
end
|
1849
|
+
if s9.last
|
1850
|
+
r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
|
1851
|
+
r9.extend(Map0)
|
1852
|
+
else
|
1853
|
+
@index = i9
|
1854
|
+
r9 = nil
|
1855
|
+
end
|
1856
|
+
if r9
|
1857
|
+
s8 << r9
|
1858
|
+
else
|
1859
|
+
break
|
1860
|
+
end
|
1823
1861
|
end
|
1824
|
-
|
1825
|
-
|
1826
|
-
r8.extend(Map0)
|
1827
|
-
else
|
1828
|
-
@index = i8
|
1829
|
-
r8 = nil
|
1830
|
-
end
|
1862
|
+
r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
|
1863
|
+
s5 << r8
|
1831
1864
|
if r8
|
1832
|
-
|
1833
|
-
|
1834
|
-
break
|
1865
|
+
r14 = _nt_OC
|
1866
|
+
s5 << r14
|
1835
1867
|
end
|
1836
1868
|
end
|
1837
|
-
r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
|
1838
|
-
s4 << r7
|
1839
|
-
if r7
|
1840
|
-
r13 = _nt_OC
|
1841
|
-
s4 << r13
|
1842
|
-
end
|
1843
1869
|
end
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1847
|
-
r4.extend(Map1)
|
1848
|
-
else
|
1849
|
-
@index = i4
|
1850
|
-
r4 = nil
|
1851
|
-
end
|
1852
|
-
if r4
|
1853
|
-
r3 = r4
|
1854
|
-
else
|
1855
|
-
r3 = instantiate_node(SyntaxNode,input, index...index)
|
1856
|
-
end
|
1857
|
-
s0 << r3
|
1858
|
-
if r3
|
1859
|
-
if (match_len = has_terminal?("}", false, index))
|
1860
|
-
r14 = true
|
1861
|
-
@index += match_len
|
1870
|
+
if s5.last
|
1871
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
1872
|
+
r5.extend(Map1)
|
1862
1873
|
else
|
1863
|
-
|
1864
|
-
|
1874
|
+
@index = i5
|
1875
|
+
r5 = nil
|
1876
|
+
end
|
1877
|
+
if r5
|
1878
|
+
r4 = r5
|
1879
|
+
else
|
1880
|
+
r4 = instantiate_node(SyntaxNode,input, index...index)
|
1881
|
+
end
|
1882
|
+
s0 << r4
|
1883
|
+
if r4
|
1884
|
+
if (match_len = has_terminal?("}", false, index))
|
1885
|
+
r15 = true
|
1886
|
+
@index += match_len
|
1887
|
+
else
|
1888
|
+
terminal_parse_failure('"}"')
|
1889
|
+
r15 = nil
|
1890
|
+
end
|
1891
|
+
s0 << r15
|
1865
1892
|
end
|
1866
|
-
s0 << r14
|
1867
1893
|
end
|
1868
1894
|
end
|
1869
1895
|
end
|
@@ -2411,7 +2437,7 @@ module EDNGRAMMAR
|
|
2411
2437
|
end
|
2412
2438
|
|
2413
2439
|
module Streamstring1
|
2414
|
-
def
|
2440
|
+
def S1
|
2415
2441
|
elements[1]
|
2416
2442
|
end
|
2417
2443
|
|
@@ -2419,7 +2445,7 @@ module EDNGRAMMAR
|
|
2419
2445
|
elements[2]
|
2420
2446
|
end
|
2421
2447
|
|
2422
|
-
def
|
2448
|
+
def S2
|
2423
2449
|
elements[3]
|
2424
2450
|
end
|
2425
2451
|
|
@@ -2451,16 +2477,16 @@ module EDNGRAMMAR
|
|
2451
2477
|
end
|
2452
2478
|
|
2453
2479
|
i0, s0 = index, []
|
2454
|
-
if (match_len = has_terminal?("(", false, index))
|
2455
|
-
r1 =
|
2480
|
+
if (match_len = has_terminal?("(_", false, index))
|
2481
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
2456
2482
|
@index += match_len
|
2457
2483
|
else
|
2458
|
-
terminal_parse_failure('"("')
|
2484
|
+
terminal_parse_failure('"(_"')
|
2459
2485
|
r1 = nil
|
2460
2486
|
end
|
2461
2487
|
s0 << r1
|
2462
2488
|
if r1
|
2463
|
-
r2 =
|
2489
|
+
r2 = _nt_S
|
2464
2490
|
s0 << r2
|
2465
2491
|
if r2
|
2466
2492
|
r3 = _nt_string
|
@@ -2540,17 +2566,6 @@ module EDNGRAMMAR
|
|
2540
2566
|
end
|
2541
2567
|
|
2542
2568
|
module Spec0
|
2543
|
-
def S
|
2544
|
-
elements[2]
|
2545
|
-
end
|
2546
|
-
end
|
2547
|
-
|
2548
|
-
module Spec1
|
2549
|
-
def ast;
|
2550
|
-
if (e1 = elements[1].elements) && !e1[0].empty?
|
2551
|
-
e1[1].text_value
|
2552
|
-
end
|
2553
|
-
end
|
2554
2569
|
end
|
2555
2570
|
|
2556
2571
|
def _nt_spec
|
@@ -2585,10 +2600,6 @@ module EDNGRAMMAR
|
|
2585
2600
|
end
|
2586
2601
|
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
2587
2602
|
s1 << r3
|
2588
|
-
if r3
|
2589
|
-
r5 = _nt_S
|
2590
|
-
s1 << r5
|
2591
|
-
end
|
2592
2603
|
end
|
2593
2604
|
if s1.last
|
2594
2605
|
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
@@ -2608,49 +2619,6 @@ module EDNGRAMMAR
|
|
2608
2619
|
r0
|
2609
2620
|
end
|
2610
2621
|
|
2611
|
-
module Spec10
|
2612
|
-
def S
|
2613
|
-
elements[1]
|
2614
|
-
end
|
2615
|
-
end
|
2616
|
-
|
2617
|
-
def _nt_spec1
|
2618
|
-
start_index = index
|
2619
|
-
if node_cache[:spec1].has_key?(index)
|
2620
|
-
cached = node_cache[:spec1][index]
|
2621
|
-
if cached
|
2622
|
-
node_cache[:spec1][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
2623
|
-
@index = cached.interval.end
|
2624
|
-
end
|
2625
|
-
return cached
|
2626
|
-
end
|
2627
|
-
|
2628
|
-
i0, s0 = index, []
|
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
|
2636
|
-
s0 << r1
|
2637
|
-
if r1
|
2638
|
-
r2 = _nt_S
|
2639
|
-
s0 << r2
|
2640
|
-
end
|
2641
|
-
if s0.last
|
2642
|
-
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
2643
|
-
r0.extend(Spec10)
|
2644
|
-
else
|
2645
|
-
@index = i0
|
2646
|
-
r0 = nil
|
2647
|
-
end
|
2648
|
-
|
2649
|
-
node_cache[:spec1][start_index] = r0
|
2650
|
-
|
2651
|
-
r0
|
2652
|
-
end
|
2653
|
-
|
2654
2622
|
module DoubleQuoted0
|
2655
2623
|
def ast; text_value end
|
2656
2624
|
end
|
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.10
|
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
|