[Cbor] cddl 0.8.17: Add .abnf (draft-ietf-cbor-cddl-control)

Carsten Bormann <cabo@tzi.org> Thu, 25 February 2021 22:58 UTC

Return-Path: <cabo@tzi.org>
X-Original-To: cbor@ietfa.amsl.com
Delivered-To: cbor@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id EC2453A0FC0 for <cbor@ietfa.amsl.com>; Thu, 25 Feb 2021 14:58:30 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.897
X-Spam-Level:
X-Spam-Status: No, score=-1.897 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_BLOCKED=0.001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id l7HqZyqlJunr for <cbor@ietfa.amsl.com>; Thu, 25 Feb 2021 14:58:28 -0800 (PST)
Received: from gabriel-vm-2.zfn.uni-bremen.de (gabriel-vm-2.zfn.uni-bremen.de [134.102.50.17]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 6ED003A0FD0 for <cbor@ietf.org>; Thu, 25 Feb 2021 14:58:27 -0800 (PST)
Received: from [192.168.217.118] (p5089a828.dip0.t-ipconnect.de [80.137.168.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gabriel-vm-2.zfn.uni-bremen.de (Postfix) with ESMTPSA id 4Dmp9Y2GW3zyRY; Thu, 25 Feb 2021 23:58:25 +0100 (CET)
Content-Type: text/plain; charset=utf-8
Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\))
From: Carsten Bormann <cabo@tzi.org>
Date: Thu, 25 Feb 2021 23:58:24 +0100
Cc: Paul Kyzivat <pkyzivat@alum.mit.edu>
X-Mao-Original-Outgoing-Id: 635986704.834802-16870f62130b522e4c03c252730dbd93
Content-Transfer-Encoding: quoted-printable
Message-Id: <AC771EE9-9672-4B2D-B66A-2C815D102687@tzi.org>
To: cbor@ietf.org
X-Mailer: Apple Mail (2.3608.120.23.2.4)
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/p5D3G6DNy5ZAiurp2HLA4E8VtAM>
Subject: [Cbor] cddl 0.8.17: Add .abnf (draft-ietf-cbor-cddl-control)
X-BeenThere: cbor@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Concise Binary Object Representation \(CBOR\)" <cbor.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/cbor>, <mailto:cbor-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cbor/>
List-Post: <mailto:cbor@ietf.org>
List-Help: <mailto:cbor-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/cbor>, <mailto:cbor-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 25 Feb 2021 22:58:36 -0000

After the discussion yesterday, I hacked together a quick PoC of the ABNF support in draft-ietf-cbor-cddl-control.

This is still rather rough:

* Error messages.  Ugh(*).
* It really conforms to RFC 5234, so *no leading whitespace* on your ABNF.
* I haven’t done .abnfb yet, and I expect some rough edges around the unicode handling in .abnf as well.

But the below example from the draft works (generate and validate), after fixing the leading whitespace.

The only surprise for me (beyond the fact that this stuff is so easy that I needed less than six hours to implement this PoC, after all) was how thoroughly I had forgotten about the leading whitespace limitation in RFC 5234 (before Julian Reschke reminded me in a completely unrelated thread a couple of days ago).  Of course, the bap tool has some adaptive handling here that makes this “feature” invisible to spec writers.

Not sure that this surprise should lead to changes in the draft.
The below spec example certainly is less readable than the text in the draft was.
We could add text that removes the common leading whitespace before processing the ABNF proper; this still requires the catted pieces to agree on the leading whitespace (which is bad if you are catting together pieces from different sources).  We could simply stipulate, say, two spaces.

Grüße, Carsten

(*) actually, my ABNF parser has pretty good error messages.
The integration into the (old version of the) CDDL tool is the bummer here.


start = [Tag0, Tag1004]

; for RFC8943:
Tag1004 = #6.1004(text .abnf full-date)
; for RFC 7049
Tag0 = #6.0(text .abnf date-time)

full-date = "full-date" .cat rfc3339
date-time = "date-time" .cat rfc3339

; Note the trick of idiomatically starting with a newline, separating
;   off the element in the .cat from the rule-list
rfc3339 = '
date-fullyear   = 4DIGIT
date-month      = 2DIGIT  ; 01-12
date-mday       = 2DIGIT  ; 01-28, 01-29, 01-30, 01-31 based on
                        ; month/year
time-hour       = 2DIGIT  ; 00-23
time-minute     = 2DIGIT  ; 00-59
time-second     = 2DIGIT  ; 00-58, 00-59, 00-60 based on leap sec
                        ; rules
time-secfrac    = "." 1*DIGIT
time-numoffset  = ("+" / "-") time-hour ":" time-minute
time-offset     = "Z" / time-numoffset

partial-time    = time-hour ":" time-minute ":" time-second
                [time-secfrac]
full-date       = date-fullyear "-" date-month "-" date-mday
full-time       = partial-time time-offset

date-time       = full-date "T" full-time
' .cat rfc5234-core

rfc5234-core = '
DIGIT          =  %x30-39 ; 0-9
; abbreviated here
'