edn-abnf 0.1.6 → 0.2.1
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 +75 -104
- metadata +3 -5
- data/bin/edn-abnf~ +0 -57
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53d9d76f5b3a4ac6e05c39d9050d8638ee9c7a7ab40b85e63d76f5deaf908343
|
4
|
+
data.tar.gz: 026a649f7b15be50650baa42b81975ddd6ca791458010dfc5f9a11a0e947bb69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50342e06dcd4acd09737a50f0f9ee52f52b997368339e98049dd59816cd137f937605514167c3bd9225b73262219ea7797855bc0d7716732c80e6e8f5fca7f99
|
7
|
+
data.tar.gz: bc2286703fc79b9a182019ff2a30b56953b829f63e22b9bf7df738928ad3379b01c1344e4bf561c6b4de1af0177efe8a747e40a4d15026950877296a76c7c8a9
|
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.1
|
3
|
+
s.version = "0.2.1"
|
4
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"
|
data/lib/parser/edngrammar.rb
CHANGED
@@ -10,16 +10,16 @@ module EDNGRAMMAR
|
|
10
10
|
end
|
11
11
|
|
12
12
|
module Seq0
|
13
|
-
def
|
14
|
-
elements[
|
13
|
+
def OC
|
14
|
+
elements[0]
|
15
15
|
end
|
16
16
|
|
17
17
|
def item
|
18
|
-
elements[
|
18
|
+
elements[1]
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
22
|
-
elements[
|
21
|
+
def S
|
22
|
+
elements[2]
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -38,13 +38,10 @@ module EDNGRAMMAR
|
|
38
38
|
end
|
39
39
|
|
40
40
|
module Seq2
|
41
|
-
def
|
41
|
+
def S
|
42
42
|
elements[0]
|
43
43
|
end
|
44
44
|
|
45
|
-
def S2
|
46
|
-
elements[2]
|
47
|
-
end
|
48
45
|
end
|
49
46
|
|
50
47
|
module Seq3
|
@@ -87,24 +84,14 @@ module EDNGRAMMAR
|
|
87
84
|
s6, i6 = [], index
|
88
85
|
loop do
|
89
86
|
i7, s7 = index, []
|
90
|
-
|
91
|
-
r8 = true
|
92
|
-
@index += match_len
|
93
|
-
else
|
94
|
-
terminal_parse_failure('","')
|
95
|
-
r8 = nil
|
96
|
-
end
|
87
|
+
r8 = _nt_OC
|
97
88
|
s7 << r8
|
98
89
|
if r8
|
99
|
-
r9 =
|
90
|
+
r9 = _nt_item
|
100
91
|
s7 << r9
|
101
92
|
if r9
|
102
|
-
r10 =
|
93
|
+
r10 = _nt_S
|
103
94
|
s7 << r10
|
104
|
-
if r10
|
105
|
-
r11 = _nt_S
|
106
|
-
s7 << r11
|
107
|
-
end
|
108
95
|
end
|
109
96
|
end
|
110
97
|
if s7.last
|
@@ -123,8 +110,8 @@ module EDNGRAMMAR
|
|
123
110
|
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
124
111
|
s3 << r6
|
125
112
|
if r6
|
126
|
-
|
127
|
-
s3 <<
|
113
|
+
r11 = _nt_OC
|
114
|
+
s3 << r11
|
128
115
|
end
|
129
116
|
end
|
130
117
|
end
|
@@ -141,10 +128,6 @@ module EDNGRAMMAR
|
|
141
128
|
r2 = instantiate_node(SyntaxNode,input, index...index)
|
142
129
|
end
|
143
130
|
s0 << r2
|
144
|
-
if r2
|
145
|
-
r13 = _nt_S
|
146
|
-
s0 << r13
|
147
|
-
end
|
148
131
|
end
|
149
132
|
if s0.last
|
150
133
|
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
@@ -360,12 +343,16 @@ module EDNGRAMMAR
|
|
360
343
|
end
|
361
344
|
|
362
345
|
module String0
|
363
|
-
def
|
346
|
+
def S1
|
364
347
|
elements[0]
|
365
348
|
end
|
366
349
|
|
350
|
+
def S2
|
351
|
+
elements[2]
|
352
|
+
end
|
353
|
+
|
367
354
|
def string1e
|
368
|
-
elements[
|
355
|
+
elements[3]
|
369
356
|
end
|
370
357
|
end
|
371
358
|
|
@@ -391,7 +378,7 @@ module EDNGRAMMAR
|
|
391
378
|
end
|
392
379
|
end
|
393
380
|
def ast
|
394
|
-
arr = [elements[0].ast] + elements[1].elements.map {|x| x.elements[
|
381
|
+
arr = [elements[0].ast] + elements[1].elements.map {|x| x.elements[3].ast}
|
395
382
|
charr = arr.chunk(&:class).to_a
|
396
383
|
if charr.size == 1
|
397
384
|
unpack_chunk(*charr.first)
|
@@ -422,8 +409,22 @@ module EDNGRAMMAR
|
|
422
409
|
r4 = _nt_S
|
423
410
|
s3 << r4
|
424
411
|
if r4
|
425
|
-
|
412
|
+
if (match_len = has_terminal?("+", false, index))
|
413
|
+
r5 = true
|
414
|
+
@index += match_len
|
415
|
+
else
|
416
|
+
terminal_parse_failure('"+"')
|
417
|
+
r5 = nil
|
418
|
+
end
|
426
419
|
s3 << r5
|
420
|
+
if r5
|
421
|
+
r6 = _nt_S
|
422
|
+
s3 << r6
|
423
|
+
if r6
|
424
|
+
r7 = _nt_string1e
|
425
|
+
s3 << r7
|
426
|
+
end
|
427
|
+
end
|
427
428
|
end
|
428
429
|
if s3.last
|
429
430
|
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
@@ -1920,16 +1921,16 @@ module EDNGRAMMAR
|
|
1920
1921
|
end
|
1921
1922
|
|
1922
1923
|
module Array0
|
1923
|
-
def
|
1924
|
-
elements[
|
1924
|
+
def OC
|
1925
|
+
elements[0]
|
1925
1926
|
end
|
1926
1927
|
|
1927
1928
|
def item
|
1928
|
-
elements[
|
1929
|
+
elements[1]
|
1929
1930
|
end
|
1930
1931
|
|
1931
|
-
def
|
1932
|
-
elements[
|
1932
|
+
def S
|
1933
|
+
elements[2]
|
1933
1934
|
end
|
1934
1935
|
end
|
1935
1936
|
|
@@ -2014,24 +2015,14 @@ module EDNGRAMMAR
|
|
2014
2015
|
s8, i8 = [], index
|
2015
2016
|
loop do
|
2016
2017
|
i9, s9 = index, []
|
2017
|
-
|
2018
|
-
r10 = true
|
2019
|
-
@index += match_len
|
2020
|
-
else
|
2021
|
-
terminal_parse_failure('","')
|
2022
|
-
r10 = nil
|
2023
|
-
end
|
2018
|
+
r10 = _nt_OC
|
2024
2019
|
s9 << r10
|
2025
2020
|
if r10
|
2026
|
-
r11 =
|
2021
|
+
r11 = _nt_item
|
2027
2022
|
s9 << r11
|
2028
2023
|
if r11
|
2029
|
-
r12 =
|
2024
|
+
r12 = _nt_S
|
2030
2025
|
s9 << r12
|
2031
|
-
if r12
|
2032
|
-
r13 = _nt_S
|
2033
|
-
s9 << r13
|
2034
|
-
end
|
2035
2026
|
end
|
2036
2027
|
end
|
2037
2028
|
if s9.last
|
@@ -2050,8 +2041,8 @@ module EDNGRAMMAR
|
|
2050
2041
|
r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
|
2051
2042
|
s5 << r8
|
2052
2043
|
if r8
|
2053
|
-
|
2054
|
-
s5 <<
|
2044
|
+
r13 = _nt_OC
|
2045
|
+
s5 << r13
|
2055
2046
|
end
|
2056
2047
|
end
|
2057
2048
|
end
|
@@ -2070,13 +2061,13 @@ module EDNGRAMMAR
|
|
2070
2061
|
s0 << r4
|
2071
2062
|
if r4
|
2072
2063
|
if (match_len = has_terminal?("]", false, index))
|
2073
|
-
|
2064
|
+
r14 = true
|
2074
2065
|
@index += match_len
|
2075
2066
|
else
|
2076
2067
|
terminal_parse_failure('"]"')
|
2077
|
-
|
2068
|
+
r14 = nil
|
2078
2069
|
end
|
2079
|
-
s0 <<
|
2070
|
+
s0 << r14
|
2080
2071
|
end
|
2081
2072
|
end
|
2082
2073
|
end
|
@@ -2096,16 +2087,16 @@ module EDNGRAMMAR
|
|
2096
2087
|
end
|
2097
2088
|
|
2098
2089
|
module Map0
|
2099
|
-
def
|
2100
|
-
elements[
|
2090
|
+
def OC
|
2091
|
+
elements[0]
|
2101
2092
|
end
|
2102
2093
|
|
2103
2094
|
def kp
|
2104
|
-
elements[
|
2095
|
+
elements[1]
|
2105
2096
|
end
|
2106
2097
|
|
2107
|
-
def
|
2108
|
-
elements[
|
2098
|
+
def S
|
2099
|
+
elements[2]
|
2109
2100
|
end
|
2110
2101
|
end
|
2111
2102
|
|
@@ -2189,24 +2180,14 @@ module EDNGRAMMAR
|
|
2189
2180
|
s8, i8 = [], index
|
2190
2181
|
loop do
|
2191
2182
|
i9, s9 = index, []
|
2192
|
-
|
2193
|
-
r10 = true
|
2194
|
-
@index += match_len
|
2195
|
-
else
|
2196
|
-
terminal_parse_failure('","')
|
2197
|
-
r10 = nil
|
2198
|
-
end
|
2183
|
+
r10 = _nt_OC
|
2199
2184
|
s9 << r10
|
2200
2185
|
if r10
|
2201
|
-
r11 =
|
2186
|
+
r11 = _nt_kp
|
2202
2187
|
s9 << r11
|
2203
2188
|
if r11
|
2204
|
-
r12 =
|
2189
|
+
r12 = _nt_S
|
2205
2190
|
s9 << r12
|
2206
|
-
if r12
|
2207
|
-
r13 = _nt_S
|
2208
|
-
s9 << r13
|
2209
|
-
end
|
2210
2191
|
end
|
2211
2192
|
end
|
2212
2193
|
if s9.last
|
@@ -2225,8 +2206,8 @@ module EDNGRAMMAR
|
|
2225
2206
|
r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
|
2226
2207
|
s5 << r8
|
2227
2208
|
if r8
|
2228
|
-
|
2229
|
-
s5 <<
|
2209
|
+
r13 = _nt_OC
|
2210
|
+
s5 << r13
|
2230
2211
|
end
|
2231
2212
|
end
|
2232
2213
|
end
|
@@ -2245,13 +2226,13 @@ module EDNGRAMMAR
|
|
2245
2226
|
s0 << r4
|
2246
2227
|
if r4
|
2247
2228
|
if (match_len = has_terminal?("}", false, index))
|
2248
|
-
|
2229
|
+
r14 = true
|
2249
2230
|
@index += match_len
|
2250
2231
|
else
|
2251
2232
|
terminal_parse_failure('"}"')
|
2252
|
-
|
2233
|
+
r14 = nil
|
2253
2234
|
end
|
2254
|
-
s0 <<
|
2235
|
+
s0 << r14
|
2255
2236
|
end
|
2256
2237
|
end
|
2257
2238
|
end
|
@@ -2786,16 +2767,16 @@ module EDNGRAMMAR
|
|
2786
2767
|
end
|
2787
2768
|
|
2788
2769
|
module Streamstring0
|
2789
|
-
def
|
2790
|
-
elements[
|
2770
|
+
def OC
|
2771
|
+
elements[0]
|
2791
2772
|
end
|
2792
2773
|
|
2793
2774
|
def string
|
2794
|
-
elements[
|
2775
|
+
elements[1]
|
2795
2776
|
end
|
2796
2777
|
|
2797
|
-
def
|
2798
|
-
elements[
|
2778
|
+
def S
|
2779
|
+
elements[2]
|
2799
2780
|
end
|
2800
2781
|
end
|
2801
2782
|
|
@@ -2861,24 +2842,14 @@ module EDNGRAMMAR
|
|
2861
2842
|
s5, i5 = [], index
|
2862
2843
|
loop do
|
2863
2844
|
i6, s6 = index, []
|
2864
|
-
|
2865
|
-
r7 = true
|
2866
|
-
@index += match_len
|
2867
|
-
else
|
2868
|
-
terminal_parse_failure('","')
|
2869
|
-
r7 = nil
|
2870
|
-
end
|
2845
|
+
r7 = _nt_OC
|
2871
2846
|
s6 << r7
|
2872
2847
|
if r7
|
2873
|
-
r8 =
|
2848
|
+
r8 = _nt_string
|
2874
2849
|
s6 << r8
|
2875
2850
|
if r8
|
2876
|
-
r9 =
|
2851
|
+
r9 = _nt_S
|
2877
2852
|
s6 << r9
|
2878
|
-
if r9
|
2879
|
-
r10 = _nt_S
|
2880
|
-
s6 << r10
|
2881
|
-
end
|
2882
2853
|
end
|
2883
2854
|
end
|
2884
2855
|
if s6.last
|
@@ -2897,17 +2868,17 @@ module EDNGRAMMAR
|
|
2897
2868
|
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
2898
2869
|
s0 << r5
|
2899
2870
|
if r5
|
2900
|
-
|
2901
|
-
s0 <<
|
2902
|
-
if
|
2871
|
+
r10 = _nt_OC
|
2872
|
+
s0 << r10
|
2873
|
+
if r10
|
2903
2874
|
if (match_len = has_terminal?(")", false, index))
|
2904
|
-
|
2875
|
+
r11 = true
|
2905
2876
|
@index += match_len
|
2906
2877
|
else
|
2907
2878
|
terminal_parse_failure('")"')
|
2908
|
-
|
2879
|
+
r11 = nil
|
2909
2880
|
end
|
2910
|
-
s0 <<
|
2881
|
+
s0 << r11
|
2911
2882
|
end
|
2912
2883
|
end
|
2913
2884
|
end
|
@@ -2983,7 +2954,7 @@ module EDNGRAMMAR
|
|
2983
2954
|
end
|
2984
2955
|
|
2985
2956
|
module DoubleQuoted0
|
2986
|
-
def ast; text_value end
|
2957
|
+
def ast; text_value.gsub("\r", "") end
|
2987
2958
|
end
|
2988
2959
|
|
2989
2960
|
module DoubleQuoted1
|
@@ -3104,7 +3075,7 @@ module EDNGRAMMAR
|
|
3104
3075
|
end
|
3105
3076
|
|
3106
3077
|
module SingleQuoted0
|
3107
|
-
def ast; text_value end
|
3078
|
+
def ast; text_value.gsub("\r", "") end
|
3108
3079
|
end
|
3109
3080
|
|
3110
3081
|
module SingleQuoted1
|
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.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -85,12 +85,10 @@ description: edn-abnf implements converters and miscellaneous tools for CBOR EDN
|
|
85
85
|
email: cabo@tzi.org
|
86
86
|
executables:
|
87
87
|
- edn-abnf
|
88
|
-
- edn-abnf~
|
89
88
|
extensions: []
|
90
89
|
extra_rdoc_files: []
|
91
90
|
files:
|
92
91
|
- bin/edn-abnf
|
93
|
-
- bin/edn-abnf~
|
94
92
|
- edn-abnf.gemspec
|
95
93
|
- lib/cbor-diagnostic-app/b64.rb
|
96
94
|
- lib/cbor-diagnostic-app/b64grammar.rb
|
@@ -122,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
120
|
- !ruby/object:Gem::Version
|
123
121
|
version: '0'
|
124
122
|
requirements: []
|
125
|
-
rubygems_version: 3.5.
|
123
|
+
rubygems_version: 3.5.14
|
126
124
|
signing_key:
|
127
125
|
specification_version: 4
|
128
126
|
summary: CBOR Extended Diagnostic Notation (EDN) implemented in ABNF
|
data/bin/edn-abnf~
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'pp'
|
3
|
-
require 'yaml'
|
4
|
-
require 'treetop'
|
5
|
-
require 'json'
|
6
|
-
|
7
|
-
require_relative '../lib/edn-abnf.rb'
|
8
|
-
|
9
|
-
def snaky(name)
|
10
|
-
name.gsub(/-/, "_")
|
11
|
-
end
|
12
|
-
|
13
|
-
Encoding.default_external = Encoding::UTF_8
|
14
|
-
require 'optparse'
|
15
|
-
require 'ostruct'
|
16
|
-
|
17
|
-
$options = OpenStruct.new
|
18
|
-
begin
|
19
|
-
op = OptionParser.new do |opts|
|
20
|
-
opts.banner = "Usage: edn-abnf.rb [options] [file.edn... | -]"
|
21
|
-
|
22
|
-
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
23
|
-
$options.verbose = v
|
24
|
-
end
|
25
|
-
opts.on("-tFMT", "--to=FMT", [:basic, :neat, :json, :yaml, :edn, :diag], "Target format") do |v|
|
26
|
-
$options.target = v
|
27
|
-
end
|
28
|
-
end
|
29
|
-
op.parse!
|
30
|
-
rescue Exception => e
|
31
|
-
warn e
|
32
|
-
exit 1
|
33
|
-
end
|
34
|
-
|
35
|
-
if ARGV == []
|
36
|
-
puts op
|
37
|
-
exit 1
|
38
|
-
end
|
39
|
-
|
40
|
-
edn_file = ARGF.read
|
41
|
-
|
42
|
-
edn = EDN.from_edn(edn_file)
|
43
|
-
result = edn.tree # XXX .tree?
|
44
|
-
|
45
|
-
case $options.target
|
46
|
-
when :basic, nil
|
47
|
-
pp result
|
48
|
-
when :neat, :json
|
49
|
-
require 'neatjson'
|
50
|
-
puts JSON.neat_generate(result, after_comma: 1, after_colon: 1)
|
51
|
-
when :yaml
|
52
|
-
puts result.to_yaml
|
53
|
-
when :edn, :diag
|
54
|
-
puts result.cbor_diagnostic
|
55
|
-
else
|
56
|
-
warn ["Unknown target format: ", $options.target].inspect
|
57
|
-
end
|