Closed anweiss closed 3 years ago
.cat
is a convenient way to piece together the format described for the controller in .abnf
, but in no way needed. There is no interaction in the semantics.
In that case, how would one denote the ABNF rule to validate against without the use of .cat
? For example,
valid-date = tstr .abnf rfc3339
rfc3339 = `
date-fullyear = 4DIGIT
date-month = 2DIGIT
`
How do I ensure that the JSON string "2004"
is valid against the date-fullyear
rule in the ABNF spec?
valid-date = tstr .abnf 'date-fullyear
date-fullyear = 4DIGIT
date-month = 2DIGIT
`
I don't like that too much, but I haven't found a better way to combine the "element" and the ABNF rules.
Well, in this case, this can be shortened to:
valid-date = tstr .abnf '4DIGIT'
(Actually, these are all invalid as DIGIT is not defined, so really:)
valid-date = tstr .abnf '4DIGIT
DIGIT = %x30-39
'
.cat
is just a nice vehicle to pull in some common ABNF to multiple places of using it by citing different "elements".
It seems I can close this now -- please re-open as needed.
Per the spec:
As I interpret this, in order to to select an element from an ABNF spec using the
.abnf
control operator, one has to.cat
the element name with the UTF-8 byte string representation of the ABNF. IMHO, this is unintuitive as the.cat
control operator as described in Section 2.1 would imply that the target is itself part of the ABNF specification. But the use of.abnf
with.cat
changes the semantics of.cat
in such a way the target becomes more of a "selector" rather than part of a string concatenation.Granted, alternative approaches that come to mind based on the CDDL syntax as is aren't necessarily any more intuitive. My first thought is some sort of key/value selector similar to other languages that makes this clearer ... e.g.
text .abnf controller.element
... But this introduces new syntax that results in additional defined semantics that may not be warranted at this point. And I'm not even sure I like something like this any better. So thinking out loud here.