Re: [Json] ABNF nits

Stefan Drees <stefan@drees.name> Fri, 07 June 2013 14:28 UTC

Return-Path: <stefan@drees.name>
X-Original-To: json@ietfa.amsl.com
Delivered-To: json@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 0B85821F9473 for <json@ietfa.amsl.com>; Fri, 7 Jun 2013 07:28:44 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.904
X-Spam-Level:
X-Spam-Status: No, score=-1.904 tagged_above=-999 required=5 tests=[AWL=-0.255, BAYES_00=-2.599, HELO_EQ_DE=0.35, J_CHICKENPOX_14=0.6]
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 EzuCmYEGNLam for <json@ietfa.amsl.com>; Fri, 7 Jun 2013 07:28:38 -0700 (PDT)
Received: from mout.web.de (mout.web.de [212.227.17.12]) by ietfa.amsl.com (Postfix) with ESMTP id 5D8DA21F9619 for <json@ietf.org>; Fri, 7 Jun 2013 07:28:33 -0700 (PDT)
Received: from newyork.local.box ([93.129.186.5]) by smtp.web.de (mrweb003) with ESMTPSA (Nemesis) id 0MJkvs-1Um3a30gM8-001dDK; Fri, 07 Jun 2013 16:28:20 +0200
Message-ID: <51B1EE02.4090804@drees.name>
Date: Fri, 07 Jun 2013 16:28:18 +0200
From: Stefan Drees <stefan@drees.name>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130509 Thunderbird/17.0.6
MIME-Version: 1.0
To: "Matt Miller (mamille2)" <mamille2@cisco.com>
References: <255B9BB34FB7D647A506DC292726F6E1151B21F79E@WSMSG3153V.srv.dir.telstra.com> <A723FC6ECC552A4D8C8249D9E07425A70FC326C8@xmb-rcd-x10.cisco.com> <255B9BB34FB7D647A506DC292726F6E1151B21F8CA@WSMSG3153V.srv.dir.telstra.com> <51B17E54.9030107@drees.name> <BF7E36B9C495A6468E8EC573603ED9411527F781@xmb-aln-x11.cisco.com>
In-Reply-To: <BF7E36B9C495A6468E8EC573603ED9411527F781@xmb-aln-x11.cisco.com>
Content-Type: text/plain; charset="ISO-8859-1"; format="flowed"
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:ClAmMER5UjD0v+nnARIaRbFSKdWnn1n47wi47H4nVy8 YBg+gRKjSxtvqT6PVePQPQ6fuO0ovAu7zMmaf2aHlA0dmcYl0G hFDpbSpNBn6r6t72DLR+M5LzVHPH/803sFtUlk4peWF/T0a+Ba awokLavRY9wHdv2Yi1ce3fd80qTXlTIg8BHkYbvzhm0HS4KSzW yMoOMtALhI9RYPV5vp83A==
Cc: Carsten Bormann <cabo@tzi.org>, "Manger, James H" <James.H.Manger@team.telstra.com>, "Joe Hildebrand (jhildebr)" <jhildebr@cisco.com>, "json@ietf.org" <json@ietf.org>
Subject: Re: [Json] ABNF nits
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.12
Precedence: list
Reply-To: stefan@drees.name
List-Id: "JavaScript Object Notation \(JSON\) WG mailing list" <json.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/json>, <mailto:json-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/json>
List-Post: <mailto:json@ietf.org>
List-Help: <mailto:json-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/json>, <mailto:json-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 07 Jun 2013 14:28:46 -0000

On 07.06.13 16:10, Matt Miller (mamille2) wrote:
> Would one of you be so kind as to put all of this into a proposal we can
> all get our heads wrapped around?

I will try for an estimated consensual definition of all and this ;-)

Proposal:

Replace the closing ABNF rules inside section 2.4. Numbers

OLD:
"""
       number = [ minus ] int [ frac ] [ exp ]

       decimal-point = %x2E       ; .

       digit1-9 = %x31-39         ; 1-9

       e = %x65 / %x45            ; e E

       exp = e [ minus / plus ] 1*DIGIT

       frac = decimal-point 1*DIGIT

       int = zero / ( digit1-9 *DIGIT )

       minus = %x2D               ; -

       plus = %x2B                ; +

       zero = %x30                ; 0
"""

with

NEW:
"""
       number = [ minus ] int [ frac ] [ exp ]

       decimal-point = %x2E       ; .

       digit1-9 = %x31-39         ; 1-9

       e = %x65 / %x45            ; e E

       exp = e [ minus / plus ] 1*DIGIT

       frac = decimal-point 1*DIGIT

       int = zero / ( digit1-9 *DIGIT )

       DIGIT = %x30-39            ; 0-9
             ; DIGIT equivalent to DIGIT rule in [RFC5234]

       minus = %x2D               ; -

       plus = %x2B                ; +

       zero = %x30                ; 0

"""

