edn-abnf 0.5.41 → 0.5.43
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 +1 -6
- data/edn-abnf.gemspec +1 -1
- data/lib/cbor-diag-support.rb +3 -0
- data/lib/cbor-diagnostic-app/b64.rb +2 -1
- data/lib/cbor-diagnostic-app/dt.rb +4 -3
- data/lib/cbor-diagnostic-app/h.rb +2 -1
- data/lib/cbor-diagnostic-app/ip.rb +4 -3
- data/lib/cbor-diagnostic-app/t1_b1.rb +6 -6
- data/lib/cbor-diagnostic-app/zzz.rb +4 -4
- data/lib/edn-abnf.rb +10 -0
- data/lib/parser/edn-util.rb +5 -5
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fe28153b880f4ed0b622b3eb4405d8eb72f480729c25d8b30edee80e95e85a74
|
|
4
|
+
data.tar.gz: e10f8b6e293a1ed72f1e4aed231339318752d023e1ddf3d7af94e161c57fc2dd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4e91ccd12231bc740812ba3f774cab99fa3e307b80bd5f729ec0429e8cbd8b99fa74986e8f094c6a2176f6a8dff20764b7645d5d20724b8f7c82957bbfaa52ef
|
|
7
|
+
data.tar.gz: a4834aa184a7b22a57d5a729939f10a3bbde519900faf6199b0609dcbb5473728356f053d5a6b16c0b22ea9c6507faeab23ff014af02e67303dec735259cd2e6
|
data/bin/edn-abnf
CHANGED
|
@@ -7,12 +7,6 @@ require 'json'
|
|
|
7
7
|
require 'cbor-pretty'
|
|
8
8
|
require 'cbor-deterministic'
|
|
9
9
|
|
|
10
|
-
# Temporary fix for name conflicts between cbor-diag and edn-abnf
|
|
11
|
-
diag_path = $LOAD_PATH.grep(/gems\/cbor-diag/).first
|
|
12
|
-
edn_path = $LOAD_PATH.grep(/gems\/edn-abnf/).first
|
|
13
|
-
$LOAD_PATH[$LOAD_PATH.index(diag_path)] = edn_path
|
|
14
|
-
$LOAD_PATH << diag_path
|
|
15
|
-
|
|
16
10
|
require_relative '../lib/edn-abnf.rb'
|
|
17
11
|
|
|
18
12
|
def snaky(name)
|
|
@@ -216,6 +210,7 @@ begin
|
|
|
216
210
|
end
|
|
217
211
|
rescue CBOR_DIAG::AppParseError, ArgumentError => e
|
|
218
212
|
warn "** #{e}"
|
|
213
|
+
warn e.backtrace if $options.verbose
|
|
219
214
|
exit 1
|
|
220
215
|
rescue CBOR::OutOfBytesError, RuntimeError, JSON::GeneratorError => e
|
|
221
216
|
warn "** (encoded CBOR input:) #{e}"
|
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.
|
|
3
|
+
s.version = "0.5.43"
|
|
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/cbor-diag-support.rb
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
require_relative "b64grammar.rb"
|
|
2
2
|
|
|
3
3
|
class CBOR_DIAG::App_b64
|
|
4
|
-
def self.decode(
|
|
4
|
+
def self.decode(prefix, s)
|
|
5
5
|
parser = B64GRAMMARParser.new # B? XXX
|
|
6
|
+
s = EDN.to_one_string(prefix, s)
|
|
6
7
|
ast = parser.parse(s)
|
|
7
8
|
if !ast
|
|
8
9
|
raise CBOR_DIAG::AppParseError.new("cbor-diagnostic: Parse Error in b64'#{s}':\n" << EDN.reason(parser, s), parser.failure_index)
|
|
@@ -7,8 +7,9 @@ require 'time'
|
|
|
7
7
|
# Probably should copy over Time#xmlschema and fix that for us.
|
|
8
8
|
|
|
9
9
|
class CBOR_DIAG::App_dt
|
|
10
|
-
def self.decode(
|
|
10
|
+
def self.decode(prefix, s)
|
|
11
11
|
parser = DTGRAMMARParser.new
|
|
12
|
+
s = EDN.to_one_string(prefix, s)
|
|
12
13
|
ast = parser.parse(s)
|
|
13
14
|
if !ast
|
|
14
15
|
raise CBOR_DIAG::AppParseError.new("cbor-diagnostic: Parse Error in dt'#{s}':\n" << EDN.reason(parser, s), parser.failure_index)
|
|
@@ -21,13 +22,13 @@ class CBOR_DIAG::App_dt
|
|
|
21
22
|
else
|
|
22
23
|
t.to_i
|
|
23
24
|
end
|
|
24
|
-
case
|
|
25
|
+
case prefix
|
|
25
26
|
when 'dt'
|
|
26
27
|
tv
|
|
27
28
|
when 'DT'
|
|
28
29
|
CBOR::Tagged.new(1, tv)
|
|
29
30
|
else
|
|
30
|
-
fail
|
|
31
|
+
fail prefix
|
|
31
32
|
end
|
|
32
33
|
end
|
|
33
34
|
end
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
require_relative "hgrammar.rb"
|
|
2
2
|
|
|
3
3
|
class CBOR_DIAG::App_h
|
|
4
|
-
def self.decode(
|
|
4
|
+
def self.decode(prefix, s)
|
|
5
5
|
parser = HGRAMMARParser.new
|
|
6
|
+
s = EDN.to_one_string(prefix, s)
|
|
6
7
|
ast = parser.parse(s)
|
|
7
8
|
if !ast
|
|
8
9
|
raise CBOR_DIAG::AppParseError.new("cbor-diagnostic: Parse Error in h'#{s}':\n" << EDN.reason(parser, s), parser.failure_index)
|
|
@@ -4,20 +4,21 @@ require 'ipaddr'
|
|
|
4
4
|
require "cbor-diagnostic-app/0"
|
|
5
5
|
|
|
6
6
|
class CBOR_DIAG::App_ip
|
|
7
|
-
def self.decode(
|
|
7
|
+
def self.decode(prefix, s)
|
|
8
8
|
parser = IPGRAMMARParser.new
|
|
9
|
+
s = EDN.to_one_string(prefix, s)
|
|
9
10
|
ast = parser.parse(s)
|
|
10
11
|
if !ast
|
|
11
12
|
raise CBOR_DIAG::AppParseError.new("cbor-diagnostic: Parse Error in ip'#{s}':\n" << EDN.reason(parser, s), parser.failure_index)
|
|
12
13
|
end
|
|
13
14
|
fam, ipv = ast.ast
|
|
14
|
-
case
|
|
15
|
+
case prefix
|
|
15
16
|
when 'ip'
|
|
16
17
|
ipv
|
|
17
18
|
when 'IP'
|
|
18
19
|
CBOR::Tagged.new(fam, ipv)
|
|
19
20
|
else
|
|
20
|
-
fail
|
|
21
|
+
fail prefix
|
|
21
22
|
end
|
|
22
23
|
end
|
|
23
24
|
end
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
require "cbor-diagnostic-app/0"
|
|
2
2
|
|
|
3
3
|
class CBOR_DIAG::Helper
|
|
4
|
-
def self.decode_string(
|
|
4
|
+
def self.decode_string(prefix, s, to_text = false)
|
|
5
5
|
ret = if CBOR::Sequence === s
|
|
6
6
|
args = s.elements
|
|
7
7
|
else
|
|
8
8
|
args = [s]
|
|
9
9
|
end.map { |el|
|
|
10
10
|
unless String === el || el.respond_to?(:value) && String === el.value
|
|
11
|
-
raise ArgumentError.new("cbor-diagnostic: #{
|
|
11
|
+
raise ArgumentError.new("cbor-diagnostic: #{prefix}<<>>: #{el.cbor_diagnostic} not a string: Argument Error")
|
|
12
12
|
end
|
|
13
13
|
el.b
|
|
14
14
|
}.join.b # .b needed so empty array becomes byte string, too
|
|
@@ -20,13 +20,13 @@ class CBOR_DIAG::Helper
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
class CBOR_DIAG::App_b1
|
|
23
|
-
def self.decode(
|
|
24
|
-
CBOR_DIAG::Helper.decode_string(
|
|
23
|
+
def self.decode(prefix, s)
|
|
24
|
+
CBOR_DIAG::Helper.decode_string(prefix, s, false)
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
class CBOR_DIAG::App_t1
|
|
29
|
-
def self.decode(
|
|
30
|
-
CBOR_DIAG::Helper.decode_string(
|
|
29
|
+
def self.decode(prefix, s)
|
|
30
|
+
CBOR_DIAG::Helper.decode_string(prefix, s, true)
|
|
31
31
|
end
|
|
32
32
|
end
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
require "cbor-diagnostic-app/0"
|
|
2
2
|
|
|
3
3
|
class CBOR_DIAG::App_zzz
|
|
4
|
-
def self.decode(
|
|
5
|
-
CBOR::Tagged.new(999, [
|
|
4
|
+
def self.decode(prefix, s)
|
|
5
|
+
CBOR::Tagged.new(999, [prefix, s])
|
|
6
6
|
end
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
class CBOR_DIAG::App_yyy
|
|
10
|
-
def self.decode(
|
|
11
|
-
CBOR::Tagged.new(999, [
|
|
10
|
+
def self.decode(prefix, s)
|
|
11
|
+
CBOR::Tagged.new(999, [prefix, s])
|
|
12
12
|
end
|
|
13
13
|
end
|
data/lib/edn-abnf.rb
CHANGED
|
@@ -5,6 +5,7 @@ class EDN
|
|
|
5
5
|
@@parser = EDNGRAMMARParser.new
|
|
6
6
|
|
|
7
7
|
def self.reason(parser, s)
|
|
8
|
+
s = s.to_str
|
|
8
9
|
reason = [parser.failure_reason]
|
|
9
10
|
parser.failure_reason =~ /^(Expected .+) after ./m
|
|
10
11
|
expected = $1
|
|
@@ -16,7 +17,16 @@ class EDN
|
|
|
16
17
|
reason.join("\n")
|
|
17
18
|
end
|
|
18
19
|
|
|
20
|
+
def self.to_one_string(prefix, s)
|
|
21
|
+
begin
|
|
22
|
+
s.to_str
|
|
23
|
+
rescue NoMethodError => e
|
|
24
|
+
raise ArgumentError.new("cbor-diagnostic #{prefix}<<>>: #{e}: #{s.inspect}")
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
19
28
|
def self.from_edn(s)
|
|
29
|
+
s = s.to_str
|
|
20
30
|
ast = @@parser.parse s
|
|
21
31
|
if !ast
|
|
22
32
|
raise ArgumentError, "Parse Error:\n" << self.reason(@@parser, s)
|
data/lib/parser/edn-util.rb
CHANGED
|
@@ -112,8 +112,8 @@ class Treetop::Runtime::SyntaxNode
|
|
|
112
112
|
end
|
|
113
113
|
|
|
114
114
|
# MTI app-extensions:
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
115
|
+
require_relative '../cbor-diagnostic-app/h'
|
|
116
|
+
require_relative '../cbor-diagnostic-app/b64'
|
|
117
|
+
require_relative '../cbor-diagnostic-app/dt'
|
|
118
|
+
require_relative '../cbor-diagnostic-app/ip'
|
|
119
|
+
require_relative '../cbor-diagnostic-app/t1_b1'
|