rfc-9165

Additional Control Operators for the Concise Data Definition Language (CDDL)

C. Bormann
date2021-12 streamIETF areaart wgcbor statusPROPOSED STANDARD pages11 canonicalhttps://www.rfc-editor.org/rfc/rfc9165 doi10.17487/RFC9165
The Concise Data Definition Language (CDDL), standardized in RFC 8610, provides "control operators" as its main language extension point. The present document defines a number of control operators that were not yet ready at the time RFC 8610 was completed: .plus, .cat, and .det for the construction of constants; .abnf/.abnfb for including ABNF (RFC 5234 and RFC 7405) in CDDL specifications; and .feature for indicating the use of a non-basic feature in an instance.

Extracted elements (20)

design-rationale §4

Leaving out an extension point entirely would mark instances using extensions as invalid; leaving it in without .feature marking would render mistakes (e.g., 'organisation' vs 'organization') invisible. The .feature operator threads between these two failure modes.

cbor

design-rationale §2.3

The .det operator was introduced because multi-line string literals for embedded ABNF need to be set flush left, but having indentation in source code promotes readability. Using .cat alone would preserve the indentation, making the embedded ABNF invalid.

cbor

design-rationale §4

The .feature operator can support a JSON/CBOR switch idiom (e.g., JC<J,C> = J .feature "json" / C .feature "cbor"), though CDDL currently has no way to enforce mutually exclusive use of features as would be required for such a switch.

cbor

design-rationale §4

The .feature operator was introduced because Boolean valid/invalid validation is too simplistic for rapidly evolving data models. It allows a specification to identify extension points and accept extensions while marking them as such, rather than treating unknown extensions as wholesale invalid.

cbor

design-rationale §2.3

The name .det was chosen as a shortcut for 'dedenting cat' rather than the more obvious .dedcat, which was rejected for being longer and invoking unpleasant images.

cbor

design-rationale §3

Two ABNF operators (.abnf and .abnfb) are needed because ABNF can define both byte sequences and UTF-8 text strings interpreted as Unicode scalar sequences, requiring distinct semantics for the two interpretations.

cbor

interoperability-note §3

All rules referenced in an ABNF operator controller string must be defined within that string — there is no implicit import of core ABNF rules from RFC 5234 or other rule sets. Composition of shared rules must be done explicitly via .cat or .det.

cbor

interoperability-note §3

The ABNF syntax within .abnf/.abnfb controllers is relaxed to allow a single line feed as a newline (CRLF = %x0A / %x0D.0A), as is customary for ABNF itself, though CDDL text strings make specifying newlines tedious.

cbor

normative-requirement §3 MUST

For .abnf and .abnfb operators, the controller string MUST be a string. When a byte string, it MUST be valid UTF-8 and is interpreted as the text string with the same sequence of bytes.

cbor

normative-requirement §2.2 MUST

For the .cat operator, the target and controller both MUST be strings. If the target is a text string, the result of the concatenation MUST be valid UTF-8.

cbor

normative-requirement §2.1 MUST

For the .plus operator, the target and controller both MUST be numeric.

cbor

protocol-element §3

The ABNF controller string for .abnf/.abnfb must be one valid ABNF 'element' followed by zero or more valid 'rules' separated from the element by a newline, allowing the element to select from the ABNF rule list.

cbor

protocol-element §2.2

The .cat control operator identifies a string built from concatenation of the target and the controller. The concatenation is performed on the bytes in both strings, and the result has the same type as the target.

cbor

protocol-element §2.3

The .det control operator works like .cat except that both arguments (target and controller) are independently dedented before concatenation. Dedenting is defined as removing the smallest amount of leftmost blank space present in all non-blank lines from each line.

cbor

protocol-element §4

The .feature control operator annotates the target as making use of the feature named by the controller (usually a string). A validation tool may mark an instance as using a named feature and include the controller as the feature name and the target as feature detail in diagnostic output.

cbor

protocol-element §2.1

The .plus control operator identifies a number constructed by adding the numeric values of the target and the controller. If target and controller are of mixed numeric types (float and integer), the sum is converted to the type of the target; converting from float to integer selects the floor.

cbor

protocol-element §3

Two ABNF control operators are defined: .abnf for ABNF denoting sequences of Unicode scalar values (code points) represented as UTF-8 text strings, and .abnfb for ABNF denoting byte sequences. Both can be applied to targets of either string type.

cbor

protocol-element §4

When the .feature controller is an array, the first element is the feature name and the second element is the detail (usually a string), allowing the specification to hint that more limited detail than the full target is appropriate for diagnostic output.

cbor

registry §5

IANA has registered six new entries in the 'CDDL Control Operators' registry: .plus, .cat, .det, .abnf, .abnfb, and .feature, all referencing RFC 9165.

registry, cbor

security-consideration §6

The security considerations of RFC 8610 apply. The use of formal description techniques such as ABNF can not only simplify but sometimes also complicate a specification, potentially leading to security problems in implementations and the specification itself. ABNF should be judiciously applied and overly complex constructions avoided.

security, cbor