and in section 2.5 Strings (as there is a 4HEXDIG, and no HEXDIG 
declared) also the ABNF rules section replace:

OLD:
"""
       string = quotation-mark *char quotation-mark

       char = unescaped /
           escape (
               %x22 /          ; "    quotation mark  U+0022
               %x5C /          ; \    reverse solidus U+005C
               %x2F /          ; /    solidus         U+002F
               %x62 /          ; b    backspace       U+0008
               %x66 /          ; f    form feed       U+000C
               %x6E /          ; n    line feed       U+000A
               %x72 /          ; r    carriage return U+000D
               %x74 /          ; t    tab             U+0009
               %x75 4HEXDIG )  ; uXXXX                U+XXXX

       escape = %x5C              ; \

       quotation-mark = %x22      ; "

       unescaped = %x20-21 / %x23-5B / %x5D-10FFFF

"""

with:
NEW:
"""
       string = quotation-mark *char quotation-mark

       char = unescaped /
           escape (
               %x22 /          ; "    quotation mark  U+0022
               %x5C /          ; \    reverse solidus U+005C
               %x2F /          ; /    solidus         U+002F
               %x62 /          ; b    backspace       U+0008
               %x66 /          ; f    form feed       U+000C
               %x6E /          ; n    line feed       U+000A
               %x72 /          ; r    carriage return U+000D
               %x74 /          ; t    tab             U+0009
               %x75 4HEXDIG )  ; uXXXX                U+XXXX

       escape = %x5C              ; \

       quotation-mark = %x22      ; "

       unescaped = %x20-21 / %x23-5B / %x5D-10FFFF

       HEXDIG = DIGIT / %x41-46 / %x61-66   ; 0-9, A-F, or a-f
              ; HEXDIG equivalent to HEXDIG rule in [RFC5234]

"""

Did it catch everything? Or do we want to explain, that 4HEXDIG means 
exactly 4 hex digits? I guess no, as the comment is depicting this nice 
and it is common ABNF practice to deal with multiplicity.

All the best and second to top posting as this is a summarizing job ;-)
Stefan

>
>
> kthxbye,
>
> - m&m
>
> Matt Miller < mamille2@cisco.com >
> Cisco Systems, Inc.
>
> On Jun 7, 2013, at 12:31 AM, Stefan Drees <stefan@drees.name> wrote:
>
>> On 2013-06-07 05:15, James H. Manger wrote:
>>>>>> Some things I found futzing with the ABNF:
>>>>>>
>>>>>> - normalize the indentation (makes it easier to pull out)
>>>>>> - Hex literals need to be uppercase.  The false and null rules are
>>>>>> wrong.
>>>>>
>>>>> Lowercase is allowed in hex literals.
>>>>> It links back to HEXDIG in RFC5234 (or RFC 4234).
>>>>> You have to remember the sneaky ABNF rule that quoted strings (eg "A")
>>>>> are case insensitive. "A" is equivalent to %x41 / %x61.
>>>>
>>>> Crap.  I didn't see that because it's in a "Note:" in section 2.3.
>>>
>>> I didn't call it "sneaky" for nothing ;) ...
>>
>> lucky JSON, it only needs short tokens (cowardly avoiding the word single character here ;-)
>>
>> If defining a grammar with real case-sensitive "word"-ish tokens in it, ABNF is IMO barely usable, unless you extend it with say single quotes as case-sensitve string delimiters. But then dealing with two kinds of strings also has it's catches =(
>>
>>
>>>> Regardless, we should change  both of those rules for consistency with
>>>> the rest of the doc.
>>>>
>>>>>> - DIGIT and HEXDIG are neither defined nor imported, as far as I can
>>>>>> tell.
>>>>>> I suggest:
>>>>>>
>>>>>> DIGIT = %x30-39                        ; 0-9
>>>>>> HEXDIG = %x30-39 / %x41-46 / %x61-66   ; 0-9, A-F, or a-f
>>>>
>>>> I still recommend being explicit about this, like the rule for e.
>>>
>>> I agree.
>>> Add DIGIT and HEXDIG to the doc so all the ABNF is present.
>>> Use your definition of HEXDIG above, not the RFC5234 one, to avoid the sneaky ABNF rule.
>>> Optionally add a note "; DIGIT and HEXDIG are equivalent to rules with the same names in [RFC5234]".
>>
>> +1 on your proposal James (including the ABNF comment).
>>
>> Stefan.
>>
>> _______________________________________________
>> json mailing list
>> json@ietf.org
>> https://www.ietf.org/mailman/listinfo/json
>