edn-abnf 0.1.7 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fddd16926a1e5bfe04391f6d13697fbc6efae2f10aa8760c302a166392b0f219
4
- data.tar.gz: 366deb2e42f3ae5260ca3be9e8c8fa9badd95013338534d856f467635d7128bf
3
+ metadata.gz: 53d9d76f5b3a4ac6e05c39d9050d8638ee9c7a7ab40b85e63d76f5deaf908343
4
+ data.tar.gz: 026a649f7b15be50650baa42b81975ddd6ca791458010dfc5f9a11a0e947bb69
5
5
  SHA512:
6
- metadata.gz: 1f752e65f80dcd12430c8add3976d5166689701a4e25892c7c2e4ae6d9f6447cdb7840c59e0294dbe010318e553402e565d24854a461cbdb7063d2d65ea71911
7
- data.tar.gz: dfbe082491e4601b2b59fa6ec2c4304ae24bf7f47f1dbb9b152e2de535afd9c49caa215a537e575162a1b62da10cb722da1cad4b844a34114d9f317d7818f7b4
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.7"
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"
@@ -10,16 +10,16 @@ module EDNGRAMMAR
10
10
  end
11
11
 
12
12
  module Seq0
13
- def S1
14
- elements[1]
13
+ def OC
14
+ elements[0]
15
15
  end
16
16
 
17
17
  def item
18
- elements[2]
18
+ elements[1]
19
19
  end
20
20
 
21
- def S2
22
- elements[3]
21
+ def S
22
+ elements[2]
23
23
  end
24
24
  end
25
25
 
@@ -84,24 +84,14 @@ module EDNGRAMMAR
84
84
  s6, i6 = [], index
85
85
  loop do
86
86
  i7, s7 = index, []
87
- if (match_len = has_terminal?(",", false, index))
88
- r8 = true
89
- @index += match_len
90
- else
91
- terminal_parse_failure('","')
92
- r8 = nil
93
- end
87
+ r8 = _nt_OC
94
88
  s7 << r8
95
89
  if r8
96
- r9 = _nt_S
90
+ r9 = _nt_item
97
91
  s7 << r9
98
92
  if r9
99
- r10 = _nt_item
93
+ r10 = _nt_S
100
94
  s7 << r10
101
- if r10
102
- r11 = _nt_S
103
- s7 << r11
104
- end
105
95
  end
106
96
  end
107
97
  if s7.last
@@ -120,8 +110,8 @@ module EDNGRAMMAR
120
110
  r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
121
111
  s3 << r6
122
112
  if r6
123
- r12 = _nt_OC
124
- s3 << r12
113
+ r11 = _nt_OC
114
+ s3 << r11
125
115
  end
126
116
  end
127
117
  end
@@ -353,12 +343,16 @@ module EDNGRAMMAR
353
343
  end
354
344
 
355
345
  module String0
356
- def S
346
+ def S1
357
347
  elements[0]
358
348
  end
359
349
 
350
+ def S2
351
+ elements[2]
352
+ end
353
+
360
354
  def string1e
361
- elements[1]
355
+ elements[3]
362
356
  end
363
357
  end
364
358
 
@@ -384,7 +378,7 @@ module EDNGRAMMAR
384
378
  end
385
379
  end
386
380
  def ast
387
- arr = [elements[0].ast] + elements[1].elements.map {|x| x.elements[1].ast}
381
+ arr = [elements[0].ast] + elements[1].elements.map {|x| x.elements[3].ast}
388
382
  charr = arr.chunk(&:class).to_a
389
383
  if charr.size == 1
390
384
  unpack_chunk(*charr.first)
@@ -415,8 +409,22 @@ module EDNGRAMMAR
415
409
  r4 = _nt_S
416
410
  s3 << r4
417
411
  if r4
418
- r5 = _nt_string1e
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
419
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
420
428
  end
421
429
  if s3.last
422
430
  r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
