Subject: [Cbor] cddl tool: Support for generics

From: Joachim Breitner <[email-masked]>
Date: Thu, 16 Apr 2020 11:06:14 +0200

Hi,

with a CDDL file accepted by https://cddl.anweiss.tech/ I get an error
message like this from cddl 0.8.10:

*** Look for syntax problems around the %%% markers:
; A request 
request = envelope%%%<(%%%
  some-request /
  another-request 
)>

*** Parse error at 478 upto 480 of 2141 (3487).

Does the cddl tool simply not support instantiating generic rules yet,
or is the validator at https://cddl.anweiss.tech/ not precise enough?

Cheers,
Joachim
-- 
Joachim Breitner
  [email-masked]
  http://www.joachim-breitner.de/

---

From: Carsten Bormann <[email-masked]>
Date: Thu, 16 Apr 2020 14:56:18 +0200

> *** Parse error at 478 upto 480 of 2141 (3487).

Hi Joachim,

my fault, I need to set up the repo for the cddl tool, then you could submit issues there.

> Does the cddl tool simply not support instantiating generic rules yet,

It sure does.

> or is the validator at https://cddl.anweiss.tech/ not precise enough?

No, that just has a better (less buggy) parser.

request = envelope<(some-request/another-request)>
envelope<x> = x
some-request = uint
another-request = text

goes through,

request = envelope<(
some-request/another-request)>
envelope<x> = x
some-request = uint
another-request = text

does not.  Bug in the aching PEG parser in the cddl tool.  The v2 tool, the first parts of which can be tested under the name of cddlc, accepts both and generates this JSON representation of the test file:

["cddl",
 ["=",
  ["name", "request"],
  ["gen",
   "envelope",
   ["tcho", ["name", "some-request"], ["name", "another-request"]]]],
 ["=", ["gen", "envelope", "x"], ["name", "x"]],
 ["=", ["name", "some-request"], ["name", "uint"]],
 ["=", ["name", "another-request"], ["name", "text"]]]

Grüße, Carsten