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

Carsten Bormann <> Sat, 27 February 2021 16:02 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id 82ABB3A0C4C for <>; Sat, 27 Feb 2021 08:02:38 -0800 (PST)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -1.898
X-Spam-Status: No, score=-1.898 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id QTBqdV9nWzpN for <>; Sat, 27 Feb 2021 08:02:34 -0800 (PST)
Received: from ( []) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by (Postfix) with ESMTPS id 648CC3A0C43 for <>; Sat, 27 Feb 2021 08:02:34 -0800 (PST)
Received: from [] ( []) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by (Postfix) with ESMTPSA id 4Dnrrm48W9zyhP; Sat, 27 Feb 2021 17:02:32 +0100 (CET)
Content-Type: text/plain; charset=utf-8
Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.\))
From: Carsten Bormann <>
In-Reply-To: <>
Date: Sat, 27 Feb 2021 17:02:31 +0100
Content-Transfer-Encoding: quoted-printable
Message-Id: <>
References: <> <> <> <> <> <> <>
To: Paul Kyzivat <>
X-Mailer: Apple Mail (2.3654.
Archived-At: <>
Subject: Re: [Cbor] cddl 0.8.17: Add .abnf (draft-ietf-cbor-cddl-control)
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Concise Binary Object Representation \(CBOR\)" <>
List-Unsubscribe: <>, <>
List-Archive: <>
List-Post: <>
List-Help: <>
List-Subscribe: <>, <>
X-List-Received-Date: Sat, 27 Feb 2021 16:02:39 -0000

Good point for older languages (it is fun to read the discussion about HT issues when <<~ was introduced to Ruby).
But literal HT is not allowed in CDDL(*), so we are covered there.

Grüße, Carsten

(*) Yeah, you could enter it in hex or base64url.  But that doesn’t turn it into whitespace we would be concerned with.

> On 27. Feb 2021, at 16:50, Paul Kyzivat <> wrote:
> Fixing the indentation problem by removing common leading whitespace breaks if both spaces and HT are used in varying combinations to achieve the indentation. You can try to fix that by transforming HT into spaces using the algorithm of your choice, but it fails if your algorithm differs from that used by the author of the abnf.
> That argues for "fixing" abnf itself. But I agree that won't happen quickly if at all.
> 	Thanks,
> 	Paul
> On 2/27/21 8:36 AM, Carsten Bormann wrote:
>> So RFC 5234 has this indentation problem:
>> oid = bytes .abnfb ("oid" .cat cbor-tags-oid)
>> cbor-tags-oid = '
>>   oid = 1*arc
>>   roid = *arc
>>   arc = [nlsb] %x00-7f
>>   nlsb = %x81-ff *%x80-ff
>> '
>> …does not work, as the ABNF is indented, which is not allowed by RFC 5234.
>> Outdenting the ABNF works, but reduces readability (it also is too easy to confuse  ABNF with CDDL rules!).
>> So how do we make something like the above work?
>> (1) We could fix ABNF.  This is an Internet Standard, so I’d expect this to be a slow process; we want to be done with the new controls earlier than that.
>> (2) We could make CDDL work with ABNF as is, but still allow something like the above.
>> Now how can we do (2):
>> (2a) We define .abnf/.abnfb to ignore leading whitespace.  This requires some elaborate rules like the ones bap uses (see previous mail).  The main problem with this is that if the ABNF is concatenated together from different sources, these must agree on the amount of leading whitespace for this to work.  And this is rather likely as 5234 and other places define “libraries” that need to combined with ABNF from protocol spec RFCs.
>> (2b) We leave .abnf/.abnfb as is, and define an outdenting version of .cat.
>> Let’s call that .bat for the moment.
>> Fix the above example:
>> oid = bytes .abnfb ("oid" .bat cbor-tags-oid)
>> Done.
>> More precisely, .bat takes its controller (right hand side argument), computes the indent (leading whitespace of least-indented non-blank line), and reduces the amount of leading whitespace on each line by the indent.
>> This is only done on the right hand side as it fits the most common use cases.  It also allows keeping some leading whitespace for the target (left hand side argument).  If really both sides need to be outdented, use something like
>> ant<v1, v2> = ("" .bat v1) .bat v2
>> As the outdenting is done before concatenation, .bat has no problems dealing with pieces that are indented by different amounts.
>> I have little problem with introducing this control operator, as there are features in other languages that have similar outdenting semantics, e.g., <<~ in Ruby.
>> CDDL tool 0.8.20 has .bat, if you want to play with that.
>> The retronym generation process for .bat is now officially started (or maybe you have a different name for this that also is short and to the point; .cat-with-undenting-of-right-hand-side is not it).
>> Grüße, Carsten