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
}
}
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.