cddl icon indicating copy to clipboard operation
cddl copied to clipboard

zcbor test cases failing

Open nslowell opened this issue 2 years ago • 2 comments

I have successfully used https://github.com/NordicSemiconductor/zcbor for generating C code from CDDLs, but my CDDLs and their provided test cases are getting error messages when I try to run them through this tool or the website.

Can you provide some clarification on why the errors are occurring? Is this tool missing support?

Example for https://github.com/NordicSemiconductor/zcbor/blob/main/tests/cases/corner_cases.cddl:

    -
 14 -     onetofourbytes: uint .size 0b1..0o4, ; Testing binary and octal
    -                                 ^^^^^^^ missing definition for rule b1..0o4
    -
 34 - TaggedUnion = #6.4321(bool) // #6.2345(uint)
    -                             ^^ expected rule identifier followed by an assignment token '=', '/=' or '//='
    -
 46 -     #6.0(tentothirtybytetstr: tstr .size 10..30),
    -          ^^^^^^^^^^^^^^^^^^^ invalid tag syntax
    -
 64 -     #6.10(boolval: bool),
    -           ^^^^^^^ invalid tag syntax
    -
 73 - Union = Group / MultiGroup / (3,4) / "\"hello\""
    -                                 ^ expected rule identifier followed by an assignment token '=', '/=' or '//='
    -
 77 -     union: (7=>uint) / (-8=>uint),
    -                    ^ missing closing delimiter
    -
 86 - Level1 = [Level2]
    -           ^^^^^^ missing definition for rule Level2
 87 - Level2 = [2**3Level3] ; Use ** here to test backwards compatibility.
    -             ^ invalid group entry syntax
    -
116 -     unabstractedunion1: (choice1: 1 // choice2: 2),
    -                                     ^^ invalid group entry syntax
    -
121 -     upto4nils: 0*0x04nil,
    -                       ^^ missing definition for rule il
    -
140 -     floats: *float,
    -             ^ invalid group entry syntax
    -
196 -     "r" : (result:result_code),
    -                              ^ missing closing delimiter

nslowell avatar Jul 26 '23 19:07 nslowell

Thanks for reporting this @nslowell. I need to add support for hex, octal and binary numbers which is why 0b1..0o4 isn't parsing correctly.

Some of your CDDL looks a bit wonky too. You're using a lot of (key: value) syntax that is confusing the parser. Anything in the form of key: value is a group entry but you're trying to use that syntax to describe types. For example, the #6.10(boolval: bool) is invalid CDDL because the boolval: bool tag type you've specified is not actually a type but rather a group entry.

anweiss avatar Aug 02 '23 20:08 anweiss

Thanks for responding. I will highlight again that this is CDDL from the creators of zcbor, it's not my direct CDDL. My actual CDDL is simpler--though perhaps still a little "wonky"--but it runs through zcbor without error, so I assumed it was acceptable CDDL. Perhaps there is some interpretation confusion with the RFC.

I will ask NordicSemiconductor for their input, but in the meantime, I welcome any updates. Thanks, again.

nslowell avatar Aug 04 '23 14:08 nslowell