cddl 0.8.8 → 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.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/bin/cddl +51 -15
  3. data/cddl.gemspec +11 -7
  4. data/data/cddl.abnf +30 -13
  5. data/lib/cbor-pp-play.rb +1 -0
  6. data/lib/cddl.rb +726 -74
  7. data/test/test-cddl.rb +53 -2
  8. data/test-data/7807.cddl +14 -0
  9. data/test-data/abignum.cddl +1 -0
  10. data/test-data/abnf1.cddl +3 -0
  11. data/test-data/abnf2.cddl +37 -0
  12. data/test-data/abnf3.cddl +32 -0
  13. data/test-data/b64c-sloppy.cddl +1 -0
  14. data/test-data/b64c.cddl +1 -0
  15. data/test-data/b64u-strict.cddl +12 -0
  16. data/test-data/b64u.cddl +1 -0
  17. data/test-data/base32.cddl +1 -0
  18. data/test-data/base32hex.cddl +1 -0
  19. data/test-data/bat.cddl +16 -0
  20. data/test-data/bpv7.cddl +136 -0
  21. data/test-data/bpv7a.cddl +181 -0
  22. data/test-data/bpv7b.cddl +167 -0
  23. data/test-data/cat-re.cddl +4 -0
  24. data/test-data/catb64.cddl +8 -0
  25. data/test-data/complex-occ.cddl +11 -0
  26. data/test-data/coral.cddl +10 -0
  27. data/test-data/coral1.cddl +5 -0
  28. data/test-data/coral2.cddl +7 -0
  29. data/test-data/coral3.cddl +7 -0
  30. data/test-data/decimal-warn.cddl +1 -0
  31. data/test-data/decimal.cddl +1 -0
  32. data/test-data/decimal2.cddl +1 -0
  33. data/test-data/det1.cddl +12 -0
  34. data/test-data/dotplus1.cddl +3 -0
  35. data/test-data/dotplus2.cddl +3 -0
  36. data/test-data/dotplus3.cddl +3 -0
  37. data/test-data/dotplus4.cddl +3 -0
  38. data/test-data/enum.cddl +14 -0
  39. data/test-data/enum1.cddl +12 -0
  40. data/test-data/feat1.cddl +4 -0
  41. data/test-data/feature-controller.cddl +6 -0
  42. data/test-data/feature-detail.cddl +5 -0
  43. data/test-data/foo.cddl +1 -0
  44. data/test-data/hex.cddl +1 -0
  45. data/test-data/hexlc.cddl +1 -0
  46. data/test-data/hexuc.cddl +1 -0
  47. data/test-data/homenet-de.cddl +12 -0
  48. data/test-data/homenet-fe.cddl +12 -0
  49. data/test-data/jim-cut-2.cddl +11 -0
  50. data/test-data/jim-cut.cddl +12 -0
  51. data/test-data/join.cddl +1 -0
  52. data/test-data/joini.cddl +1 -0
  53. data/test-data/joinx.cddl +1 -0
  54. data/test-data/json.cddl +1 -0
  55. data/test-data/json1.cddl +15 -0
  56. data/test-data/json2.cddl +1 -0
  57. data/test-data/jsoniodef.cddl +719 -0
  58. data/test-data/jwt.cddl +15 -0
  59. data/test-data/lint1.cddl +9 -0
  60. data/test-data/mdl-ble.cddl +9 -0
  61. data/test-data/mdl-deve.cddl +54 -0
  62. data/test-data/mdl-dp.cddl +11 -0
  63. data/test-data/mdl-mso.cddl +20 -0
  64. data/test-data/mdl-request.cddl +26 -0
  65. data/test-data/mdl-response.cddl +66 -0
  66. data/test-data/mdl.cddl +11 -0
  67. data/test-data/mon-val.cddl +1 -0
  68. data/test-data/multipart-ct.cddl +2 -0
  69. data/test-data/named-group.cddl +7 -0
  70. data/test-data/non-empty.cddl +5 -0
  71. data/test-data/oid.cddl +8 -0
  72. data/test-data/oidbat.cddl +8 -0
  73. data/test-data/plus.cddl +3 -0
  74. data/test-data/prim.cddl +7 -0
  75. data/test-data/printf.cddl +2 -0
  76. data/test-data/printf0.cddl +1 -0
  77. data/test-data/printf1.cddl +2 -0
  78. data/test-data/printf2.cddl +2 -0
  79. data/test-data/printf3.cddl +2 -0
  80. data/test-data/sasl.cddl +24 -0
  81. data/test-data/sequence.cddl +1 -0
  82. data/test-data/sipos.cddl +8 -0
  83. data/test-data/star-edited.cddl +98 -0
  84. data/test-data/star.cddl +95 -0
  85. data/test-data/test-gen.cddl +3 -0
  86. data/test-data/time.cddl +11 -0
  87. data/test-data/valemb.cddl +16 -0
  88. data/test-data/yangid.cddl +1 -0
  89. data/test-data/yaron1.cddl +95 -0
  90. metadata +148 -14
