edn-abnf 0.4.1 → 0.5.1
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/bin/edn-abnf +16 -3
- data/edn-abnf.gemspec +1 -1
- data/lib/parser/edngrammar.rb +93 -6
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ddc4fd884d2eb5af3b0dd9b76ca452db54c42def393cd5d53867a70b98b4990
|
4
|
+
data.tar.gz: ba447dfe08051442194cfb9a991bd04ed6e7a9127b5c839ff85c7952d64bc430
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc8950aa2b619fc9482e030b12166f66a5cc091b73ba3802375bb80a8ab41b035a8b57e7c6a82ac785a7937fd4796aa824c47fd2933a47d25f5d434bb585450d
|
7
|
+
data.tar.gz: 410b389c142d948492492dbe37473b1fc78e91f8e057acf4276fc4a69a1d8b67edfc836ce86b563d6d006cc7239c7f97f6f090355dc58b2909a087471ddcb7a3
|
data/bin/edn-abnf
CHANGED
@@ -48,10 +48,19 @@ begin
|
|
48
48
|
$options.edn = v
|
49
49
|
end
|
50
50
|
opts.on("-tFMT", "--to=FMT",
|
51
|
-
[:basic, :neat, :json, :yaml, :edn, :diag, :pretty],
|
51
|
+
[:basic, :neat, :json, :yaml, :edn, :diag, :pretty, :hex],
|
52
52
|
"Target format (default: diag)") do |v|
|
53
53
|
$options.target = v
|
54
54
|
end
|
55
|
+
opts.on("-aAPP", "--app=APP", "Load application extension") do |v|
|
56
|
+
v.split(",") do |nm|
|
57
|
+
if nm =~ /\A[a-z][a-z0-9]*\z/
|
58
|
+
require "cbor-diagnostic-app/#{nm}"
|
59
|
+
else
|
60
|
+
raise ArgumentError.new("edn-abnf: app-extension name #{nm} not valid")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
55
64
|
end
|
56
65
|
op.parse!
|
57
66
|
rescue Exception => e
|
@@ -140,14 +149,18 @@ when :yaml
|
|
140
149
|
puts result.to_yaml
|
141
150
|
when :edn, :diag, nil
|
142
151
|
puts result.cbor_diagnostic
|
143
|
-
when :pretty
|
152
|
+
when :pretty, :hex
|
144
153
|
# XXX can't do Box yet
|
145
154
|
enc = if CBOR::Sequence === result
|
146
155
|
result.to_cborseq
|
147
156
|
else
|
148
157
|
result.to_cbor
|
149
158
|
end
|
150
|
-
|
159
|
+
if $options.target == :pretty
|
160
|
+
puts CBOR::pretty_seq(enc)
|
161
|
+
else
|
162
|
+
puts enc.bytes.map{|x| "%02x" % x}.join
|
163
|
+
end
|
151
164
|
else
|
152
165
|
warn ["Unknown target format: ", $options.target].inspect
|
153
166
|
end
|
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.
|
3
|
+
s.version = "0.5.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
@@ -1740,6 +1740,85 @@ module EDNGRAMMAR
|
|
1740
1740
|
r0
|
1741
1741
|
end
|
1742
1742
|
|
1743
|
+
module AppSequence0
|
1744
|
+
def app_prefix
|
1745
|
+
elements[0]
|
1746
|
+
end
|
1747
|
+
|
1748
|
+
def seq
|
1749
|
+
elements[2]
|
1750
|
+
end
|
1751
|
+
|
1752
|
+
end
|
1753
|
+
|
1754
|
+
module AppSequence1
|
1755
|
+
def ast
|
1756
|
+
args = seq.ast
|
1757
|
+
app = app_prefix.text_value
|
1758
|
+
# Find a better place to put a default initialization
|
1759
|
+
EDNGRAMMAR.const_set(:APPS, Hash.new { |h, k|
|
1760
|
+
h[k] = begin ::CBOR_DIAG.const_get("App_#{k.downcase}")
|
1761
|
+
|
1762
|
+
rescue NameError
|
1763
|
+
raise ArgumentError, "cbor-diagnostic: Unknown application-oriented extension '#{k}'", caller
|
1764
|
+
end
|
1765
|
+
}) unless ::EDNGRAMMAR.const_defined?(:APPS)
|
1766
|
+
::EDNGRAMMAR::APPS[app].decode(app, args)
|
1767
|
+
end
|
1768
|
+
end
|
1769
|
+
|
1770
|
+
def _nt_app_sequence
|
1771
|
+
start_index = index
|
1772
|
+
if node_cache[:app_sequence].has_key?(index)
|
1773
|
+
cached = node_cache[:app_sequence][index]
|
1774
|
+
if cached
|
1775
|
+
node_cache[:app_sequence][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1776
|
+
@index = cached.interval.end
|
1777
|
+
end
|
1778
|
+
return cached
|
1779
|
+
end
|
1780
|
+
|
1781
|
+
i0, s0 = index, []
|
1782
|
+
r1 = _nt_app_prefix
|
1783
|
+
s0 << r1
|
1784
|
+
if r1
|
1785
|
+
if (match_len = has_terminal?("<<", false, index))
|
1786
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
1787
|
+
@index += match_len
|
1788
|
+
else
|
1789
|
+
terminal_parse_failure('"<<"')
|
1790
|
+
r2 = nil
|
1791
|
+
end
|
1792
|
+
s0 << r2
|
1793
|
+
if r2
|
1794
|
+
r3 = _nt_seq
|
1795
|
+
s0 << r3
|
1796
|
+
if r3
|
1797
|
+
if (match_len = has_terminal?(">>", false, index))
|
1798
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
1799
|
+
@index += match_len
|
1800
|
+
else
|
1801
|
+
terminal_parse_failure('">>"')
|
1802
|
+
r4 = nil
|
1803
|
+
end
|
1804
|
+
s0 << r4
|
1805
|
+
end
|
1806
|
+
end
|
1807
|
+
end
|
1808
|
+
if s0.last
|
1809
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1810
|
+
r0.extend(AppSequence0)
|
1811
|
+
r0.extend(AppSequence1)
|
1812
|
+
else
|
1813
|
+
@index = i0
|
1814
|
+
r0 = nil
|
1815
|
+
end
|
1816
|
+
|
1817
|
+
node_cache[:app_sequence][start_index] = r0
|
1818
|
+
|
1819
|
+
r0
|
1820
|
+
end
|
1821
|
+
|
1743
1822
|
module Sqstr0
|
1744
1823
|
def SQUOTE1
|
1745
1824
|
elements[0]
|
@@ -1823,13 +1902,19 @@ module EDNGRAMMAR
|
|
1823
1902
|
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
1824
1903
|
r0 = r2
|
1825
1904
|
else
|
1826
|
-
r3 =
|
1905
|
+
r3 = _nt_app_sequence
|
1827
1906
|
if r3
|
1828
1907
|
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
1829
1908
|
r0 = r3
|
1830
1909
|
else
|
1831
|
-
|
1832
|
-
|
1910
|
+
r4 = _nt_embedded
|
1911
|
+
if r4
|
1912
|
+
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
1913
|
+
r0 = r4
|
1914
|
+
else
|
1915
|
+
@index = i0
|
1916
|
+
r0 = nil
|
1917
|
+
end
|
1833
1918
|
end
|
1834
1919
|
end
|
1835
1920
|
end
|
@@ -5036,9 +5121,11 @@ module EDNGRAMMAR
|
|
5036
5121
|
r0
|
5037
5122
|
end
|
5038
5123
|
|
5039
|
-
end
|
5040
5124
|
|
5041
|
-
class
|
5042
|
-
|
5125
|
+
class Parser < Treetop::Runtime::CompiledParser
|
5126
|
+
include EDNGRAMMAR
|
5127
|
+
end
|
5043
5128
|
end
|
5044
5129
|
|
5130
|
+
EDNGRAMMARParser = EDNGRAMMAR::Parser
|
5131
|
+
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: edn-abnf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date: 2025-
|
10
|
+
date: 2025-04-17 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: bundler
|
@@ -120,7 +119,6 @@ homepage: http://github.com/cabo/edn-abnf
|
|
120
119
|
licenses:
|
121
120
|
- MIT
|
122
121
|
metadata: {}
|
123
|
-
post_install_message:
|
124
122
|
rdoc_options: []
|
125
123
|
require_paths:
|
126
124
|
- lib
|
@@ -135,8 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
133
|
- !ruby/object:Gem::Version
|
136
134
|
version: '0'
|
137
135
|
requirements: []
|
138
|
-
rubygems_version: 3.
|
139
|
-
signing_key:
|
136
|
+
rubygems_version: 3.6.2
|
140
137
|
specification_version: 4
|
141
138
|
summary: CBOR Extended Diagnostic Notation (EDN) implemented in ABNF
|
142
139
|
test_files: []
|