Re: [abnf-discuss] ABNF colloquialism for end-of-line

Sean Leonard <> Thu, 16 November 2017 21:26 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id 630EC128DF3 for <>; Thu, 16 Nov 2017 13:26:44 -0800 (PST)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -1.9
X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9] autolearn=ham autolearn_force=no
Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id D7mjIZ0P7zoW for <>; Thu, 16 Nov 2017 13:26:42 -0800 (PST)
Received: from ( []) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by (Postfix) with ESMTPS id 70F061200F1 for <>; Thu, 16 Nov 2017 13:26:42 -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 2F23C274FB; Thu, 16 Nov 2017 16:26:39 -0500 (EST)
Content-Type: text/plain; charset=utf-8
Mime-Version: 1.0 (Mac OS X Mail 11.1 \(3445.4.7\))
From: Sean Leonard <>
In-Reply-To: <>
Date: Fri, 17 Nov 2017 05:26:34 +0800
Cc: Carsten Bormann <>, ABNF-Discuss <>
Content-Transfer-Encoding: quoted-printable
Message-Id: <>
References: <> <> <> <>
To: Dave Crocker <>
X-Mailer: Apple Mail (2.3445.4.7)
Archived-At: <>
Subject: Re: [abnf-discuss] ABNF colloquialism for end-of-line
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: "General discussion about tools, activities and capabilities involving the ABNF meta-language" <>
List-Unsubscribe: <>, <>
List-Archive: <>
List-Post: <>
List-Help: <>
List-Subscribe: <>, <>
X-List-Received-Date: Thu, 16 Nov 2017 21:26:44 -0000

> On Nov 16, 2017, at 11:31 PM, Dave Crocker <> wrote:
> Carsten,
> On 11/15/2017 6:35 PM, Carsten Bormann wrote:
>> Hi Dave,
>> On Nov 15, 2017, at 23:37, Dave Crocker <> wrote:
>>> [...]
>> PS.: If ABNF had cuts, I’d write
>>    EOL = [CR ^] LF
>> to get better errors on stray CRs.  Maybe not so important these days.
> Sorry.  Not sure what you mean.  "cuts"? "^”?

To add some color to this point, “cuts” was discussed in the CBOR WG in the context of CDDL. It is a technique from Parsing Expression Grammars. Here is overview:
(see soft cut)

Basically it commits the parser at a particular point, so that it does not backtrack.

However, PEGs are ordered; ABNF is unordered. With ABNF (as presently constituted), all alternatives in a choice are considered simultaneously (order is not relevant). Even if you match one alternative, you’re supposed to try all other alternatives.


are equivalent: the point being that once a CR is encountered, LF is supposed to follow...and if LF does not follow, then the parser fails but throws an error that EOL did not match because there was no LF after the CR (because it’s more specific). However, cuts also takes the initial production CR out of the equation, so if you have:

EOL = CR ~CUT~ LF / LF / CR "foo"

the last alternative will never be reached, because it’s order-sensitive: the ~CUT~ will consume the first CR, so CR "foo" can never be matched. The equivalent technology in regular expressions is “atomic grouping”.

With a context-free grammar, it is better to think about all alternatives simultaneously.