@@ -1913,16 +1921,16 @@ module EDNGRAMMAR
1913
1921
  end
1914
1922
 
1915
1923
  module Array0
1916
- def S1
1917
- elements[1]
1924
+ def OC
1925
+ elements[0]
1918
1926
  end
1919
1927
 
1920
1928
  def item
1921
- elements[2]
1929
+ elements[1]
1922
1930
  end
1923
1931
 
1924
- def S2
1925
- elements[3]
1932
+ def S
1933
+ elements[2]
1926
1934
  end
1927
1935
  end
1928
1936
 
@@ -2007,24 +2015,14 @@ module EDNGRAMMAR
2007
2015
  s8, i8 = [], index
2008
2016
  loop do
2009
2017
  i9, s9 = index, []
2010
- if (match_len = has_terminal?(",", false, index))
2011
- r10 = true
2012
- @index += match_len
2013
- else
2014
- terminal_parse_failure('","')
2015
- r10 = nil
2016
- end
2018
+ r10 = _nt_OC
2017
2019
  s9 << r10
2018
2020
  if r10
2019
- r11 = _nt_S
2021
+ r11 = _nt_item
2020
2022
  s9 << r11
2021
2023
  if r11
2022
- r12 = _nt_item
2024
+ r12 = _nt_S
2023
2025
  s9 << r12
2024
- if r12
2025
- r13 = _nt_S
2026
- s9 << r13
2027
- end
2028
2026
  end
2029
2027
  end
2030
2028
  if s9.last
@@ -2043,8 +2041,8 @@ module EDNGRAMMAR
2043
2041
  r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
2044
2042
  s5 << r8
2045
2043
  if r8
2046
- r14 = _nt_OC
2047
- s5 << r14
2044
+ r13 = _nt_OC
2045
+ s5 << r13
2048
2046
  end
2049
2047
  end
2050
2048
  end
@@ -2063,13 +2061,13 @@ module EDNGRAMMAR
2063
2061
  s0 << r4
2064
2062
  if r4
2065
2063
  if (match_len = has_terminal?("]", false, index))
2066
- r15 = true
2064
+ r14 = true
2067
2065
  @index += match_len
2068
2066
  else
2069
2067
  terminal_parse_failure('"]"')
2070
- r15 = nil
2068
+ r14 = nil
2071
2069
  end
2072
- s0 << r15
2070
+ s0 << r14
2073
2071
  end
2074
2072
  end
2075
2073
  end
@@ -2089,16 +2087,16 @@ module EDNGRAMMAR
2089
2087
  end
2090
2088
 
2091
2089
  module Map0
2092
- def S1
2093
- elements[1]
2090
+ def OC
2091
+ elements[0]
2094
2092
  end
2095
2093
 
2096
2094
  def kp
2097
- elements[2]
2095
+ elements[1]
2098
2096
  end
2099
2097
 
2100
- def S2
2101
- elements[3]
2098
+ def S
2099
+ elements[2]
2102
2100
  end
2103
2101
  end
2104
2102
 
@@ -2182,24 +2180,14 @@ module EDNGRAMMAR
2182
2180
  s8, i8 = [], index
2183
2181
  loop do
2184
2182
  i9, s9 = index, []
2185
- if (match_len = has_terminal?(",", false, index))
2186
- r10 = true
2187
- @index += match_len
2188
- else
2189
- terminal_parse_failure('","')
2190
- r10 = nil
2191
- end
2183
+ r10 = _nt_OC
2192
2184
  s9 << r10
2193
2185
  if r10
2194
- r11 = _nt_S
2186
+ r11 = _nt_kp
2195
2187
  s9 << r11
2196
2188
  if r11
2197
- r12 = _nt_kp
2189
+ r12 = _nt_S
2198
2190
  s9 << r12
2199
- if r12
2200
- r13 = _nt_S
2201
- s9 << r13
2202
- end
2203
2191
  end
2204
2192
  end
2205
2193
  if s9.last
