Subject: [netmod] another XPath tip

From: Andy Bierman <[email-masked]>
Date: Thu, 18 Dec 2008 17:30:09 -0800

Hi,

I just found another difference between YANG and XPath
syntax by studying the EBNF.

XPath expressions do not have negative numbers,
only the unary operator '-' (see rule [30]).

For example:

    child::para[position()=last()-1]

Make sure you don't parse a '-1' instead of the correct '-' '1'.

Andy

_______________________________________________
netmod mailing list
[email-masked]
https://www.ietf.org/mailman/listinfo/netmod

---

From: Phil Shafer <[email-masked]>
Date: Fri, 19 Dec 2008 09:51:11 -0500

>only the unary operator '-' (see rule [30]).

Viewed the other way, XPath expressions have negative numbers
built by using the unary operator and a set of digits.

>Make sure you don't parse a '-1' instead of the correct '-' '1'.

Normal grammar rules should handle this.  The unary "-" is not a
valid token after an Expr, so the "-" in "-1" should trigger rule
25 instead.

The "gotcha" is probably that "-" is not a token if the next character
is a path-element.  So some look-ahead is required.  Consider the
difference between "last()-position()", "last-position()",
"last()-position", and "last-position".  Worse, consider "last()-1"
and "last-1".  Lots of fun.

Thanks,
 Phil

---

From: Andy Bierman <[email-masked]>
Date: Fri, 19 Dec 2008 07:48:09 -0800

> built by using the unary operator and a set of digits.

Why doesn't YANG do it this way? Does it matter?

> and "last-1".  Lots of fun.

sometimes 2-token lookahead is required. very fun.
(follow the EBNF and the precedence falls out for free)

Andy