Subject: [netmod] YANG ABNF bug

From: Andy Bierman <[email-masked]>
Date: Mon, 7 Mar 2011 16:14:02 -0800

Hi,

I found a bug in RFC 6020 ABNF...

RFC 6020, sec. 9.12, para 3:

   A member type can be of any built-in or derived type, except it MUST
   NOT be one of the built-in types "empty" or "leafref".

Sec 12, ABNF Grammar , page 149:

   union-specification = 1*(type-stmt stmtsep)

This ABNF allows all types, which is wrong:

    type-stmt           = type-keyword sep identifier-ref-arg-str optsep

                         (";" /

                          "{" stmtsep

                              type-body-stmts

                          "}")

   type-body-stmts     = numerical-restrictions /

                         decimal64-specification /

                         string-restrictions /

                         enum-specification /

                         leafref-specification /

                         identityref-specification /

                         instance-identifier-specification /

                         bits-specification /

                         union-specification

I do not know how to express "builtin-type of identifier-ref-arg-str
must resolve to a string other than 'leafref' or 'empty' and the
leafref-specification is not allowed  if the type-stmt is declared within a union type-stmt.

Andy

---

From: Martin Bjorklund <[email-masked]>
Date: Tue, 08 Mar 2011 08:19:44 +0100 (CET)

Hi,

> I found a bug in RFC 6020 ABNF...

I don't agree that this a bug.  There are many constructs that the
ABNF allows that are not valid YANG.  If a module passes the grammar
check it is syntactically correct.  This does not mean it is valid
YANG.

/martin

---

From: Ladislav Lhotka <[email-masked]>
Date: Tue, 08 Mar 2011 09:43:29 +0100

> check it is syntactically correct.  This does not mean it is valid

This case could be corrected simply by defining the union type without
using the generic productions, right? I would be in favor of making this
change in 6020bis.

Lada  

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

-- 
Ladislav Lhotka, CESNET
PGP Key ID: E74E8C0C

---

From: Martin Bjorklund <[email-masked]>
Date: Tue, 08 Mar 2011 10:01:38 +0100 (CET)

Ladislav Lhotka <[email-masked]> wrote:
> using the generic productions, right?

I don't think it is that easy.  Here's an example of a valid snippet:

  type union {
    type 'int' + "32";
    type 'str' + /* foo */ 'ing';
  }

and an invalid:

  type union {
    type int32 {
      length "10";
    }
    type 'emp' + "ty";
  }

/martin

---

From: Ladislav Lhotka <[email-masked]>
Date: Tue, 08 Mar 2011 18:23:12 +0100

>     type 'str' + /* foo */ 'ing';

This is only a matter of interpretation of identifier-ref-arg-str, but I
think the problem has to do with derived types: I first thought that
"union-specification" could be changed like this:

union-specification = 1*(type-stmt-union stmtsep)

and then have the "type-stmt-union" production without "empty" and
"leafref" types.

But I guess the problem is more with the following example which cannot
be easily excluded in the grammar:

    type union {
      type foo;
      ...
    }

    typedef foo {
      type empty;
    }

This should be also forbidden, although the sentence that Andy cited
doesn't seem to exclude this case because the member type is neither
"empty" nor "leafref". So the text should probably be changed:

OLD

NEW  

   A member type can be of any built-in or derived type, except it MUST 
   NOT be one of the built-in types "empty" or "leafref", or any type 
   (transitively) derived from these two built-in types.

Lada

-- 
Ladislav Lhotka, CESNET
PGP Key ID: E74E8C0C