cddl 0.12.6 → 0.12.14
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/cddl.gemspec +2 -3
- data/data/cddl.abnf +3 -2
- data/lib/cddl.rb +40 -7
- data/test-data/decimal-warn.cddl +1 -0
- metadata +5 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a4b5bfb31fd9b7fcf4cf66a1d0f2a76550c9682215c486d99a03997bab1ae30b
|
|
4
|
+
data.tar.gz: 97f11378fb18576f115ffb8cbd668fe9e14e33e91e4aac01d874c69e206f2fbd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 623f3945c3fff7c04dd2a4e1c77879d585d347092c87b54d5ead6b8fb3ed3c5ab68a58ae67b7f3f936437c8bc9f92dea6f8597509ba8913fbc5e2e47f43d398a
|
|
7
|
+
data.tar.gz: a04d3f282b0d42182f63dd66988fece8fb0ab7ddb4e159b2f8213705503cff0a97b622a172096b881dc4fe70f16bdcc48a51fa035413bc55421bb5e15d1bcda3
|
data/cddl.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
spec = Gem::Specification.new do |s|
|
|
2
2
|
s.name = 'cddl'
|
|
3
|
-
s.version = '0.12.
|
|
3
|
+
s.version = '0.12.14'
|
|
4
4
|
s.summary = "CDDL generator and validator."
|
|
5
5
|
s.description = %{A parser, generator, and validator for CDDL}
|
|
6
6
|
s.add_dependency('cbor-diag')
|
|
@@ -16,11 +16,10 @@ spec = Gem::Specification.new do |s|
|
|
|
16
16
|
s.files = Dir['lib/**/*.rb'] + %w(cddl.gemspec) + Dir['data/**/*.abnf'] + Dir['data/**/*.cddl'] + Dir['test-data/**/*.cddl'] + Dir['test/**/*.rb']
|
|
17
17
|
s.require_path = 'lib'
|
|
18
18
|
s.executables = ['cddl']
|
|
19
|
-
s.default_executable = 'cddl'
|
|
20
19
|
s.required_ruby_version = '>= 2.3'
|
|
21
20
|
s.author = "Carsten Bormann"
|
|
22
21
|
s.email = "cabo@tzi.org"
|
|
23
|
-
s.homepage = "
|
|
22
|
+
s.homepage = "https://www.rfc-editor.org/rfc/rfc8610#appendix-F"
|
|
24
23
|
s.license = 'MIT'
|
|
25
24
|
end
|
|
26
25
|
|
data/data/cddl.abnf
CHANGED
|
@@ -65,9 +65,10 @@ value = number
|
|
|
65
65
|
int = ["-"] uint
|
|
66
66
|
|
|
67
67
|
; This is a float if it has fraction or exponent; int otherwise
|
|
68
|
-
number = int ["." fraction] ["e" exponent ]
|
|
68
|
+
number = hexfloat / (int ["." fraction] ["e" exponent ])
|
|
69
|
+
hexfloat = ["-"] "0x" 1*HEXDIG ["." 1*HEXDIG] "p" exponent
|
|
69
70
|
fraction = 1*DIGIT
|
|
70
|
-
exponent =
|
|
71
|
+
exponent = ["+"/"-"] 1*DIGIT
|
|
71
72
|
|
|
72
73
|
text = %x22 *SCHAR %x22
|
|
73
74
|
SCHAR = %x20-21 / %x23-5B / %x5D-7E / NONASCII / SESC
|
data/lib/cddl.rb
CHANGED
|
@@ -40,6 +40,7 @@ module CDDL
|
|
|
40
40
|
[{}, {}]
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
+
CDDL_UNUSED_OK = ENV["CDDL_UNUSED_OK"]
|
|
43
44
|
|
|
44
45
|
class BackTrack < Exception; end
|
|
45
46
|
|
|
@@ -118,6 +119,16 @@ module CDDL
|
|
|
118
119
|
r.compact
|
|
119
120
|
end
|
|
120
121
|
|
|
122
|
+
def longest_initial_match(old, now)
|
|
123
|
+
md = /\A(.*)(.*)\n\1(.*)\z/.match([old,now].join("\n"))
|
|
124
|
+
md[1..3]
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def diff_message(old, now)
|
|
128
|
+
c, l, r = longest_initial_match(old, now)
|
|
129
|
+
"-- common: >#{c}< -- old: >#{l}< -- new: >#{r}<"
|
|
130
|
+
end
|
|
131
|
+
|
|
121
132
|
def cname(s)
|
|
122
133
|
s.to_s.gsub(/-/, "_")
|
|
123
134
|
end
|
|
@@ -204,7 +215,8 @@ module CDDL
|
|
|
204
215
|
ids = g.children(:id).map(&:to_s)
|
|
205
216
|
# puts ["ids", ids].inspect
|
|
206
217
|
if b = @generics[n]
|
|
207
|
-
fail "Duplicate generics definition #{n}
|
|
218
|
+
fail "Duplicate generics definition #{n} #{
|
|
219
|
+
diff_message(strip_nodes(b[0]).inspect, strip_nodes(rule_ast).inspect)}"
|
|
208
220
|
end
|
|
209
221
|
@generics[n] = [rule_ast, ids]
|
|
210
222
|
else
|
|
@@ -216,7 +228,7 @@ module CDDL
|
|
|
216
228
|
if a == b
|
|
217
229
|
warn "*** Warning: Identical redefinition of #{n} as #{a}"
|
|
218
230
|
else
|
|
219
|
-
fail "Duplicate rule definition #{n}
|
|
231
|
+
fail "Duplicate rule definition #{n} #{diff_message(b, a)}"
|
|
220
232
|
end
|
|
221
233
|
end
|
|
222
234
|
@rules[n] = rule_ast
|
|
@@ -248,7 +260,7 @@ module CDDL
|
|
|
248
260
|
r_process("used_in_cddl_prelude", @rules["used_in_cddl_prelude"])
|
|
249
261
|
@rules.each do |n, r|
|
|
250
262
|
# r_process(n, r) # debug only loop
|
|
251
|
-
warn "*** Unused rule #{n}" unless @stage1[n]
|
|
263
|
+
warn "*** Unused rule #{n}" unless @stage1[n] || CDDL_UNUSED_OK
|
|
252
264
|
end
|
|
253
265
|
if result[0] == :grpent
|
|
254
266
|
warn "Group at top -- first rule must be a type!"
|
|
@@ -625,7 +637,13 @@ module CDDL
|
|
|
625
637
|
end
|
|
626
638
|
content = JSON::dump(generate1(control))
|
|
627
639
|
content
|
|
628
|
-
when :decimal
|
|
640
|
+
when :decimal, :base10
|
|
641
|
+
if conop == :decimal
|
|
642
|
+
unless @decimal_warned
|
|
643
|
+
warn "** .decimal control operator is now called .base10"
|
|
644
|
+
@decimal_warned = true
|
|
645
|
+
end
|
|
646
|
+
end
|
|
629
647
|
unless target == [:prim, 3]
|
|
630
648
|
fail "Don't know yet how to generate #{where}"
|
|
631
649
|
end
|
|
@@ -692,6 +710,7 @@ module CDDL
|
|
|
692
710
|
fail "Not smart enough to generate #{where}#{@last_message}"
|
|
693
711
|
when :within, :and
|
|
694
712
|
try_generate(target) do |content|
|
|
713
|
+
$features ||= Hash.new {|h, k| h[k] = {}}
|
|
695
714
|
if validate1(content, control)
|
|
696
715
|
return content
|
|
697
716
|
elsif conop == :within
|
|
@@ -1023,6 +1042,9 @@ module CDDL
|
|
|
1023
1042
|
@last_data = d
|
|
1024
1043
|
@last_rule = where
|
|
1025
1044
|
ann = nil
|
|
1045
|
+
if CBOR::Tagged === d && d.tag === 888 && ENV["CDDL_888"]
|
|
1046
|
+
return []
|
|
1047
|
+
end
|
|
1026
1048
|
case where[0]
|
|
1027
1049
|
when :type1
|
|
1028
1050
|
if where[1..-1].any? {|r| ann = validate1a(d, r)}
|
|
@@ -1199,7 +1221,14 @@ module CDDL
|
|
|
1199
1221
|
end
|
|
1200
1222
|
when :json
|
|
1201
1223
|
ann if validate1((JSON::load(d) rescue :BAD_JSON), control)
|
|
1202
|
-
when :decimal
|
|
1224
|
+
when :decimal, :base10
|
|
1225
|
+
if conop == :decimal
|
|
1226
|
+
unless @decimal_warned
|
|
1227
|
+
warn "** .decimal control operator is now called .base10"
|
|
1228
|
+
@decimal_warned = true
|
|
1229
|
+
end
|
|
1230
|
+
end
|
|
1231
|
+
|
|
1203
1232
|
ann if (
|
|
1204
1233
|
if /\A0|-?[1-9][0-9]*\z/ === d
|
|
1205
1234
|
validate1((d.to_i rescue :BAD_JSON), control)
|
|
@@ -1547,7 +1576,11 @@ module CDDL
|
|
|
1547
1576
|
end
|
|
1548
1577
|
}
|
|
1549
1578
|
end
|
|
1550
|
-
|
|
1579
|
+
if s =~ /p.*\d\z/ # hexfloat
|
|
1580
|
+
val = s.scanf("%a").first
|
|
1581
|
+
else
|
|
1582
|
+
val = eval(s)
|
|
1583
|
+
end
|
|
1551
1584
|
# warn val
|
|
1552
1585
|
case val
|
|
1553
1586
|
when Integer; [:int, val]
|
|
@@ -1740,7 +1773,7 @@ module CDDL
|
|
|
1740
1773
|
:within, :and,
|
|
1741
1774
|
:default, :lt, :le, :gt, :ge, :eq, :ne,
|
|
1742
1775
|
:feature, :abnf, :abnfb, :det, :cat, :plus,
|
|
1743
|
-
:json, :decimal, :join,
|
|
1776
|
+
:json, :decimal, :base10, :join,
|
|
1744
1777
|
:b64u, :"b64u-sloppy", :b64c, :"b64c-sloppy",
|
|
1745
1778
|
:b45, :b32, :h32, :hex, :hexlc, :hexuc,
|
|
1746
1779
|
:printf,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
s = [text .decimal 4711, text .base10 4712]
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cddl
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.12.
|
|
4
|
+
version: 0.12.14
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Carsten Bormann
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: cbor-diag
|
|
@@ -184,6 +183,7 @@ files:
|
|
|
184
183
|
- test-data/cose.cddl
|
|
185
184
|
- test-data/dcaf.cddl
|
|
186
185
|
- test-data/dcaf1.cddl
|
|
186
|
+
- test-data/decimal-warn.cddl
|
|
187
187
|
- test-data/decimal.cddl
|
|
188
188
|
- test-data/decimal2.cddl
|
|
189
189
|
- test-data/det1.cddl
|
|
@@ -272,11 +272,10 @@ files:
|
|
|
272
272
|
- test-data/yangid.cddl
|
|
273
273
|
- test-data/yaron1.cddl
|
|
274
274
|
- test/test-cddl.rb
|
|
275
|
-
homepage:
|
|
275
|
+
homepage: https://www.rfc-editor.org/rfc/rfc8610#appendix-F
|
|
276
276
|
licenses:
|
|
277
277
|
- MIT
|
|
278
278
|
metadata: {}
|
|
279
|
-
post_install_message:
|
|
280
279
|
rdoc_options: []
|
|
281
280
|
require_paths:
|
|
282
281
|
- lib
|
|
@@ -291,8 +290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
291
290
|
- !ruby/object:Gem::Version
|
|
292
291
|
version: '0'
|
|
293
292
|
requirements: []
|
|
294
|
-
rubygems_version:
|
|
295
|
-
signing_key:
|
|
293
|
+
rubygems_version: 4.0.8
|
|
296
294
|
specification_version: 4
|
|
297
295
|
summary: CDDL generator and validator.
|
|
298
296
|
test_files: []
|