Uploaded image for project: 'yangtools'
  1. yangtools
  2. YANGTOOLS-544

YangSyntaxErrorException depending of the restictions/extensions order for the String type

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Resolution: Done
    • None
    • None
    • None
    • None
    • Operating System: Linux
      Platform: PC

    • 4623

    Description

      module extension-def {
      namespace "urn:simple.extension.typedefs";
      prefix "ext";

      extension unknown

      { argument "ext-arg"; description "Extension with single argument definition."; }

      }

      module types {
      namespace "urn:custom.types.demo";
      prefix "types";

      import extension-def

      { prefix "ext"; }

      leaf leaf-length-unknown-pattern {
      type string

      { length "2..10"; ext:unknown "unknown"; pattern "[0-9a-fA-F]"; }

      }
      }

      The given example results in "YangSyntaxErrorException: mismatched input 'pattern' expecting

      {'}

      '" because of the type string restriction order.

      type string {
      length "2..10"; <--- String restriction
      ext:unknown "unknown"; <--- extension
      pattern "[0-9a-fA-F]"; <--- String restriction
      }

      According to the YangParser.g4

      type body for string type:
      type_body_stmts: (identifier_stmt)* (string_restriction) (identifier_stmt)*;
      string_restrictions : (length_stmt |pattern_stmt)*;

      Recomended solution:

      string_restrictions : (length_stmt | identifier_stmt | pattern_stmt)*;

      It will allow any order of restrictions and extensions.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            icaro.damiani@datacom.ind.br Ícaro Franco Damiani
            icaro.damiani@datacom.ind.br Ícaro Franco Damiani
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: