cbor-diag 0.6.3 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/cbor2diag.rb +4 -12
- data/bin/cbor2json.rb +4 -9
- data/bin/cbor2yaml.rb +3 -9
- data/bin/cborleader2diag.rb +3 -12
- data/bin/cborseq2diag.rb +3 -12
- data/bin/cborseq2json.rb +3 -9
- data/bin/cborseq2neatjson.rb +4 -9
- data/bin/cborseq2yaml.rb +5 -9
- data/bin/diag2cbor.rb +3 -0
- data/bin/diag2diag.rb +4 -20
- data/bin/diag2pretty.rb +3 -0
- data/bin/json2cbor.rb +4 -9
- data/bin/json2json.rb +3 -9
- data/bin/json2neatjson.rb +3 -10
- data/bin/json2yaml.rb +3 -9
- data/bin/pretty2diag.rb +6 -1
- data/bin/yaml2cbor.rb +3 -9
- data/bin/yaml2json.rb +3 -9
- data/cbor-diag.gemspec +1 -1
- data/lib/cbor-diag-parser.rb +135 -4
- data/lib/cbor-diagnostic-app/dt.rb +17 -0
- data/lib/cbor-diagnostic-helper.rb +35 -0
- data/lib/cbor-diagnostic-parser.rb +3 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d46971cb4fe65291d5659c969853e2776bc803a4260d3831107ee5b801c0fc76
|
4
|
+
data.tar.gz: e54c7b33742851467b3b631220a65558f5493c61eb011a973a5283191d4cbe0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbc73e462fd6fa8a3e44255d4d85847512a320a2e75d141c657849cd21fd1c975429fcaea9798e257ffb681bebec3c6f19d1f50461cc8f36b04a73592ba61fc8
|
7
|
+
data.tar.gz: dad9a127145e629293892154b6b7e51dde44151138f7596f006226ed238a6bc74740f291b40818123d435a25b0f6eb739cb67a8c7c74f3c1c49cd4ab207fe386
|
data/bin/cbor2diag.rb
CHANGED
@@ -4,19 +4,11 @@ require 'cbor-packed'
|
|
4
4
|
require 'cbor-deterministic'
|
5
5
|
require 'cbor-canonical'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
ARGV.shift
|
11
|
-
end
|
7
|
+
|
8
|
+
require 'cbor-diagnostic-helper'
|
9
|
+
options = cbor_diagnostic_process_args("cdetpqu")
|
12
10
|
|
13
11
|
ARGF.binmode
|
14
12
|
i = ARGF.read
|
15
13
|
o = CBOR.decode(i)
|
16
|
-
|
17
|
-
o = o.to_unpacked_cbor if /q/ === options
|
18
|
-
o = o.cbor_pre_canonicalize if /c/ === options
|
19
|
-
o = o.cbor_prepare_deterministic if /d/ === options
|
20
|
-
puts o.cbor_diagnostic(try_decode_embedded: /e/ === options,
|
21
|
-
bytes_as_text: /t/ === options,
|
22
|
-
utf8: /u/ === options)
|
14
|
+
puts cbor_diagnostic_output(o, options)
|
data/bin/cbor2json.rb
CHANGED
@@ -5,19 +5,14 @@ require 'cbor-packed'
|
|
5
5
|
require 'cbor-deterministic'
|
6
6
|
require 'cbor-canonical'
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
ARGV.shift
|
12
|
-
end
|
8
|
+
|
9
|
+
require 'cbor-diagnostic-helper'
|
10
|
+
options = cbor_diagnostic_process_args("cdpqj")
|
13
11
|
|
14
12
|
ARGF.binmode
|
15
13
|
i = ARGF.read
|
16
14
|
o = CBOR.decode(i)
|
17
|
-
o = o
|
18
|
-
o = o.to_unpacked_cbor if /q/ === options
|
19
|
-
o = o.cbor_pre_canonicalize if /c/ === options
|
20
|
-
o = o.cbor_prepare_deterministic if /d/ === options
|
15
|
+
o = cbor_diagnostic_item_processing(o, options)
|
21
16
|
if /j/ === options
|
22
17
|
require 'cbor-transform-j'
|
23
18
|
o = CBOR::Transform_j.new.transform(o)
|
data/bin/cbor2yaml.rb
CHANGED
@@ -12,17 +12,11 @@ class Array
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
options << $1
|
18
|
-
ARGV.shift
|
19
|
-
end
|
15
|
+
require 'cbor-diagnostic-helper'
|
16
|
+
options = cbor_diagnostic_process_args("cdpq")
|
20
17
|
|
21
18
|
ARGF.binmode
|
22
19
|
i = ARGF.read
|
23
20
|
o = CBOR.decode(i)
|
24
|
-
o = o
|
25
|
-
o = o.to_unpacked_cbor if /q/ === options
|
26
|
-
o = o.cbor_prepare_deterministic if /d/ === options
|
27
|
-
o = o.cbor_pre_canonicalize if /c/ === options
|
21
|
+
o = cbor_diagnostic_item_processing(o, options)
|
28
22
|
puts YAML.dump(o)
|
data/bin/cborleader2diag.rb
CHANGED
@@ -4,11 +4,8 @@ require 'cbor-packed'
|
|
4
4
|
require 'cbor-deterministic'
|
5
5
|
require 'cbor-canonical'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
options << $1
|
10
|
-
ARGV.shift
|
11
|
-
end
|
7
|
+
require 'cbor-diagnostic-helper'
|
8
|
+
options = cbor_diagnostic_process_args("cdetpqu")
|
12
9
|
|
13
10
|
ARGF.binmode
|
14
11
|
i = ARGF.read
|
@@ -16,10 +13,4 @@ o,r = CBOR.decode_with_rest(i)
|
|
16
13
|
if r != ''
|
17
14
|
warn "** ignoring rest of #{r.bytesize} bytes after first CBOR data item"
|
18
15
|
end
|
19
|
-
|
20
|
-
o = o.to_unpacked_cbor if /q/ === options
|
21
|
-
o = o.cbor_prepare_deterministic if /d/ === options
|
22
|
-
o = o.cbor_pre_canonicalize if /c/ === options
|
23
|
-
puts o.cbor_diagnostic(try_decode_embedded: /e/ === options,
|
24
|
-
bytes_as_text: /t/ === options,
|
25
|
-
utf8: /u/ === options)
|
16
|
+
puts cbor_diagnostic_output(o, options)
|
data/bin/cborseq2diag.rb
CHANGED
@@ -4,11 +4,8 @@ require 'cbor-packed'
|
|
4
4
|
require 'cbor-deterministic'
|
5
5
|
require 'cbor-canonical'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
options << $1
|
10
|
-
ARGV.shift
|
11
|
-
end
|
7
|
+
require 'cbor-diagnostic-helper'
|
8
|
+
options = cbor_diagnostic_process_args("cdetpqu")
|
12
9
|
|
13
10
|
ARGF.binmode
|
14
11
|
i = ARGF.read
|
@@ -20,13 +17,7 @@ while !i.empty?
|
|
20
17
|
puts "/ *** Garbage at byte #{totalsize-i.bytesize}: #{e.message} /"
|
21
18
|
exit 1
|
22
19
|
end
|
23
|
-
|
24
|
-
o = o.to_unpacked_cbor if /q/ === options
|
25
|
-
o = o.cbor_pre_canonicalize if /c/ === options
|
26
|
-
o = o.cbor_prepare_deterministic if /d/ === options
|
27
|
-
out = o.cbor_diagnostic(try_decode_embedded: /e/ === options,
|
28
|
-
bytes_as_text: /t/ === options,
|
29
|
-
utf8: /u/ === options)
|
20
|
+
out = cbor_diagnostic_output(o, options)
|
30
21
|
if i.empty?
|
31
22
|
puts out
|
32
23
|
else
|
data/bin/cborseq2json.rb
CHANGED
@@ -4,19 +4,13 @@ require 'cbor-pure'
|
|
4
4
|
require 'cbor-deterministic'
|
5
5
|
require 'cbor-canonical'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
options << $1
|
10
|
-
ARGV.shift
|
11
|
-
end
|
7
|
+
require 'cbor-diagnostic-helper'
|
8
|
+
options = cbor_diagnostic_process_args("cdpq")
|
12
9
|
|
13
10
|
ARGF.binmode
|
14
11
|
i = ARGF.read
|
15
12
|
while i != ''
|
16
13
|
o, i = CBOR.decode_with_rest(i)
|
17
|
-
o = o
|
18
|
-
o = o.to_unpacked_cbor if /q/ === options
|
19
|
-
o = o.cbor_pre_canonicalize if /c/ === options
|
20
|
-
o = o.cbor_prepare_deterministic if /d/ === options
|
14
|
+
o = cbor_diagnostic_item_processing(o, options)
|
21
15
|
puts JSON.pretty_generate(o)
|
22
16
|
end
|
data/bin/cborseq2neatjson.rb
CHANGED
@@ -5,19 +5,14 @@ require 'neatjson'
|
|
5
5
|
require 'cbor-deterministic'
|
6
6
|
require 'cbor-canonical'
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
ARGV.shift
|
12
|
-
end
|
8
|
+
|
9
|
+
require 'cbor-diagnostic-helper'
|
10
|
+
options = cbor_diagnostic_process_args("cdpq")
|
13
11
|
|
14
12
|
ARGF.binmode
|
15
13
|
i = ARGF.read
|
16
14
|
while i != ''
|
17
15
|
o, i = CBOR.decode_with_rest(i)
|
18
|
-
o = o
|
19
|
-
o = o.to_unpacked_cbor if /q/ === options
|
20
|
-
o = o.cbor_pre_canonicalize if /c/ === options
|
21
|
-
o = o.cbor_prepare_deterministic if /d/ === options
|
16
|
+
o = cbor_diagnostic_item_processing(o, options)
|
22
17
|
puts JSON.neat_generate(o, after_comma: 1, after_colon: 1)
|
23
18
|
end
|
data/bin/cborseq2yaml.rb
CHANGED
@@ -12,21 +12,17 @@ class Array
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
15
|
+
|
16
|
+
|
17
|
+
require 'cbor-diagnostic-helper'
|
18
|
+
options = cbor_diagnostic_process_args("cdpq")
|
20
19
|
|
21
20
|
|
22
21
|
ARGF.binmode
|
23
22
|
i = ARGF.read
|
24
23
|
while i != ''
|
25
24
|
o, i = CBOR.decode_with_rest(i)
|
26
|
-
o = o
|
27
|
-
o = o.to_unpacked_cbor if /q/ === options
|
28
|
-
o = o.cbor_pre_canonicalize if /c/ === options
|
29
|
-
o = o.cbor_prepare_deterministic if /d/ === options
|
25
|
+
o = cbor_diagnostic_item_processing(o, options)
|
30
26
|
puts YAML.dump(o)
|
31
27
|
end
|
32
28
|
|
data/bin/diag2cbor.rb
CHANGED
data/bin/diag2diag.rb
CHANGED
@@ -7,25 +7,9 @@ unless ''.respond_to? :b
|
|
7
7
|
end
|
8
8
|
require 'cbor-pretty'
|
9
9
|
require 'cbor-diagnostic'
|
10
|
-
require 'cbor-packed'
|
11
|
-
require 'cbor-deterministic'
|
12
|
-
require 'cbor-canonical'
|
13
10
|
|
14
|
-
|
15
|
-
|
16
|
-
options << $1
|
17
|
-
ARGV.shift
|
18
|
-
end
|
19
|
-
|
20
|
-
def diagnostic(o, options)
|
21
|
-
o = o.to_packed_cbor if /p/ === options
|
22
|
-
o = o.to_unpacked_cbor if /q/ === options
|
23
|
-
o = o.cbor_pre_canonicalize if /c/ === options
|
24
|
-
o = o.cbor_prepare_deterministic if /d/ === options
|
25
|
-
puts o.cbor_diagnostic(try_decode_embedded: /e/ === options,
|
26
|
-
bytes_as_text: /t/ === options,
|
27
|
-
utf8: /u/ === options)
|
28
|
-
end
|
11
|
+
require 'cbor-diagnostic-helper'
|
12
|
+
options = cbor_diagnostic_process_args("cdetpqu")
|
29
13
|
|
30
14
|
parser = CBOR_DIAGParser.new
|
31
15
|
|
@@ -37,8 +21,8 @@ if result = parser.parse(i)
|
|
37
21
|
decoded.elements
|
38
22
|
else
|
39
23
|
[decoded]
|
40
|
-
end.map {|x|
|
41
|
-
|
24
|
+
end.map {|x| cbor_diagnostic_output(x, options)}.join(", ")
|
25
|
+
puts out
|
42
26
|
else
|
43
27
|
puts "*** can't parse #{i}"
|
44
28
|
puts "*** #{parser.failure_reason}"
|
data/bin/diag2pretty.rb
CHANGED
data/bin/json2cbor.rb
CHANGED
@@ -5,11 +5,9 @@ require 'cbor-packed'
|
|
5
5
|
require 'cbor-deterministic'
|
6
6
|
require 'cbor-canonical'
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
ARGV.shift
|
12
|
-
end
|
8
|
+
|
9
|
+
require 'cbor-diagnostic-helper'
|
10
|
+
options = cbor_diagnostic_process_args("cdpqvj")
|
13
11
|
|
14
12
|
$stdout.binmode
|
15
13
|
i = ARGF.read
|
@@ -18,10 +16,7 @@ if /j/ === options
|
|
18
16
|
require 'cbor-transform-j'
|
19
17
|
o = CBOR::Transform_jr.new.transform(o)
|
20
18
|
end
|
21
|
-
o = o
|
22
|
-
o = o.to_unpacked_cbor if /q/ === options
|
23
|
-
o = o.cbor_pre_canonicalize if /c/ === options
|
24
|
-
o = o.cbor_prepare_deterministic if /d/ === options
|
19
|
+
o = cbor_diagnostic_item_processing(o, options)
|
25
20
|
o = CBOR.encode(o)
|
26
21
|
print o
|
27
22
|
warn "JSON size: #{i.size} bytes, CBOR size: #{o.size} bytes." if /v/ === options
|
data/bin/json2json.rb
CHANGED
@@ -5,16 +5,10 @@ require 'cbor-packed'
|
|
5
5
|
require 'cbor-deterministic'
|
6
6
|
require 'cbor-canonical'
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
options << $1
|
11
|
-
ARGV.shift
|
12
|
-
end
|
8
|
+
require 'cbor-diagnostic-helper'
|
9
|
+
options = cbor_diagnostic_process_args("cdpq")
|
13
10
|
|
14
11
|
i = ARGF.read
|
15
12
|
o = JSON.load(i)
|
16
|
-
o = o
|
17
|
-
o = o.to_unpacked_cbor if /q/ === options
|
18
|
-
o = o.cbor_pre_canonicalize if /c/ === options
|
19
|
-
o = o.cbor_prepare_deterministic if /d/ === options
|
13
|
+
o = cbor_diagnostic_item_processing(o, options)
|
20
14
|
puts JSON.pretty_generate(o)
|
data/bin/json2neatjson.rb
CHANGED
@@ -6,17 +6,10 @@ require 'cbor-packed'
|
|
6
6
|
require 'cbor-deterministic'
|
7
7
|
require 'cbor-canonical'
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
options << $1
|
12
|
-
ARGV.shift
|
13
|
-
end
|
9
|
+
require 'cbor-diagnostic-helper'
|
10
|
+
options = cbor_diagnostic_process_args("cdpq")
|
14
11
|
|
15
|
-
$stdout.binmode
|
16
12
|
i = ARGF.read
|
17
13
|
o = JSON.load(i)
|
18
|
-
o = o
|
19
|
-
o = o.to_unpacked_cbor if /q/ === options
|
20
|
-
o = o.cbor_pre_canonicalize if /c/ === options
|
21
|
-
o = o.cbor_prepare_deterministic if /d/ === options
|
14
|
+
o = cbor_diagnostic_item_processing(o, options)
|
22
15
|
puts JSON.neat_generate(o, after_comma: 1, after_colon: 1)
|
data/bin/json2yaml.rb
CHANGED
@@ -13,16 +13,10 @@ class Array
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
options << $1
|
19
|
-
ARGV.shift
|
20
|
-
end
|
16
|
+
require 'cbor-diagnostic-helper'
|
17
|
+
options = cbor_diagnostic_process_args("cdpq")
|
21
18
|
|
22
19
|
i = ARGF.read
|
23
20
|
o = JSON.load(i)
|
24
|
-
o = o
|
25
|
-
o = o.to_unpacked_cbor if /q/ === options
|
26
|
-
o = o.cbor_pre_canonicalize if /c/ === options
|
27
|
-
o = o.cbor_prepare_deterministic if /d/ === options
|
21
|
+
o = cbor_diagnostic_item_processing(o, options)
|
28
22
|
puts YAML.dump(o)
|
data/bin/pretty2diag.rb
CHANGED
@@ -7,6 +7,11 @@ def extractbytes(s)
|
|
7
7
|
s.each_line.map {|ln| ln.sub(/#.*/, '')}.join.scan(/[0-9a-fA-F][0-9a-fA-F]/).map {|b| b.to_i(16).chr(Encoding::BINARY)}.join
|
8
8
|
end
|
9
9
|
|
10
|
+
|
11
|
+
require 'cbor-diagnostic-helper'
|
12
|
+
options = cbor_diagnostic_process_args("cdetpqu")
|
13
|
+
|
14
|
+
|
10
15
|
i = extractbytes(ARGF)
|
11
16
|
o = CBOR.decode(i)
|
12
|
-
puts o
|
17
|
+
puts cbor_diagnostic_output(o, options)
|
data/bin/yaml2cbor.rb
CHANGED
@@ -6,19 +6,13 @@ require 'cbor-packed'
|
|
6
6
|
require 'cbor-deterministic'
|
7
7
|
require 'cbor-canonical'
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
options << $1
|
12
|
-
ARGV.shift
|
13
|
-
end
|
9
|
+
require 'cbor-diagnostic-helper'
|
10
|
+
options = cbor_diagnostic_process_args("cdpqv")
|
14
11
|
|
15
12
|
$stdout.binmode
|
16
13
|
i = ARGF.read
|
17
14
|
o = YAML.load(i)
|
18
|
-
o = o
|
19
|
-
o = o.to_unpacked_cbor if /q/ === options
|
20
|
-
o = o.cbor_pre_canonicalize if /c/ === options
|
21
|
-
o = o.cbor_prepare_deterministic if /d/ === options
|
15
|
+
o = cbor_diagnostic_item_processing(o, options)
|
22
16
|
o = CBOR.encode(o)
|
23
17
|
print o
|
24
18
|
warn "YAML size: #{i.size} bytes, CBOR size: #{o.size} bytes." if /v/ === options
|
data/bin/yaml2json.rb
CHANGED
@@ -7,16 +7,10 @@ require 'cbor-packed'
|
|
7
7
|
require 'cbor-deterministic'
|
8
8
|
require 'cbor-canonical'
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
options << $1
|
13
|
-
ARGV.shift
|
14
|
-
end
|
10
|
+
require 'cbor-diagnostic-helper'
|
11
|
+
options = cbor_diagnostic_process_args("cdpq")
|
15
12
|
|
16
13
|
i = ARGF.read
|
17
14
|
o = YAML.load(i)
|
18
|
-
o = o
|
19
|
-
o = o.to_unpacked_cbor if /q/ === options
|
20
|
-
o = o.cbor_pre_canonicalize if /c/ === options
|
21
|
-
o = o.cbor_prepare_deterministic if /d/ === options
|
15
|
+
o = cbor_diagnostic_item_processing(o, options)
|
22
16
|
puts JSON.pretty_generate(o)
|
data/cbor-diag.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "cbor-diag"
|
3
|
-
s.version = "0.
|
3
|
+
s.version = "0.7.0"
|
4
4
|
s.summary = "CBOR (Concise Binary Object Representation) diagnostic notation"
|
5
5
|
s.description = %q{cbor-diag implements diagnostic notation for CBOR, RFC 8949 and RFC 8742}
|
6
6
|
s.author = "Carsten Bormann"
|
data/lib/cbor-diag-parser.rb
CHANGED
@@ -226,18 +226,24 @@ module CBOR_DIAG
|
|
226
226
|
r11 = SyntaxNode.new(input, (index-1)...index) if r11 == true
|
227
227
|
r0 = r11
|
228
228
|
else
|
229
|
-
r12 =
|
229
|
+
r12 = _nt_appstring
|
230
230
|
if r12
|
231
231
|
r12 = SyntaxNode.new(input, (index-1)...index) if r12 == true
|
232
232
|
r0 = r12
|
233
233
|
else
|
234
|
-
r13 =
|
234
|
+
r13 = _nt_embedded
|
235
235
|
if r13
|
236
236
|
r13 = SyntaxNode.new(input, (index-1)...index) if r13 == true
|
237
237
|
r0 = r13
|
238
238
|
else
|
239
|
-
|
240
|
-
|
239
|
+
r14 = _nt_streamstring
|
240
|
+
if r14
|
241
|
+
r14 = SyntaxNode.new(input, (index-1)...index) if r14 == true
|
242
|
+
r0 = r14
|
243
|
+
else
|
244
|
+
@index = i0
|
245
|
+
r0 = nil
|
246
|
+
end
|
241
247
|
end
|
242
248
|
end
|
243
249
|
end
|
@@ -1519,6 +1525,131 @@ module CBOR_DIAG
|
|
1519
1525
|
r0
|
1520
1526
|
end
|
1521
1527
|
|
1528
|
+
module Appstring0
|
1529
|
+
end
|
1530
|
+
|
1531
|
+
module Appstring1
|
1532
|
+
def a
|
1533
|
+
elements[0]
|
1534
|
+
end
|
1535
|
+
|
1536
|
+
def s
|
1537
|
+
elements[2]
|
1538
|
+
end
|
1539
|
+
|
1540
|
+
end
|
1541
|
+
|
1542
|
+
module Appstring2
|
1543
|
+
#'
|
1544
|
+
def to_rb
|
1545
|
+
data = s.elements.map(&:partval).join.b
|
1546
|
+
app = a.text_value
|
1547
|
+
# Find a better place to put a default initialization
|
1548
|
+
CBOR_DIAG::APPS ||= Hash.new { |h, k|
|
1549
|
+
h[k] = begin CBOR_DIAG.const_get("App_#{app}")
|
1550
|
+
rescue NameError
|
1551
|
+
raise ArgumentError.new("cbor-diagnostic: Unknown application-oriented extension #{k}")
|
1552
|
+
end
|
1553
|
+
}
|
1554
|
+
CBOR_DIAG::APPS[app].decode(app, data)
|
1555
|
+
end
|
1556
|
+
end
|
1557
|
+
|
1558
|
+
def _nt_appstring
|
1559
|
+
start_index = index
|
1560
|
+
if node_cache[:appstring].has_key?(index)
|
1561
|
+
cached = node_cache[:appstring][index]
|
1562
|
+
if cached
|
1563
|
+
node_cache[:appstring][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1564
|
+
@index = cached.interval.end
|
1565
|
+
end
|
1566
|
+
return cached
|
1567
|
+
end
|
1568
|
+
|
1569
|
+
i0, s0 = index, []
|
1570
|
+
i1, s1 = index, []
|
1571
|
+
if has_terminal?(@regexps[gr = '\A[a-z]'] ||= Regexp.new(gr), :regexp, index)
|
1572
|
+
r2 = true
|
1573
|
+
@index += 1
|
1574
|
+
else
|
1575
|
+
terminal_parse_failure('[a-z]')
|
1576
|
+
r2 = nil
|
1577
|
+
end
|
1578
|
+
s1 << r2
|
1579
|
+
if r2
|
1580
|
+
s3, i3 = [], index
|
1581
|
+
loop do
|
1582
|
+
if has_terminal?(@regexps[gr = '\A[a-z0-9]'] ||= Regexp.new(gr), :regexp, index)
|
1583
|
+
r4 = true
|
1584
|
+
@index += 1
|
1585
|
+
else
|
1586
|
+
terminal_parse_failure('[a-z0-9]')
|
1587
|
+
r4 = nil
|
1588
|
+
end
|
1589
|
+
if r4
|
1590
|
+
s3 << r4
|
1591
|
+
else
|
1592
|
+
break
|
1593
|
+
end
|
1594
|
+
end
|
1595
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
1596
|
+
s1 << r3
|
1597
|
+
end
|
1598
|
+
if s1.last
|
1599
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
1600
|
+
r1.extend(Appstring0)
|
1601
|
+
else
|
1602
|
+
@index = i1
|
1603
|
+
r1 = nil
|
1604
|
+
end
|
1605
|
+
s0 << r1
|
1606
|
+
if r1
|
1607
|
+
if (match_len = has_terminal?("'", false, index))
|
1608
|
+
r5 = true
|
1609
|
+
@index += match_len
|
1610
|
+
else
|
1611
|
+
terminal_parse_failure('"\'"')
|
1612
|
+
r5 = nil
|
1613
|
+
end
|
1614
|
+
s0 << r5
|
1615
|
+
if r5
|
1616
|
+
s6, i6 = [], index
|
1617
|
+
loop do
|
1618
|
+
r7 = _nt_bstring_part
|
1619
|
+
if r7
|
1620
|
+
s6 << r7
|
1621
|
+
else
|
1622
|
+
break
|
1623
|
+
end
|
1624
|
+
end
|
1625
|
+
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
1626
|
+
s0 << r6
|
1627
|
+
if r6
|
1628
|
+
if (match_len = has_terminal?("'", false, index))
|
1629
|
+
r8 = true
|
1630
|
+
@index += match_len
|
1631
|
+
else
|
1632
|
+
terminal_parse_failure('"\'"')
|
1633
|
+
r8 = nil
|
1634
|
+
end
|
1635
|
+
s0 << r8
|
1636
|
+
end
|
1637
|
+
end
|
1638
|
+
end
|
1639
|
+
if s0.last
|
1640
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1641
|
+
r0.extend(Appstring1)
|
1642
|
+
r0.extend(Appstring2)
|
1643
|
+
else
|
1644
|
+
@index = i0
|
1645
|
+
r0 = nil
|
1646
|
+
end
|
1647
|
+
|
1648
|
+
node_cache[:appstring][start_index] = r0
|
1649
|
+
|
1650
|
+
r0
|
1651
|
+
end
|
1652
|
+
|
1522
1653
|
module Bstring0
|
1523
1654
|
def s
|
1524
1655
|
elements[1]
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'time'
|
2
|
+
|
3
|
+
# Using Time#iso8601 creates the following bugs:
|
4
|
+
# * dt'1970-01-01T10:00:00' is accepted and gives local time
|
5
|
+
# * dt'1970-01-01T10:00:00.0Z' gives an integer instead of a float
|
6
|
+
# Probably should copy over Time#xmlschema and fix that for us.
|
7
|
+
|
8
|
+
class CBOR_DIAG::App_dt
|
9
|
+
def self.decode(_, s)
|
10
|
+
t = Time.iso8601(s)
|
11
|
+
if t.subsec != 0
|
12
|
+
t.to_f
|
13
|
+
else
|
14
|
+
t.to_i
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'cbor-packed'
|
2
|
+
require 'cbor-deterministic'
|
3
|
+
require 'cbor-canonical'
|
4
|
+
|
5
|
+
def cbor_diagnostic_process_args(chars)
|
6
|
+
options = ''
|
7
|
+
while /\A-(?:([#{chars}]+)|a(.*))\z/ === ARGV[0]
|
8
|
+
ARGV.shift
|
9
|
+
if $1
|
10
|
+
options << $1
|
11
|
+
else
|
12
|
+
s = $2
|
13
|
+
s = ARGV.shift if s == ""
|
14
|
+
s.split(",").each do |a|
|
15
|
+
require "cbor-diagnostic-app/#{a}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
options
|
20
|
+
end
|
21
|
+
|
22
|
+
def cbor_diagnostic_item_processing(o, options)
|
23
|
+
o = o.to_packed_cbor if /p/ === options
|
24
|
+
o = o.to_unpacked_cbor if /q/ === options
|
25
|
+
o = o.cbor_pre_canonicalize if /c/ === options
|
26
|
+
o = o.cbor_prepare_deterministic if /d/ === options
|
27
|
+
o
|
28
|
+
end
|
29
|
+
|
30
|
+
def cbor_diagnostic_output(o, options)
|
31
|
+
o = cbor_diagnostic_item_processing(o, options)
|
32
|
+
o.cbor_diagnostic(try_decode_embedded: /e/ === options,
|
33
|
+
bytes_as_text: /t/ === options,
|
34
|
+
utf8: /u/ === options)
|
35
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cbor-diag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -162,6 +162,9 @@ files:
|
|
162
162
|
- bin/yaml2json.rb
|
163
163
|
- cbor-diag.gemspec
|
164
164
|
- lib/cbor-diag-parser.rb
|
165
|
+
- lib/cbor-diagnostic-app/dt.rb
|
166
|
+
- lib/cbor-diagnostic-helper.rb
|
167
|
+
- lib/cbor-diagnostic-parser.rb
|
165
168
|
- lib/cbor-diagnostic.rb
|
166
169
|
- lib/cbor-pretty.rb
|
167
170
|
- lib/cbor-pure.rb
|