Re: [netmod] 'predicate' production

Ladislav Lhotka <lhotka@nic.cz> Thu, 25 February 2016 14:01 UTC

Return-Path: <lhotka@nic.cz>
X-Original-To: netmod@ietfa.amsl.com
Delivered-To: netmod@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 233CF1ACD59 for <netmod@ietfa.amsl.com>; Thu, 25 Feb 2016 06:01:09 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -5.357
X-Spam-Level:
X-Spam-Status: No, score=-5.357 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HELO_EQ_CZ=0.445, HOST_EQ_CZ=0.904, MIME_8BIT_HEADER=0.3, RCVD_IN_DNSWL_HI=-5, RP_MATCHES_RCVD=-0.006] autolearn=ham
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 FQKU21neO64b for <netmod@ietfa.amsl.com>; Thu, 25 Feb 2016 06:01:04 -0800 (PST)
Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 543161ACD4D for <netmod@ietf.org>; Thu, 25 Feb 2016 06:01:04 -0800 (PST)
Received: from birdie.labs.nic.cz (unknown [195.113.220.110]) by mail.nic.cz (Postfix) with ESMTPSA id F0E04181A66; Thu, 25 Feb 2016 15:01:02 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1456408863; bh=cbZTrtHo1oXr/EjnUZDWIRZgnFv3DZR5gOBBn1iJdKY=; h=From:Date:To; b=xLWmluTvGiQ2auMJ/lpnwtFvqIOdbDsHoM/auCfDd6PKkX0nwdsYGl/FvNu1QCYtT /dkokOeDFt+6+aNtTUPnK0AgoUCdTx3l+MrD0lK91gdeqp9IopMT6qP+bKsJC8LWPS nkfTBRpk41pjC97CZfeIcT0GciSsCMVt7zJdCw6w=
Content-Type: text/plain; charset="us-ascii"
Mime-Version: 1.0 (Mac OS X Mail 9.2 \(3112\))
From: Ladislav Lhotka <lhotka@nic.cz>
In-Reply-To: <20160225.145102.1511894162925887050.mbj@tail-f.com>
Date: Thu, 25 Feb 2016 15:01:14 +0100
Content-Transfer-Encoding: quoted-printable
Message-Id: <489B46F2-CF54-4696-A4C9-BDE7295569D6@nic.cz>
References: <m2povlayve.fsf@birdie.labs.nic.cz> <20160225.141636.866530241120731674.mbj@tail-f.com> <8DCD8E77-F906-49F6-A776-31FF2B623D8F@nic.cz> <20160225.145102.1511894162925887050.mbj@tail-f.com>
To: Martin Björklund <mbj@tail-f.com>
X-Mailer: Apple Mail (2.3112)
X-Virus-Scanned: clamav-milter 0.98.7 at mail
X-Virus-Status: Clean
Archived-At: <http://mailarchive.ietf.org/arch/msg/netmod/IRHj3B1iOwk0XGpHYQTK-9M4ECI>
Cc: netmod@ietf.org
Subject: Re: [netmod] 'predicate' production
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: NETMOD WG list <netmod.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/netmod>, <mailto:netmod-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/netmod/>
List-Post: <mailto:netmod@ietf.org>
List-Help: <mailto:netmod-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/netmod>, <mailto:netmod-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 25 Feb 2016 14:01:09 -0000

> On 25 Feb 2016, at 14:51, Martin Bjorklund <mbj@tail-f.com> wrote:
> 
> Ladislav Lhotka <lhotka@nic.cz> wrote:
>> 
>>> On 25 Feb 2016, at 14:16, Martin Bjorklund <mbj@tail-f.com> wrote:
>>> 
>>> Ladislav Lhotka <lhotka@nic.cz> wrote:
>>>> Martin Bjorklund <mbj@tail-f.com> writes:
>>>> 
>>>>> Ladislav Lhotka <lhotka@nic.cz> wrote:
>>>>>> Hi,
>>>>>> 
>>>>>> another ABNF issue:
>>>>>> 
>>>>>>  predicate           = "[" *WSP (predicate-expr / pos) *WSP "]"
>>>>>> 
>>>>>>  predicate-expr      = (node-identifier / ".") *WSP "=" *WSP
>>>>>>                        ((DQUOTE string DQUOTE) /
>>>>>>                         (SQUOTE string SQUOTE))
>>>>>> 
>>>>>>  pos                 = non-negative-integer-value
>>>>>> 
>>>>>>  non-negative-integer-value = "0" / positive-integer-value
>>>>>> 
>>>>>> The value of 0 shouldn't be allowed for 'pos' because context position
>>>>>> in XPath is always positive, i.e. the first list entry is selected
>>>>>> with "[1]".
>>>>> 
>>>>> You are right - I have changed this to:
>>>>> 
>>>>>  pos = positive-integer-value
>>>> 
>>>> Actually, there is another problem: the ABNF allows, for example
>>>> 
>>>> /if:interfaces/if:interface[1][2]
>>>> 
>>>> which doesn't make sense.
>>> 
>>> Yes, you're right.
>>> 
>>>> So a correct version could be
>>>> 
>>>>  instance-identifier = 1*("/" (node-identifier (*predicate / pos))
>>> 
>>> this would make pos mandatory after every node-identifier.  It should
>>> be: 
>>> 
>>> instance-identifier = 1*("/" (node-identifier (*predicate / *1pos)))
>>> 
>>> or, in order to match the style in the rest of the grammar:
>>> 
>>> instance-identifier = 1*("/" (node-identifier [1*predicate / pos]))
>> 
>> If we want to be really precise, then the predicate for a leaf-list [
>> . = 'foo'] can also appear no more than once.
> 
> Correct.  But we can only do so much in the grammar... For example, we
> cannot verify that the name and number of keys are correct.

Yes, but these are already semantic constraints. I think the new productions below are in fact easier to comprehend. Perhaps a production like

quoted-string = (DQUOTE string DQUOTE) / (SQUOTE string SQUOTE)

would also be an improvement.

Lada

> 
> It would be:
> 
> instance-identifier = 1*("/" (node-identifier [1*key-predicate /
>                                               leaf-list-predicate /
>                                               pos]))
> 
> key-predicate       = "[" *WSP key-predicate-expr *WSP "]"
> 
> key-predicate-expr  = node-identifier *WSP "=" *WSP
>                      ((DQUOTE string DQUOTE) /
>                       (SQUOTE string SQUOTE))
> 
> leaf-list-predicate = "[" *WSP leaf-list-predicate-expr *WSP "]"
> 
> leaf-list-predicate-expr = "." *WSP "=" *WSP
>                      ((DQUOTE string DQUOTE) /
>                       (SQUOTE string SQUOTE))
> 
> pos                 = "[" *WSP positive-integer-value *WSP "]"
> 
> 
> 
> /martin

--
Ladislav Lhotka, CZ.NIC Labs
PGP Key ID: E74E8C0C