edn-abnf 0.5.4 → 0.5.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 922ecd2d704ac04d4e5528eb69a1f0db417783db1919f4da4defb1292639b4bb
4
- data.tar.gz: bd1cc06141be181acd59f63b15496c390dd9f6e522fc8586f7f92a6b43a8f34e
3
+ metadata.gz: 3af63aa900f9f717d9f2d2a50a15ee315d7e6c08c6c1a25cf774b4ee2d9b1582
4
+ data.tar.gz: a3e7fccd19e0b3ce9858d023dc1217c65b624be46a88561078b32c9a3f626a9f
5
5
  SHA512:
6
- metadata.gz: 85e253915ca89b58db123872902d38c208064d4f71b808381129ac6b177e3d603d1731dc86721b224388a9ab1de76af113dca1ce75147c84353ca14bdc1f310f
7
- data.tar.gz: 78885798497255c6530f96fd048fb2f48fcbe4d6cadceaee2c8b8aa117a460bdba9041d6473a08382323d1fb1f2a084a75ac613df5eb3ead22322419336c32c9
6
+ metadata.gz: 9a1c93950df83082da957bfeb9b3989981615d15c48100af5f01682532496d93d5191e5ce435b0c747c7107c86a3d9cc072e3c4f6d08296ccfa6431d42d38322
7
+ data.tar.gz: 7f3feae2f8db35a1206527a8b4142dfa7f28e276a85b0cad8f1b931a8c3e713a622f6dd6b3e2f35d05a0e6e6db79225eb33f387e51f364e317b80ca0f67fe76a
data/bin/edn-abnf CHANGED
@@ -34,6 +34,8 @@ require 'ostruct'
34
34
 
35
35
  $error = 0
36
36
 
37
+ output_formats = [:basic, :neat, :json, :yaml, :edn, :diag, :pretty, :hex, :cbor]
38
+
37
39
  $options = OpenStruct.new
38
40
  begin
39
41
  op = OptionParser.new do |opts|
@@ -46,12 +48,15 @@ begin
46
48
  require 'csv'
47
49
  $options.lines = v
48
50
  end
51
+ opts.on("-i", "--[no-]integrated", "use integrated parsers where available") do |v|
52
+ $options.integrated = v
53
+ end
49
54
  opts.on("-eEDN", "--e=EDN", "supply EDN on command line") do |v|
50
55
  $options.edn = v
51
56
  end
52
57
  opts.on("-tFMT", "--to=FMT",
53
- [:basic, :neat, :json, :yaml, :edn, :diag, :pretty, :hex],
54
- "Target format (default: diag)") do |v|
58
+ output_formats,
59
+ "Target format (#{output_formats.join("/")}, default: diag)") do |v|
55
60
  $options.target = v
56
61
  end
57
62
  opts.on("-aAPP", "--app=APP", "Load application extension") do |v|
@@ -162,17 +167,23 @@ when :yaml
162
167
  puts result.to_yaml
163
168
  when :edn, :diag, nil
164
169
  puts result.cbor_diagnostic
165
- when :pretty, :hex
170
+ when :pretty, :hex, :cbor
166
171
  # XXX can't do Box yet
167
172
  enc = if CBOR::Sequence === result
168
173
  result.to_cborseq
169
174
  else
170
175
  result.to_cbor
171
176
  end
172
- if $options.target == :pretty
177
+ case $options.target
178
+ when :pretty
173
179
  puts CBOR::pretty_seq(enc)
174
- else
180
+ when :hex
175
181
  puts enc.bytes.map{|x| "%02x" % x}.join
182
+ when :cbor
183
+ $stdout.binmode
184
+ print enc
185
+ else
186
+ fail "Cannot happen"
176
187
  end
177
188
  else
178
189
  warn ["Unknown target format: ", $options.target].inspect
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.5.4"
3
+ s.version = "0.5.6"
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"
@@ -1865,6 +1865,28 @@ module EDNGRAMMAR
1865
1865
  r0
1866
1866
  end
1867
1867
 
1868
+ module Bstr0
1869
+ def sq_app_string_h
1870
+ elements[0]
1871
+ end
1872
+
1873
+ end
1874
+
1875
+ module Bstr1
1876
+ def ast; elements[0].ast end
1877
+ end
1878
+
1879
+ module Bstr2
1880
+ def sq_app_string_b64
1881
+ elements[0]
1882
+ end
1883
+
1884
+ end
1885
+
1886
+ module Bstr3
1887
+ def ast; elements[0].ast end
1888
+ end
1889
+
1868
1890
  def _nt_bstr