@@ -2218,8 +2206,8 @@ module EDNGRAMMAR
2218
2206
  r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
2219
2207
  s5 << r8
2220
2208
  if r8
2221
- r14 = _nt_OC
2222
- s5 << r14
2209
+ r13 = _nt_OC
2210
+ s5 << r13
2223
2211
  end
2224
2212
  end
2225
2213
  end
@@ -2238,13 +2226,13 @@ module EDNGRAMMAR
2238
2226
  s0 << r4
2239
2227
  if r4
2240
2228
  if (match_len = has_terminal?("}", false, index))
2241
- r15 = true
2229
+ r14 = true
2242
2230
  @index += match_len
2243
2231
  else
2244
2232
  terminal_parse_failure('"}"')
2245
- r15 = nil
2233
+ r14 = nil
2246
2234
  end
2247
- s0 << r15
2235
+ s0 << r14
2248
2236
  end
2249
2237
  end
2250
2238
  end
@@ -2779,16 +2767,16 @@ module EDNGRAMMAR
2779
2767
  end
2780
2768
 
2781
2769
  module Streamstring0
2782
- def S1
2783
- elements[1]
2770
+ def OC
2771
+ elements[0]
2784
2772
  end
2785
2773
 
2786
2774
  def string
2787
- elements[2]
2775
+ elements[1]
2788
2776
  end
2789
2777
 
2790
- def S2
2791
- elements[3]
2778
+ def S
2779
+ elements[2]
2792
2780
  end
2793
2781
  end
2794
2782
 
@@ -2854,24 +2842,14 @@ module EDNGRAMMAR
2854
2842
  s5, i5 = [], index
2855
2843
  loop do
2856
2844
  i6, s6 = index, []
2857
- if (match_len = has_terminal?(",", false, index))
2858
- r7 = true
2859
- @index += match_len
2860
- else
2861
- terminal_parse_failure('","')
2862
- r7 = nil
2863
- end
2845
+ r7 = _nt_OC
2864
2846
  s6 << r7
2865
2847
  if r7
2866
- r8 = _nt_S
2848
+ r8 = _nt_string
2867
2849
  s6 << r8
2868
2850
  if r8
2869
- r9 = _nt_string
2851
+ r9 = _nt_S
2870
2852
  s6 << r9
2871
- if r9
2872
- r10 = _nt_S
2873
- s6 << r10
2874
- end
2875
2853
  end
2876
2854
  end
2877
2855
  if s6.last
@@ -2890,17 +2868,17 @@ module EDNGRAMMAR
2890
2868
  r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
2891
2869
  s0 << r5
2892
2870
  if r5
2893
- r11 = _nt_OC
2894
- s0 << r11
2895
- if r11
2871
+ r10 = _nt_OC
2872
+ s0 << r10
2873
+ if r10
2896
2874
  if (match_len = has_terminal?(")", false, index))
2897
- r12 = true
2875
+ r11 = true
2898
2876
  @index += match_len
2899
2877
  else
2900
2878
  terminal_parse_failure('")"')
2901
- r12 = nil
2879
+ r11 = nil
2902
2880
  end
2903
- s0 << r12
2881
+ s0 << r11
2904
2882
  end
2905
2883
  end
2906
2884
  end
@@ -2976,7 +2954,7 @@ module EDNGRAMMAR
2976
2954
  end
2977
2955
 
2978
2956
  module DoubleQuoted0
2979
- def ast; text_value end
2957
+ def ast; text_value.gsub("\r", "") end
2980
2958
  end
2981
2959
 
2982
2960
  module DoubleQuoted1
@@ -3097,7 +3075,7 @@ module EDNGRAMMAR
3097
3075
  end
3098
3076
 
3099
3077
  module SingleQuoted0
3100
- def ast; text_value end
3078
+ def ast; text_value.gsub("\r", "") end
3101
3079
  end
3102
3080
 
3103
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.7
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-06-12 00:00:00.000000000 Z
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.11
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