Re: [abnf-discuss] Unordered lists with specific cardinality

Paul Kyzivat <pkyzivat@alum.mit.edu> Tue, 12 June 2012 20:00 UTC

X-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000
Delivered-To: barryleiba.mailing.lists@gmail.com
Received: by 10.112.48.104 with SMTP id k8csp158532lbn; Tue, 12 Jun 2012 13:00:09 -0700 (PDT)
Received: by 10.68.200.197 with SMTP id ju5mr42133081pbc.19.1339531208462; Tue, 12 Jun 2012 13:00:08 -0700 (PDT)
Return-Path: <abnf-discuss-bounces@ietf.org>
Received: from mail.ietf.org (mail.ietf.org. [2001:1890:123a::1:1e]) by mx.google.com with ESMTP id gk9si771897pbc.8.2012.06.12.13.00.07; Tue, 12 Jun 2012 13:00:08 -0700 (PDT)
Received-SPF: fail (google.com: domain of abnf-discuss-bounces@ietf.org does not designate 2001:1890:123a::1:1e as permitted sender) client-ip=2001:1890:123a::1:1e;
Authentication-Results: mx.google.com; spf=hardfail (google.com: domain of abnf-discuss-bounces@ietf.org does not designate 2001:1890:123a::1:1e as permitted sender) smtp.mail=abnf-discuss-bounces@ietf.org; dkim=pass (test mode) header.i=@ietf.org
Received: from ietfa.amsl.com (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 745D621F854F; Tue, 12 Jun 2012 13:00:07 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ietf.org; s=ietf1; t=1339531207; bh=pVNUOGNCnS3qDwX55PW6lhsdYl/y3H/7xyk9B3DaIG8=; h=Message-ID:Date:From:MIME-Version:To:References:In-Reply-To: Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help: List-Subscribe:Content-Transfer-Encoding:Content-Type:Sender; b=WyNWuOzr7jN70EujY/UiDjOWtAzwvUIYThCkF1uCSMqkyBWUU6s65wmIM2RejvKKj tBmLt++S5pfwBttIjZp6G7zq6TEL0s/kJmNi4DVtbyYJTnGwJ9MdYE4e9LeclNOAip /jKzbU39GnrobK1aPUDhq+pBKuYpSwVBzwtIgdSQ=
X-Original-To: abnf-discuss@ietfa.amsl.com
Delivered-To: abnf-discuss@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 3E5B821F850D for <abnf-discuss@ietfa.amsl.com>; Tue, 12 Jun 2012 13:00:06 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.92
X-Spam-Level:
X-Spam-Status: No, score=-1.92 tagged_above=-999 required=5 tests=[AWL=0.679, BAYES_00=-2.599]
Received: from mail.ietf.org ([12.22.58.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CugMwFH-tkMH for <abnf-discuss@ietfa.amsl.com>; Tue, 12 Jun 2012 13:00:05 -0700 (PDT)
Received: from qmta11.emeryville.ca.mail.comcast.net (qmta11.emeryville.ca.mail.comcast.net [76.96.27.211]) by ietfa.amsl.com (Postfix) with ESMTP id 77A6B21F8543 for <abnf-discuss@ietf.org>; Tue, 12 Jun 2012 13:00:04 -0700 (PDT)
Received: from omta23.emeryville.ca.mail.comcast.net ([76.96.30.90]) by qmta11.emeryville.ca.mail.comcast.net with comcast id MX7w1j0021wfjNsABY04tJ; Tue, 12 Jun 2012 20:00:04 +0000
Received: from Paul-Kyzivats-MacBook-Pro.local ([83.241.130.138]) by omta23.emeryville.ca.mail.comcast.net with comcast id MXzi1j00o2zJWM78jXzowX; Tue, 12 Jun 2012 19:59:59 +0000
Message-ID: <4FD79FAD.8040409@alum.mit.edu>
Date: Tue, 12 Jun 2012 21:59:41 +0200
From: Paul Kyzivat <pkyzivat@alum.mit.edu>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:12.0) Gecko/20120428 Thunderbird/12.0.1
MIME-Version: 1.0
To: abnf-discuss@ietf.org
References: <2CCD27F5-B8D5-4C51-A830-54E6E2676029@lineone.net>
In-Reply-To: <2CCD27F5-B8D5-4C51-A830-54E6E2676029@lineone.net>
Subject: Re: [abnf-discuss] Unordered lists with specific cardinality
X-BeenThere: abnf-discuss@ietf.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: "General discussion about tools, activities and capabilities involving the ABNF meta-language" <abnf-discuss.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/abnf-discuss>, <mailto:abnf-discuss-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/abnf-discuss>
List-Post: <mailto:abnf-discuss@ietf.org>
List-Help: <mailto:abnf-discuss-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/abnf-discuss>, <mailto:abnf-discuss-request@ietf.org?subject=subscribe>
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"; Format="flowed"
Sender: abnf-discuss-bounces@ietf.org
Errors-To: abnf-discuss-bounces@ietf.org

Paul M,

Yes, I see issues like this quite a lot, though I would characterize the 
issue a little differently. I usually see this as a desire to have a 
list of optional items. The actual items each have their own syntax, and 
each must appear at most once in the list. E.g.

optionlist = [option *[COMMA option]]
option = "A" | "B" | "C"

The above syntax allows: A,B,C and B,A and C.
But it also allows: A,A,B,A,B,C which isn't intended.

For small numbers of options this can be solved by brute force:

optionslist = "A" [COMMA "B" [COMMA "C"]]
             / "A" [COMMA "C" [COMMA "B"]]
             / "B" [COMMA "A" [COMMA "C"]]
             / "B" [COMMA "C" [COMMA "A"]]
             / "C" [COMMA "A" [COMMA "B"]]
             / "C" [COMMA "B" [COMMA "A"]]

But its too cumbersome to do that in practice. So we get by by giving 
something at is too loose and tightening it down with words.

It would be nice to extend ABNF with some syntax to help with this. But 
no good syntax for this leaps into my mind.

	Thanks,
	Paul

On 6/11/12 9:56 PM, Paul Moore wrote:
> Hi everyone,
>
> *Background*
>
> I'm documenting a vendor specific media type
> (application/vnd.whosebill+json) which I intend to publish as an
> Informational RFC. However, I'm having some trouble with the handling of
> unordered lists in ABNF.
>
> Broadly, from my research it would appear that this has been a
> long-standing problem, and authors have typically used one of two
> approaches:
>
> *Approach A - Specific cardinality, unordered nature in prose*
>
> In this approach, authors document the list as an ordered rule, *and*
> annotate the list to communicate the unordered nature:
>
>     myobject = begin-object members end-object
>     members = member-a [separator member-b] separator member-c
>     ; the ordering of the members is unimportant
>     begin-object = %x7B ; "{"
>     end-object = %x7D ; "}"
>     separator = %x2C ; ","
>
>
> Pros: Cardinality is ABNF specific (as 'member-b').
> Cons: Ordering has to *fixed* by prose.
> Example: RFC 2045 (MIME Format) - MIME Header Fields
> <http://tools.ietf.org/html/rfc2045#section-3> which states "/The
> ordering of the header fields implied by this BNF definition should be
> ignored"/
>
> or,
>
> *Approach B - Specific unordered nature, cardinality in prose*
>
> In this approach, authors document the list as a selection of
> alternatives, and annotate the cardinality of each member in prose
>
>     myobject = begin-object member *( separator member ) end-object
>     member = member-a
>     / member-b ; required
>     / member-c
>     begin-object = %x7B ; "{"
>     end-object = %x7D ; "}"
>     separator = %x2C ; ","
>
>
> Pros: Unordered nature is implicit through the combination of optional
> alternative values.
> Cons: Cardinality concerns are reduced to prose.
> Example: RFC 5988 (Web Linking) - Link grammar
> <http://tools.ietf.org/html/rfc5988#page-7>. There is some discussion
> about this specific approach in a rejected erratum
> <http://www.rfc-editor.org/errata_search.php?eid=3080> of the same RFC,
> where Mark Nottingham notes "/The proposed ABNF makes ordering
> significant, which is NOT specified or intended. ABNF can never capture
> all of the constraints on syntax; that's why we have prose."/
> *Problem*
>
> My (limited) research implies that ABNF cannot precisely articulate
> unordered lists with specific cardinality; authors are left with a
> choice as to which aspect to handle in prose.
>
> There is some discussion about the problem by Chris Newman here
> <http://www.imc.org/ietf-calendar/archive1/msg03550.html>, and Chris
> advocates a more formulated arrangement of the cardinality in prose
> approach here
> <http://tools.ietf.org/html/draft-ietf-drums-msg-fmt-07#section-3.6>.
>
> Additionally, from examination of the earlier ABNF drafts (RFC 2234) I
> see there was some discussion of a 'list rule' (#rule) and latterly a 'set
> group' with similar intent, but none of these proposals made it to the
> final versions.
>
> I also stumbled across a thread which implicated that use of the 'list
> rule' / 'set group' proposals would cause ambiguities in ABNF, and
> therefore were not pursued. I appreciate that syntax features must be
> carefully designed so as not to introduce ambiguity, but I'm not a lexer
> / parser specialist, and so would like to get a view of whether this is
> something that could be considered for a latter revision of ABNF?
>
> *Questions*
> *
> *
> 1. Is my understanding that ABNF is unable to articulate unordered lists
> with specific cardinality correct, or am I missing something?
>
> 2. Would introducing functionality to allow such lists fundamentally
> introduce ambiguity into the ABNF syntax?
>
>
> Many thanks for your time
>
> Paul
>
>
> _______________________________________________
> abnf-discuss mailing list
> abnf-discuss@ietf.org
> https://www.ietf.org/mailman/listinfo/abnf-discuss

_______________________________________________
abnf-discuss mailing list
abnf-discuss@ietf.org
https://www.ietf.org/mailman/listinfo/abnf-discuss