edn-abnf 0.0.9 → 0.0.10
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/edn-abnf.gemspec +1 -1
- data/lib/cbor-diagnostic-app/hgrammar.rb +327 -53
- 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
|
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
|