1869
1891
  start_index = index
1870
1892
  if node_cache[:bstr].has_key?(index)
@@ -1877,35 +1899,85 @@ module EDNGRAMMAR
1877
1899
  end
1878
1900
 
1879
1901
  i0 = index
1880
- r1 = _nt_sq_app_string_h
1902
+ i1, s1 = index, []
1903
+ r2 = _nt_sq_app_string_h
1904
+ s1 << r2
1905
+ if r2
1906
+ i3 = index
1907
+ r4 = lambda {|x|$options.integrated}.call(s1)
1908
+ if !r4
1909
+ terminal_parse_failure("<semantic predicate>")
1910
+ end
1911
+ if r4
1912
+ @index = i3
1913
+ r3 = instantiate_node(SyntaxNode,input, index...index)
1914
+ else
1915
+ @index = i3
1916
+ r3 = nil
1917
+ end
1918
+ s1 << r3
1919
+ end
1920
+ if s1.last
1921
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
1922
+ r1.extend(Bstr0)
1923
+ r1.extend(Bstr1)
1924
+ else
1925
+ @index = i1
1926
+ r1 = nil
1927
+ end
1881
1928
  if r1
1882
1929
  r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
1883
1930
  r0 = r1
1884
1931
  else
1885
- r2 = _nt_sq_app_string_b64
1886
- if r2
1887
- r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
1888
- r0 = r2
1932
+ i5, s5 = index, []
1933
+ r6 = _nt_sq_app_string_b64
1934
+ s5 << r6
1935
+ if r6
1936
+ i7 = index
1937
+ r8 = lambda {|x|$options.integrated}.call(s5)
1938
+ if !r8
1939
+ terminal_parse_failure("<semantic predicate>")
1940
+ end
1941
+ if r8
1942
+ @index = i7
1943
+ r7 = instantiate_node(SyntaxNode,input, index...index)
1944
+ else
1945
+ @index = i7
1946
+ r7 = nil
1947
+ end
1948
+ s5 << r7
1949
+ end
1950
+ if s5.last
1951
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
1952
+ r5.extend(Bstr2)
1953
+ r5.extend(Bstr3)
1889
1954
  else
1890
- r3 = _nt_app_string
1891
- if r3
1892
- r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
1893
- r0 = r3
1955
+ @index = i5
1956
+ r5 = nil
1957
+ end
1958
+ if r5
1959
+ r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
1960
+ r0 = r5
1961
+ else
1962
+ r9 = _nt_app_string
1963
+ if r9
1964
+ r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
1965
+ r0 = r9
1894
1966
  else
1895
- r4 = _nt_sqstr
1896
- if r4
1897
- r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
1898
- r0 = r4
1967
+ r10 = _nt_sqstr
1968
+ if r10
1969
+ r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
1970
+ r0 = r10
1899
1971
  else
1900
- r5 = _nt_app_sequence
1901
- if r5
1902
- r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
1903
- r0 = r5
1972
+ r11 = _nt_app_sequence
1973
+ if r11
1974
+ r11 = SyntaxNode.new(input, (index-1)...index) if r11 == true
1975
+ r0 = r11
1904
1976
  else
1905
- r6 = _nt_embedded
1906
- if r6
1907
- r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
1908
- r0 = r6
1977
+ r12 = _nt_embedded
1978
+ if r12
1979
+ r12 = SyntaxNode.new(input, (index-1)...index) if r12 == true
1980
+ r0 = r12
1909
1981
  else
1910
1982
  @index = i0
1911
1983
  r0 = nil
@@ -5913,7 +5985,7 @@ module EDNGRAMMAR
5913
5985
  r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
5914
5986
  r0 = r1
5915
5987
  else
5916
- r2 = _nt_lcalpha
5988
+ r2 = _nt_ALPHA
5917
5989
  if r2
5918
5990
  r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
5919
5991
  r0 = r2
@@ -5923,14 +5995,8 @@ module EDNGRAMMAR
5923
5995
  r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
5924
5996
  r0 = r3
5925
5997
  else
5926
- r4 = _nt_ucalpha
5927
- if r4
5928
- r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
5929
- r0 = r4
5930
- else
5931
- @index = i0
5932
- r0 = nil
5933
- end
5998
+ @index = i0
5999
+ r0 = nil
5934
6000
  end
5935
6001
  end
5936
6002
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edn-abnf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-04-29 00:00:00.000000000 Z
10
+ date: 2025-05-15 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: bundler