@@ -0,0 +1,8 @@
1
+ a1 = '' .cat a2
2
+ a2 = text .b64u ain
3
+ ; a = "e30" .b64u ain
4
+ ain = '{}'
5
+
6
+ ;;gp 3
7
+ ;;vp 'e30'
8
+ ;;vp "e30"
@@ -0,0 +1,11 @@
1
+ foo = {
2
+ 2*4 any => any
3
+ }
4
+
5
+ ;;sed -n 's/^; //p' complex-occ.cddl | sh
6
+ ; echo '{}' | cddl complex-occ.cddl v -
7
+ ; echo '{"1": 2}' | cddl complex-occ.cddl v -
8
+ ; echo '{"1": 2, "2": 3}' | cddl complex-occ.cddl v -
9
+ ; echo '{"1": 2, "2": 3, "3": 4}' | cddl complex-occ.cddl v -
10
+ ; echo '{"1": 2, "2": 3, "3": 4, "4": 5}' | cddl complex-occ.cddl v -
11
+ ; echo '{"1": 2, "2": 3, "3": 4, "4": 5, "5": 6}' | cddl complex-occ.cddl v -
@@ -0,0 +1,10 @@
1
+ coral = [+ s-exp]
2
+ s-exp = ((text, value, ?coral) // directive)
3
+ value = ctext / cbytes / cint / cfloat / cboolean / cdatetime / null / {"_link": tstr} / {"_form": tstr}
4
+ ctext = text / {"_text": text}
5
+ cint = {"_int": int}
6
+ cfloat = float / {"_float": float}
7
+ cboolean = bool / {"_bool": bool}
8
+ cdatetime = {"_datetime": text}
9
+ cbytes = {"_bytes": text} ; base64url no padding
10
+ directive = (("_using", {* text => text}) // ("_base", text))
@@ -0,0 +1,5 @@
1
+ document = {*element}
2
+ element = (relation => value / [2*value])
3
+
4
+ relation = text
5
+ value = text
@@ -0,0 +1,7 @@
1
+ document = {*element}
2
+ element = (text => value / [2*value])
3
+ value = text / float / bool / tagged
4
+ tagged = {"_int":int,*element} / {"_float":float,*element} / {"_text":text,*element} / {"_bytes":bytes,*element} / {"_datetime":text,*element} / {"_bool":bool,*element} / {"_link":ciri,*element} / {"_form":ciri,*element}
5
+ ciri = text ; full IRI given
6
+ / [text] ; suffix for default prefix
7
+ / [text, text] ; prefix, suffix for that prefix
@@ -0,0 +1,7 @@
1
+ document = {? ("_using" => {* text => text}), *element}
2
+ element = (text => value / [2*value])
3
+ value = text / float / bool / tagged / {*element}
4
+ tagged = {"_int": int, *element} / {"_float": float, *element} / {"_text": text, *element} / {"_bytes": bytes, *element} / {"_datetime": text, *element} / {"_bool": bool, *element} / {"_link": ciri, *element} / {"_form": ciri, *element}
5
+ ciri = text ; full IRI given
6
+ / [text] ; suffix for default prefix
7
+ / [text, text] ; prefix, suffix for that prefix
@@ -0,0 +1 @@
1
+ s = [text .decimal 4711, text .base10 4712]
@@ -0,0 +1 @@
1
+ a = text .decimal uint
@@ -0,0 +1 @@
1
+ a = text .decimal 4711
@@ -0,0 +1,12 @@
1
+ bar = ["" .cat foo, "" .cat cbor-tags-oid]
2
+
3
+ foo = '' .det cbor-tags-oid
4
+
5
+ cbor-tags-oid = '
6
+ oid = 1*arc
7
+ roid = *arc
8
+ arc = [nlsb] %x00-7f
9
+ nlsb = %x81-ff *%x80-ff
10
+ ' .det ''
11
+
12
+ cbor-tags-oid-decrypted = cbor-tags-oid .det (([]) .det ([]))
@@ -0,0 +1,3 @@
1
+ a = b<13..15>
2
+ b<T> = #7.<32 .plus T>
3
+ ; cddl dotplus1.cddl gp 10
@@ -0,0 +1,3 @@
1
+ a = d<17..19>
2
+ d<T> = #7.<T .plus 32>
3
+ ; cddl dotplus.cddl gp 10
@@ -0,0 +1,3 @@
1
+ a = d<17..19>
2
+ d<T> = 32.5 .plus T
3
+ ; cddl dotplus4.cddl gp 10
@@ -0,0 +1,3 @@
1
+ a = d<17..19>
2
+ d<T> = T .plus 32.5
3
+ ; cddl dotplus4.cddl gp 10
@@ -0,0 +1,14 @@
1
+ terminal-color = &basecolors
2
+ basecolors = (
3
+ black: 0, red: 1, green: 2, yellow: 3,
4
+ blue: 4, magenta: 5, cyan: 6, white: 7,
5
+ reserved: (8..255) .feature "extension"
6
+ )
7
+ ; extended-color = &(
8
+ ; basecolors,
9
+ ; orange: 8, pink: 9, purple: 10, brown: 11,
10
+ ; )
11
+
12
+ ;;gp 10
13
+ ;;vp 42
14
+ ;;vp 433
@@ -0,0 +1,12 @@
1
+ terminal-color = $terminal-color / text .feature "extension"
2
+ $terminal-color /= &basecolors
3
+ basecolors = (
4
+ black: "black", red: "red", green: "green",
5
+ )
6
+
7
+ pastelcolors = ( pink: "pink", mauve: "mauve", peach: "peach", lavender: "lavender" )
8
+ $terminal-color /= &pastelcolors
9
+
10
+ ;;gp 10
11
+ ;;vp "florp"
12
+ ;;vp "lavender"
@@ -0,0 +1,4 @@
1
+ bla = {
2
+ a: int
3
+ ? ("b" .feature "foo") => float
4
+ }
@@ -0,0 +1,6 @@
1
+ a = b .feature 3
2
+ b = c .feature 3.3
3
+ c = d .feature (["drei", "ok"])
4
+ d = e .feature ([[], "ok"])
5
+ e = f .feature ([1, "ok"])
6
+ f = int .feature (1)
@@ -0,0 +1,5 @@
1
+ foo = {
2
+ kind: bar / baz .feature (["foo-extensions", "bazify"])
3
+ }
4
+ bar = int
5
+ baz = text ; complex stuff that doesn't all need to be in the detail
@@ -0,0 +1 @@
1
+ foo=bar=int
@@ -0,0 +1 @@
1
+ a = text .hex 'mnoabcd'
@@ -0,0 +1 @@
1
+ a = text .hexlc 'mnoabcd'
@@ -0,0 +1 @@
1
+ a = text .hexuc 'mnoabcd'
@@ -0,0 +1,12 @@
1
+ hna-configuration = {
2
+ "registred_domain" : tstr,
3
+ "dm" : tstr,
4
+ ? "dm_transport" : "53" // "DoT" // "DoH" // "DoQ"
5
+ ? "dm_port" : uint,
6
+ ? "dm_acl" : hna-acl // [ +hna-acl ]
7
+ ? "hna_auth_method": hna-auth-method
8
+ ? "hna_certificate": tstr
9
+ }
10
+
11
+ hna-acl = tstr
12
+ hna-auth-method /= "certificate"
@@ -0,0 +1,12 @@
1
+ hna-configuration = {
2
+ "registered_domain" : tstr,
3
+ "dm" : tstr,
4
+ ? "dm_transport" : "53" / "DoT" / "DoH" / "DoQ"
5
+ ? "dm_port" : uint,
6
+ ? "dm_acl" : hna-acl / [ +hna-acl ]
7
+ ? "hna_auth_method": hna-auth-method
8
+ ? "hna_certificate": tstr
9
+ }
10
+
11
+ hna-acl = tstr
12
+ hna-auth-method /= "certificate"
@@ -0,0 +1,11 @@
1
+
2
+ map-example = {
3
+ ? optional-key : int,
4
+ * map-example-extension,
5
+ * tstr => any
6
+ }
7
+
8
+ map-example-extension = ()
9
+
10
+ map-example-extension //= (another-optional-key : tstr,)
11
+ map-example-extension //= ("and a third" : bstr,)
@@ -0,0 +1,12 @@
1
+ map-example = {
2
+ ? "optional-key" : int,
3
+ map-example-extensions,
4
+ * tstr => any
5
+ }
6
+
7
+ map-example-extensions = ()
8
+
9
+ map-example-extensions //= (
10
+ "another-optional-key" : tstr,
11
+ "and a third": bstr
12
+ )
@@ -0,0 +1 @@
1
+ a = text .join (["a", "b", "c"])
@@ -0,0 +1 @@
1
+ a = text .join (["a", "b", 3])
@@ -0,0 +1 @@
1
+ a = text .join (["a", "b", text])
@@ -0,0 +1 @@
1
+ a = text .json ([4, uint .size 1, {"a": "b"}])
@@ -0,0 +1,15 @@
1
+ ; JWT-JWS = text .join ([
2
+ ; b64u<jwt-headers>, ".",
3
+ ; b64u<jwt-payload>, ".",
4
+ ; b64u<jwt-signature>])
5
+ ; ; a = jwt-headers
6
+ ; ; a = b64u<"abc"> ; fails
7
+ ; ; a = b64u<'abc'> ; succeeds
8
+ ; b64u<B> = text .b64u B
9
+ jwt-headers = '' .cat jwt-headers1
10
+ jwt-headers1 = text .json jwt-headermap
11
+ jwt-headermap = { * text => any } ; simplified
12
+ jwt-payload = bytes
13
+ jwt-signature = bytes
14
+
15
+ ;;gp 10
@@ -0,0 +1 @@
1
+ a = text .json ([4, uint .size 2, {"a": "b"}])