github.com/openconfig/goyang@v1.4.5/pkg/yang/yang.go (about)

     1  // Copyright 2015 Google Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package yang
    16  
    17  import "fmt"
    18  
    19  // This file contains the definitions for all nodes of the yang AST.
    20  // The actual building of the AST is in ast.go
    21  
    22  // Some field names have specific meanings:
    23  //
    24  //  Grouping - This field must always be of type []*Grouping
    25  //  Typedef - This field must always be of type []*Typedef
    26  
    27  // A Value is just a string that can have extensions.
    28  type Value struct {
    29  	Name       string       `yang:"Name,nomerge"`
    30  	Source     *Statement   `yang:"Statement,nomerge" json:",omitempty"`
    31  	Parent     Node         `yang:"Parent,nomerge" json:"-"`
    32  	Extensions []*Statement `yang:"Ext" json:",omitempty"`
    33  
    34  	Description *Value `yang:"description" json:",omitempty"`
    35  }
    36  
    37  func (Value) Kind() string             { return "string" }
    38  func (s *Value) ParentNode() Node      { return s.Parent }
    39  func (s *Value) NName() string         { return s.Name }
    40  func (s *Value) Statement() *Statement { return s.Source }
    41  func (s *Value) Exts() []*Statement    { return s.Extensions }
    42  
    43  // asRangeInt returns the value v as an int64 if it is between the values of
    44  // min and max inclusive.  An error is returned if v is out of range or does
    45  // not parse into a number.  If v is nil then an error is returned.
    46  func (s *Value) asRangeInt(min, max int64) (int64, error) {
    47  	if s == nil {
    48  		return 0, fmt.Errorf("value is required in the range of [%d..%d]", min, max)
    49  	}
    50  	n, err := ParseInt(s.Name)
    51  	if err != nil {
    52  		return 0, err
    53  	}
    54  	i, err := n.Int()
    55  	if err != nil {
    56  		return 0, err
    57  	}
    58  	if i < min || i > max {
    59  		return 0, fmt.Errorf("value %s out of range [%d..%d]", s.Name, min, max)
    60  	}
    61  	return i, nil
    62  }
    63  
    64  // asBool returns v as a boolean (true or flase) or returns an error if v
    65  // is neither true nor false.  If v is nil then false is returned.
    66  func (s *Value) asBool() (bool, error) {
    67  	// A missing value is considered false
    68  	if s == nil {
    69  		return false, nil
    70  	}
    71  	switch s.Name {
    72  	case "true":
    73  		return true, nil
    74  	case "false":
    75  		return false, nil
    76  	default:
    77  		return false, fmt.Errorf("invalid boolean: %s", s.Name)
    78  	}
    79  }
    80  
    81  // asString simply returns the string value of v.  If v is nil then an empty
    82  // string is returned.
    83  func (s *Value) asString() string {
    84  	if s == nil {
    85  		return ""
    86  	}
    87  	return s.Name
    88  }
    89  
    90  // See http://tools.ietf.org/html/rfc6020#section-7 for a description of the
    91  // following structures.  The structures are derived from that document.
    92  
    93  // A Module is defined in: http://tools.ietf.org/html/rfc6020#section-7.1
    94  //
    95  // A SubModule is defined in: http://tools.ietf.org/html/rfc6020#section-7.2
    96  type Module struct {
    97  	Name       string       `yang:"Name,nomerge"`
    98  	Source     *Statement   `yang:"Statement,nomerge" json:"-"`
    99  	Parent     Node         `yang:"Parent,nomerge" json:"-"`
   100  	Extensions []*Statement `yang:"Ext"`
   101  
   102  	Anydata      []*AnyData      `yang:"anydata"`
   103  	Anyxml       []*AnyXML       `yang:"anyxml"`
   104  	Augment      []*Augment      `yang:"augment"`
   105  	BelongsTo    *BelongsTo      `yang:"belongs-to,required=submodule,nomerge"`
   106  	Choice       []*Choice       `yang:"choice"`
   107  	Contact      *Value          `yang:"contact,nomerge"`
   108  	Container    []*Container    `yang:"container"`
   109  	Description  *Value          `yang:"description,nomerge"`
   110  	Deviation    []*Deviation    `yang:"deviation"`
   111  	Extension    []*Extension    `yang:"extension"`
   112  	Feature      []*Feature      `yang:"feature"`
   113  	Grouping     []*Grouping     `yang:"grouping"`
   114  	Identity     []*Identity     `yang:"identity"`
   115  	Import       []*Import       `yang:"import"`
   116  	Include      []*Include      `yang:"include"`
   117  	Leaf         []*Leaf         `yang:"leaf"`
   118  	LeafList     []*LeafList     `yang:"leaf-list"`
   119  	List         []*List         `yang:"list"`
   120  	Namespace    *Value          `yang:"namespace,required=module,nomerge"`
   121  	Notification []*Notification `yang:"notification"`
   122  	Organization *Value          `yang:"organization,nomerge"`
   123  	Prefix       *Value          `yang:"prefix,required=module,nomerge"`
   124  	Reference    *Value          `yang:"reference,nomerge"`
   125  	Revision     []*Revision     `yang:"revision,nomerge"`
   126  	RPC          []*RPC          `yang:"rpc"`
   127  	Typedef      []*Typedef      `yang:"typedef"`
   128  	Uses         []*Uses         `yang:"uses"`
   129  	YangVersion  *Value          `yang:"yang-version,nomerge"`
   130  
   131  	// Modules references the Modules object from which this Module node
   132  	// was parsed.
   133  	Modules *Modules
   134  }
   135  
   136  func (s *Module) Kind() string {
   137  	if s.BelongsTo != nil {
   138  		return "submodule"
   139  	}
   140  	return "module"
   141  }
   142  func (s *Module) ParentNode() Node        { return s.Parent }
   143  func (s *Module) NName() string           { return s.Name }
   144  func (s *Module) Statement() *Statement   { return s.Source }
   145  func (s *Module) Exts() []*Statement      { return s.Extensions }
   146  func (s *Module) Groupings() []*Grouping  { return s.Grouping }
   147  func (s *Module) Typedefs() []*Typedef    { return s.Typedef }
   148  func (s *Module) Identities() []*Identity { return s.Identity }
   149  
   150  // Current returns the most recent revision of this module, or "" if the module
   151  // has no revisions.
   152  func (s *Module) Current() string {
   153  	var rev string
   154  	for _, r := range s.Revision {
   155  		if r.Name > rev {
   156  			rev = r.Name
   157  		}
   158  	}
   159  	return rev
   160  }
   161  
   162  // FullName returns the full name of the module including the most recent
   163  // revision, if any.
   164  func (s *Module) FullName() string {
   165  	if rev := s.Current(); rev != "" {
   166  		return s.Name + "@" + rev
   167  	}
   168  	return s.Name
   169  }
   170  
   171  // GetPrefix returns the proper prefix of m.  Useful when looking up types
   172  // in modules found by FindModuleByPrefix.
   173  func (s *Module) GetPrefix() string {
   174  	pfx := s.getPrefix()
   175  	if pfx == nil {
   176  		// This case can be true during testing.
   177  		return ""
   178  	}
   179  	return pfx.Name
   180  }
   181  
   182  // getPrefix returns the local prefix of the module used to refer to itself.
   183  func (s *Module) getPrefix() *Value {
   184  	switch {
   185  	case s == nil:
   186  		return nil
   187  	case s.Kind() == "module" && s.Prefix != nil:
   188  		return s.Prefix
   189  	case s.Kind() == "submodule" && s.BelongsTo != nil:
   190  		return s.BelongsTo.Prefix
   191  	default:
   192  		return nil
   193  	}
   194  }
   195  
   196  // An Import is defined in: http://tools.ietf.org/html/rfc6020#section-7.1.5
   197  type Import struct {
   198  	Name       string       `yang:"Name,nomerge"`
   199  	Source     *Statement   `yang:"Statement,nomerge" json:"-"`
   200  	Parent     Node         `yang:"Parent,nomerge" json:"-"`
   201  	Extensions []*Statement `yang:"Ext"`
   202  
   203  	Prefix       *Value `yang:"prefix,required"`
   204  	RevisionDate *Value `yang:"revision-date"`
   205  	Reference    *Value `yang:"reference,nomerge"`
   206  	Description  *Value `yang:"description,nomerge"`
   207  
   208  	// Module is the imported module.  The types and groupings are
   209  	// available to the importer with the defined prefix.
   210  	Module *Module
   211  }
   212  
   213  func (Import) Kind() string             { return "import" }
   214  func (s *Import) ParentNode() Node      { return s.Parent }
   215  func (s *Import) NName() string         { return s.Name }
   216  func (s *Import) Statement() *Statement { return s.Source }
   217  func (s *Import) Exts() []*Statement    { return s.Extensions }
   218  
   219  // An Include is defined in: http://tools.ietf.org/html/rfc6020#section-7.1.6
   220  type Include struct {
   221  	Name       string       `yang:"Name,nomerge"`
   222  	Source     *Statement   `yang:"Statement,nomerge" json:"-"`
   223  	Parent     Node         `yang:"Parent,nomerge" json:"-"`
   224  	Extensions []*Statement `yang:"Ext" json:",omitempty"`
   225  
   226  	RevisionDate *Value `yang:"revision-date"`
   227  
   228  	// Module is the included module.  The types and groupings are
   229  	// available to the importer with the defined prefix.
   230  	Module *Module
   231  }
   232  
   233  func (Include) Kind() string             { return "include" }
   234  func (s *Include) ParentNode() Node      { return s.Parent }
   235  func (s *Include) NName() string         { return s.Name }
   236  func (s *Include) Statement() *Statement { return s.Source }
   237  func (s *Include) Exts() []*Statement    { return s.Extensions }
   238  
   239  // A Revision is defined in: http://tools.ietf.org/html/rfc6020#section-7.1.9
   240  type Revision struct {
   241  	Name       string       `yang:"Name,nomerge"`
   242  	Source     *Statement   `yang:"Statement,nomerge" json:"-"`
   243  	Parent     Node         `yang:"Parent,nomerge" json:"-"`
   244  	Extensions []*Statement `yang:"Ext" json:",omitempty"`
   245  
   246  	Description *Value `yang:"description"`
   247  	Reference   *Value `yang:"reference"`
   248  }
   249  
   250  func (Revision) Kind() string             { return "revision" }
   251  func (s *Revision) ParentNode() Node      { return s.Parent }
   252  func (s *Revision) NName() string         { return s.Name }
   253  func (s *Revision) Statement() *Statement { return s.Source }
   254  func (s *Revision) Exts() []*Statement    { return s.Extensions }
   255  
   256  // A BelongsTo is defined in: http://tools.ietf.org/html/rfc6020#section-7.2.2
   257  type BelongsTo struct {
   258  	Name       string       `yang:"Name,nomerge"`
   259  	Source     *Statement   `yang:"Statement,nomerge" json:"-"`
   260  	Parent     Node         `yang:"Parent,nomerge" json:"-"`
   261  	Extensions []*Statement `yang:"Ext" json:",omitempty"`
   262  
   263  	Prefix *Value `yang:"prefix,required"`
   264  }
   265  
   266  func (BelongsTo) Kind() string             { return "belongs-to" }
   267  func (s *BelongsTo) ParentNode() Node      { return s.Parent }
   268  func (s *BelongsTo) NName() string         { return s.Name }
   269  func (s *BelongsTo) Statement() *Statement { return s.Source }
   270  func (s *BelongsTo) Exts() []*Statement    { return s.Extensions }
   271  
   272  // A Typedef is defined in: http://tools.ietf.org/html/rfc6020#section-7.3
   273  type Typedef struct {
   274  	Name       string       `yang:"Name,nomerge"`
   275  	Source     *Statement   `yang:"Statement,nomerge"`
   276  	Parent     Node         `yang:"Parent,nomerge"`
   277  	Extensions []*Statement `yang:"Ext"`
   278  
   279  	Default     *Value `yang:"default"`
   280  	Description *Value `yang:"description"`
   281  	Reference   *Value `yang:"reference"`
   282  	Status      *Value `yang:"status"`
   283  	Type        *Type  `yang:"type,required"`
   284  	Units       *Value `yang:"units"`
   285  
   286  	YangType *YangType `json:"-"`
   287  }
   288  
   289  func (Typedef) Kind() string             { return "typedef" }
   290  func (s *Typedef) ParentNode() Node      { return s.Parent }
   291  func (s *Typedef) NName() string         { return s.Name }
   292  func (s *Typedef) Statement() *Statement { return s.Source }
   293  func (s *Typedef) Exts() []*Statement    { return s.Extensions }
   294  
   295  // A Type is defined in: http://tools.ietf.org/html/rfc6020#section-7.4
   296  // Note that Name is the name of the type we want, it is what must
   297  // be looked up and resolved.
   298  type Type struct {
   299  	Name       string       `yang:"Name,nomerge"`
   300  	Source     *Statement   `yang:"Statement,nomerge"`
   301  	Parent     Node         `yang:"Parent,nomerge"`
   302  	Extensions []*Statement `yang:"Ext"`
   303  
   304  	IdentityBase    *Value     `yang:"base"` // Name == identityref
   305  	Bit             []*Bit     `yang:"bit"`
   306  	Enum            []*Enum    `yang:"enum"`
   307  	FractionDigits  *Value     `yang:"fraction-digits"` // Name == decimal64
   308  	Length          *Length    `yang:"length"`
   309  	Path            *Value     `yang:"path"`
   310  	Pattern         []*Pattern `yang:"pattern"`
   311  	Range           *Range     `yang:"range"`
   312  	RequireInstance *Value     `yang:"require-instance"`
   313  	Type            []*Type    `yang:"type"` // len > 1 only when Name is "union"
   314  
   315  	YangType *YangType
   316  }
   317  
   318  func (Type) Kind() string             { return "type" }
   319  func (s *Type) ParentNode() Node      { return s.Parent }
   320  func (s *Type) NName() string         { return s.Name }
   321  func (s *Type) Statement() *Statement { return s.Source }
   322  func (s *Type) Exts() []*Statement    { return s.Extensions }
   323  
   324  // A Container is defined in: http://tools.ietf.org/html/rfc6020#section-7.5
   325  // and http://tools.ietf.org/html/rfc7950#section-7.5 ("container" sub-statement)
   326  type Container struct {
   327  	Name       string       `yang:"Name,nomerge"`
   328  	Source     *Statement   `yang:"Statement,nomerge"`
   329  	Parent     Node         `yang:"Parent,nomerge"`
   330  	Extensions []*Statement `yang:"Ext"`
   331  
   332  	Anydata      []*AnyData      `yang:"anydata"`
   333  	Action       []*Action       `yang:"action"`
   334  	Anyxml       []*AnyXML       `yang:"anyxml"`
   335  	Choice       []*Choice       `yang:"choice"`
   336  	Config       *Value          `yang:"config"`
   337  	Container    []*Container    `yang:"container"`
   338  	Description  *Value          `yang:"description"`
   339  	Grouping     []*Grouping     `yang:"grouping"`
   340  	IfFeature    []*Value        `yang:"if-feature"`
   341  	Leaf         []*Leaf         `yang:"leaf"`
   342  	LeafList     []*LeafList     `yang:"leaf-list"`
   343  	List         []*List         `yang:"list"`
   344  	Must         []*Must         `yang:"must"`
   345  	Notification []*Notification `yang:"notification"`
   346  	Presence     *Value          `yang:"presence"`
   347  	Reference    *Value          `yang:"reference"`
   348  	Status       *Value          `yang:"status"`
   349  	Typedef      []*Typedef      `yang:"typedef"`
   350  	Uses         []*Uses         `yang:"uses"`
   351  	When         *Value          `yang:"when"`
   352  }
   353  
   354  func (Container) Kind() string              { return "container" }
   355  func (s *Container) ParentNode() Node       { return s.Parent }
   356  func (s *Container) NName() string          { return s.Name }
   357  func (s *Container) Statement() *Statement  { return s.Source }
   358  func (s *Container) Exts() []*Statement     { return s.Extensions }
   359  func (s *Container) Groupings() []*Grouping { return s.Grouping }
   360  func (s *Container) Typedefs() []*Typedef   { return s.Typedef }
   361  
   362  // A Must is defined in: http://tools.ietf.org/html/rfc6020#section-7.5.3
   363  type Must struct {
   364  	Name       string       `yang:"Name,nomerge" json:",omitempty"`
   365  	Source     *Statement   `yang:"Statement,nomerge" json:"-"`
   366  	Parent     Node         `yang:"Parent,nomerge" json:"-"`
   367  	Extensions []*Statement `yang:"Ext" json:",omitempty"`
   368  
   369  	Description  *Value `yang:"description" json:",omitempty"`
   370  	ErrorAppTag  *Value `yang:"error-app-tag" json:",omitempty"`
   371  	ErrorMessage *Value `yang:"error-message" json:",omitempty"`
   372  	Reference    *Value `yang:"reference" json:",omitempty"`
   373  }
   374  
   375  func (Must) Kind() string             { return "must" }
   376  func (s *Must) ParentNode() Node      { return s.Parent }
   377  func (s *Must) NName() string         { return s.Name }
   378  func (s *Must) Statement() *Statement { return s.Source }
   379  func (s *Must) Exts() []*Statement    { return s.Extensions }
   380  
   381  // A Leaf is defined in: http://tools.ietf.org/html/rfc6020#section-7.6
   382  type Leaf struct {
   383  	Name       string       `yang:"Name,nomerge"`
   384  	Source     *Statement   `yang:"Statement,nomerge"`
   385  	Parent     Node         `yang:"Parent,nomerge"`
   386  	Extensions []*Statement `yang:"Ext"`
   387  
   388  	Config      *Value   `yang:"config"`
   389  	Default     *Value   `yang:"default"`
   390  	Description *Value   `yang:"description"`
   391  	IfFeature   []*Value `yang:"if-feature"`
   392  	Mandatory   *Value   `yang:"mandatory"`
   393  	Must        []*Must  `yang:"must"`
   394  	Reference   *Value   `yang:"reference"`
   395  	Status      *Value   `yang:"status"`
   396  	Type        *Type    `yang:"type,required"`
   397  	Units       *Value   `yang:"units"`
   398  	When        *Value   `yang:"when"`
   399  }
   400  
   401  func (Leaf) Kind() string             { return "leaf" }
   402  func (s *Leaf) ParentNode() Node      { return s.Parent }
   403  func (s *Leaf) NName() string         { return s.Name }
   404  func (s *Leaf) Statement() *Statement { return s.Source }
   405  func (s *Leaf) Exts() []*Statement    { return s.Extensions }
   406  
   407  // A LeafList is defined in:
   408  // YANG 1:   http://tools.ietf.org/html/rfc6020#section-7.7
   409  // YANG 1.1: https://tools.ietf.org/html/rfc7950#section-7.7
   410  // It this is supposed to be an array of nodes..
   411  type LeafList struct {
   412  	Name       string       `yang:"Name,nomerge"`
   413  	Source     *Statement   `yang:"Statement,nomerge"`
   414  	Parent     Node         `yang:"Parent,nomerge"`
   415  	Extensions []*Statement `yang:"Ext"`
   416  
   417  	Config      *Value   `yang:"config"`
   418  	Default     []*Value `yang:"default"`
   419  	Description *Value   `yang:"description"`
   420  	IfFeature   []*Value `yang:"if-feature"`
   421  	MaxElements *Value   `yang:"max-elements"`
   422  	MinElements *Value   `yang:"min-elements"`
   423  	Must        []*Must  `yang:"must"`
   424  	OrderedBy   *Value   `yang:"ordered-by"`
   425  	Reference   *Value   `yang:"reference"`
   426  	Status      *Value   `yang:"status"`
   427  	Type        *Type    `yang:"type,required"`
   428  	Units       *Value   `yang:"units"`
   429  	When        *Value   `yang:"when"`
   430  }
   431  
   432  func (LeafList) Kind() string             { return "leaf-list" }
   433  func (s *LeafList) ParentNode() Node      { return s.Parent }
   434  func (s *LeafList) NName() string         { return s.Name }
   435  func (s *LeafList) Statement() *Statement { return s.Source }
   436  func (s *LeafList) Exts() []*Statement    { return s.Extensions }
   437  
   438  // A List is defined in: http://tools.ietf.org/html/rfc6020#section-7.8
   439  // and http://tools.ietf.org/html/rfc7950#section-7.8 ("list" sub-statement)
   440  type List struct {
   441  	Name       string       `yang:"Name,nomerge"`
   442  	Source     *Statement   `yang:"Statement,nomerge"`
   443  	Parent     Node         `yang:"Parent,nomerge"`
   444  	Extensions []*Statement `yang:"Ext"`
   445  
   446  	Anydata      []*AnyData      `yang:"anydata"`
   447  	Action       []*Action       `yang:"action"`
   448  	Anyxml       []*AnyXML       `yang:"anyxml"`
   449  	Choice       []*Choice       `yang:"choice"`
   450  	Config       *Value          `yang:"config"`
   451  	Container    []*Container    `yang:"container"`
   452  	Description  *Value          `yang:"description"`
   453  	Grouping     []*Grouping     `yang:"grouping"`
   454  	IfFeature    []*Value        `yang:"if-feature"`
   455  	Key          *Value          `yang:"key"`
   456  	Leaf         []*Leaf         `yang:"leaf"`
   457  	LeafList     []*LeafList     `yang:"leaf-list"`
   458  	List         []*List         `yang:"list"`
   459  	MaxElements  *Value          `yang:"max-elements"`
   460  	MinElements  *Value          `yang:"min-elements"`
   461  	Must         []*Must         `yang:"must"`
   462  	Notification []*Notification `yang:"notification"`
   463  	OrderedBy    *Value          `yang:"ordered-by"`
   464  	Reference    *Value          `yang:"reference"`
   465  	Status       *Value          `yang:"status"`
   466  	Typedef      []*Typedef      `yang:"typedef"`
   467  	Unique       []*Value        `yang:"unique"`
   468  	Uses         []*Uses         `yang:"uses"`
   469  	When         *Value          `yang:"when"`
   470  }
   471  
   472  func (List) Kind() string              { return "list" }
   473  func (s *List) ParentNode() Node       { return s.Parent }
   474  func (s *List) NName() string          { return s.Name }
   475  func (s *List) Statement() *Statement  { return s.Source }
   476  func (s *List) Exts() []*Statement     { return s.Extensions }
   477  func (s *List) Groupings() []*Grouping { return s.Grouping }
   478  func (s *List) Typedefs() []*Typedef   { return s.Typedef }
   479  
   480  // A Choice is defined in: http://tools.ietf.org/html/rfc6020#section-7.9
   481  type Choice struct {
   482  	Name       string       `yang:"Name,nomerge"`
   483  	Source     *Statement   `yang:"Statement,nomerge"`
   484  	Parent     Node         `yang:"Parent,nomerge"`
   485  	Extensions []*Statement `yang:"Ext"`
   486  
   487  	Anydata     []*AnyData   `yang:"anydata"`
   488  	Anyxml      []*AnyXML    `yang:"anyxml"`
   489  	Case        []*Case      `yang:"case"`
   490  	Config      *Value       `yang:"config"`
   491  	Container   []*Container `yang:"container"`
   492  	Default     *Value       `yang:"default"`
   493  	Description *Value       `yang:"description"`
   494  	IfFeature   []*Value     `yang:"if-feature"`
   495  	Leaf        []*Leaf      `yang:"leaf"`
   496  	LeafList    []*LeafList  `yang:"leaf-list"`
   497  	List        []*List      `yang:"list"`
   498  	Mandatory   *Value       `yang:"mandatory"`
   499  	Reference   *Value       `yang:"reference"`
   500  	Status      *Value       `yang:"status"`
   501  	When        *Value       `yang:"when"`
   502  }
   503  
   504  func (Choice) Kind() string             { return "choice" }
   505  func (s *Choice) ParentNode() Node      { return s.Parent }
   506  func (s *Choice) NName() string         { return s.Name }
   507  func (s *Choice) Statement() *Statement { return s.Source }
   508  func (s *Choice) Exts() []*Statement    { return s.Extensions }
   509  
   510  // A Case is defined in: http://tools.ietf.org/html/rfc6020#section-7.9.2
   511  type Case struct {
   512  	Name       string       `yang:"Name,nomerge"`
   513  	Source     *Statement   `yang:"Statement,nomerge"`
   514  	Parent     Node         `yang:"Parent,nomerge"`
   515  	Extensions []*Statement `yang:"Ext"`
   516  
   517  	Anydata     []*AnyData   `yang:"anydata"`
   518  	Anyxml      []*AnyXML    `yang:"anyxml"`
   519  	Choice      []*Choice    `yang:"choice"`
   520  	Container   []*Container `yang:"container"`
   521  	Description *Value       `yang:"description"`
   522  	IfFeature   []*Value     `yang:"if-feature"`
   523  	Leaf        []*Leaf      `yang:"leaf"`
   524  	LeafList    []*LeafList  `yang:"leaf-list"`
   525  	List        []*List      `yang:"list"`
   526  	Reference   *Value       `yang:"reference"`
   527  	Status      *Value       `yang:"status"`
   528  	Uses        []*Uses      `yang:"uses"`
   529  	When        *Value       `yang:"when"`
   530  }
   531  
   532  func (Case) Kind() string             { return "case" }
   533  func (s *Case) ParentNode() Node      { return s.Parent }
   534  func (s *Case) NName() string         { return s.Name }
   535  func (s *Case) Statement() *Statement { return s.Source }
   536  func (s *Case) Exts() []*Statement    { return s.Extensions }
   537  
   538  // An AnyXML is defined in: http://tools.ietf.org/html/rfc6020#section-7.10
   539  type AnyXML struct {
   540  	Name       string       `yang:"Name,nomerge"`
   541  	Source     *Statement   `yang:"Statement,nomerge"`
   542  	Parent     Node         `yang:"Parent,nomerge"`
   543  	Extensions []*Statement `yang:"Ext"`
   544  
   545  	Config      *Value   `yang:"config"`
   546  	Description *Value   `yang:"description"`
   547  	IfFeature   []*Value `yang:"if-feature"`
   548  	Mandatory   *Value   `yang:"mandatory"`
   549  	Must        []*Must  `yang:"must"`
   550  	Reference   *Value   `yang:"reference"`
   551  	Status      *Value   `yang:"status"`
   552  	When        *Value   `yang:"when"`
   553  }
   554  
   555  func (AnyXML) Kind() string             { return "anyxml" }
   556  func (s *AnyXML) ParentNode() Node      { return s.Parent }
   557  func (s *AnyXML) NName() string         { return s.Name }
   558  func (s *AnyXML) Statement() *Statement { return s.Source }
   559  func (s *AnyXML) Exts() []*Statement    { return s.Extensions }
   560  
   561  // An AnyData is defined in: http://tools.ietf.org/html/rfc7950#section-7.10
   562  //
   563  // AnyData are only expected in YANG 1.1 modules (those with a
   564  // "yang-version 1.1;" statement in the module).
   565  type AnyData struct {
   566  	Name       string       `yang:"Name,nomerge"`
   567  	Source     *Statement   `yang:"Statement,nomerge"`
   568  	Parent     Node         `yang:"Parent,nomerge"`
   569  	Extensions []*Statement `yang:"Ext"`
   570  
   571  	Config      *Value   `yang:"config"`
   572  	Description *Value   `yang:"description"`
   573  	IfFeature   []*Value `yang:"if-feature"`
   574  	Mandatory   *Value   `yang:"mandatory"`
   575  	Must        []*Must  `yang:"must"`
   576  	Reference   *Value   `yang:"reference"`
   577  	Status      *Value   `yang:"status"`
   578  	When        *Value   `yang:"when"`
   579  }
   580  
   581  func (AnyData) Kind() string             { return "anydata" }
   582  func (s *AnyData) ParentNode() Node      { return s.Parent }
   583  func (s *AnyData) NName() string         { return s.Name }
   584  func (s *AnyData) Statement() *Statement { return s.Source }
   585  func (s *AnyData) Exts() []*Statement    { return s.Extensions }
   586  
   587  // A Grouping is defined in: http://tools.ietf.org/html/rfc6020#section-7.11
   588  // and http://tools.ietf.org/html/rfc7950#section-7.12 ("grouping" sub-statement)
   589  type Grouping struct {
   590  	Name       string       `yang:"Name,nomerge"`
   591  	Source     *Statement   `yang:"Statement,nomerge"`
   592  	Parent     Node         `yang:"Parent,nomerge"`
   593  	Extensions []*Statement `yang:"Ext"`
   594  
   595  	Anydata      []*AnyData      `yang:"anydata"`
   596  	Action       []*Action       `yang:"action"`
   597  	Anyxml       []*AnyXML       `yang:"anyxml"`
   598  	Choice       []*Choice       `yang:"choice"`
   599  	Container    []*Container    `yang:"container"`
   600  	Description  *Value          `yang:"description"`
   601  	Grouping     []*Grouping     `yang:"grouping"`
   602  	Leaf         []*Leaf         `yang:"leaf"`
   603  	LeafList     []*LeafList     `yang:"leaf-list"`
   604  	List         []*List         `yang:"list"`
   605  	Notification []*Notification `yang:"notification"`
   606  	Reference    *Value          `yang:"reference"`
   607  	Status       *Value          `yang:"status"`
   608  	Typedef      []*Typedef      `yang:"typedef"`
   609  	Uses         []*Uses         `yang:"uses"`
   610  }
   611  
   612  func (Grouping) Kind() string              { return "grouping" }
   613  func (s *Grouping) ParentNode() Node       { return s.Parent }
   614  func (s *Grouping) NName() string          { return s.Name }
   615  func (s *Grouping) Statement() *Statement  { return s.Source }
   616  func (s *Grouping) Exts() []*Statement     { return s.Extensions }
   617  func (s *Grouping) Groupings() []*Grouping { return s.Grouping }
   618  func (s *Grouping) Typedefs() []*Typedef   { return s.Typedef }
   619  
   620  // A Uses is defined in: http://tools.ietf.org/html/rfc6020#section-7.12
   621  type Uses struct {
   622  	Name       string       `yang:"Name,nomerge"`
   623  	Source     *Statement   `yang:"Statement,nomerge" json:"-"`
   624  	Parent     Node         `yang:"Parent,nomerge" json:"-"`
   625  	Extensions []*Statement `yang:"Ext" json:"-"`
   626  
   627  	Augment     *Augment  `yang:"augment" json:",omitempty"`
   628  	Description *Value    `yang:"description" json:",omitempty"`
   629  	IfFeature   []*Value  `yang:"if-feature" json:"-"`
   630  	Refine      []*Refine `yang:"refine" json:"-"`
   631  	Reference   *Value    `yang:"reference" json:"-"`
   632  	Status      *Value    `yang:"status" json:"-"`
   633  	When        *Value    `yang:"when" json:",omitempty"`
   634  }
   635  
   636  func (Uses) Kind() string             { return "uses" }
   637  func (s *Uses) ParentNode() Node      { return s.Parent }
   638  func (s *Uses) NName() string         { return s.Name }
   639  func (s *Uses) Statement() *Statement { return s.Source }
   640  func (s *Uses) Exts() []*Statement    { return s.Extensions }
   641  
   642  // A Refine is defined in: http://tools.ietf.org/html/rfc6020#section-7.12.2
   643  type Refine struct {
   644  	Name       string       `yang:"Name,nomerge"`
   645  	Source     *Statement   `yang:"Statement,nomerge"`
   646  	Parent     Node         `yang:"Parent,nomerge"`
   647  	Extensions []*Statement `yang:"Ext"`
   648  
   649  	Default     *Value   `yang:"default"`
   650  	Description *Value   `yang:"description"`
   651  	IfFeature   []*Value `yang:"if-feature"`
   652  	Reference   *Value   `yang:"reference"`
   653  	Config      *Value   `yang:"config"`
   654  	Mandatory   *Value   `yang:"mandatory"`
   655  	Presence    *Value   `yang:"presence"`
   656  	Must        []*Must  `yang:"must"`
   657  	MaxElements *Value   `yang:"max-elements"`
   658  	MinElements *Value   `yang:"min-elements"`
   659  }
   660  
   661  func (Refine) Kind() string             { return "refine" }
   662  func (s *Refine) ParentNode() Node      { return s.Parent }
   663  func (s *Refine) NName() string         { return s.Name }
   664  func (s *Refine) Statement() *Statement { return s.Source }
   665  func (s *Refine) Exts() []*Statement    { return s.Extensions }
   666  
   667  // An RPC is defined in: http://tools.ietf.org/html/rfc6020#section-7.13
   668  type RPC struct {
   669  	Name       string       `yang:"Name,nomerge"`
   670  	Source     *Statement   `yang:"Statement,nomerge"`
   671  	Parent     Node         `yang:"Parent,nomerge"`
   672  	Extensions []*Statement `yang:"Ext"`
   673  
   674  	Description *Value      `yang:"description"`
   675  	Grouping    []*Grouping `yang:"grouping"`
   676  	IfFeature   []*Value    `yang:"if-feature"`
   677  	Input       *Input      `yang:"input"`
   678  	Output      *Output     `yang:"output"`
   679  	Reference   *Value      `yang:"reference"`
   680  	Status      *Value      `yang:"status"`
   681  	Typedef     []*Typedef  `yang:"typedef"`
   682  }
   683  
   684  func (RPC) Kind() string              { return "rpc" }
   685  func (s *RPC) ParentNode() Node       { return s.Parent }
   686  func (s *RPC) NName() string          { return s.Name }
   687  func (s *RPC) Statement() *Statement  { return s.Source }
   688  func (s *RPC) Exts() []*Statement     { return s.Extensions }
   689  func (s *RPC) Groupings() []*Grouping { return s.Grouping }
   690  func (s *RPC) Typedefs() []*Typedef   { return s.Typedef }
   691  
   692  // An Input is defined in: http://tools.ietf.org/html/rfc6020#section-7.13.2
   693  type Input struct {
   694  	Name       string       `yang:"Name,nomerge"`
   695  	Source     *Statement   `yang:"Statement,nomerge"`
   696  	Parent     Node         `yang:"Parent,nomerge"`
   697  	Extensions []*Statement `yang:"Ext"`
   698  
   699  	Anydata   []*AnyData   `yang:"anydata"`
   700  	Anyxml    []*AnyXML    `yang:"anyxml"`
   701  	Choice    []*Choice    `yang:"choice"`
   702  	Container []*Container `yang:"container"`
   703  	Grouping  []*Grouping  `yang:"grouping"`
   704  	Leaf      []*Leaf      `yang:"leaf"`
   705  	LeafList  []*LeafList  `yang:"leaf-list"`
   706  	List      []*List      `yang:"list"`
   707  	Typedef   []*Typedef   `yang:"typedef"`
   708  	Uses      []*Uses      `yang:"uses"`
   709  }
   710  
   711  func (Input) Kind() string              { return "input" }
   712  func (s *Input) ParentNode() Node       { return s.Parent }
   713  func (s *Input) NName() string          { return s.Name }
   714  func (s *Input) Statement() *Statement  { return s.Source }
   715  func (s *Input) Exts() []*Statement     { return s.Extensions }
   716  func (s *Input) Groupings() []*Grouping { return s.Grouping }
   717  func (s *Input) Typedefs() []*Typedef   { return s.Typedef }
   718  
   719  // An Output is defined in: http://tools.ietf.org/html/rfc6020#section-7.13.3
   720  type Output struct {
   721  	Name       string       `yang:"Name,nomerge"`
   722  	Source     *Statement   `yang:"Statement,nomerge"`
   723  	Parent     Node         `yang:"Parent,nomerge"`
   724  	Extensions []*Statement `yang:"Ext"`
   725  
   726  	Anydata   []*AnyData   `yang:"anydata"`
   727  	Anyxml    []*AnyXML    `yang:"anyxml"`
   728  	Choice    []*Choice    `yang:"choice"`
   729  	Container []*Container `yang:"container"`
   730  	Grouping  []*Grouping  `yang:"grouping"`
   731  	Leaf      []*Leaf      `yang:"leaf"`
   732  	LeafList  []*LeafList  `yang:"leaf-list"`
   733  	List      []*List      `yang:"list"`
   734  	Typedef   []*Typedef   `yang:"typedef"`
   735  	Uses      []*Uses      `yang:"uses"`
   736  }
   737  
   738  func (Output) Kind() string              { return "output" }
   739  func (s *Output) ParentNode() Node       { return s.Parent }
   740  func (s *Output) NName() string          { return s.Name }
   741  func (s *Output) Statement() *Statement  { return s.Source }
   742  func (s *Output) Exts() []*Statement     { return s.Extensions }
   743  func (s *Output) Groupings() []*Grouping { return s.Grouping }
   744  func (s *Output) Typedefs() []*Typedef   { return s.Typedef }
   745  
   746  // A Notification is defined in: http://tools.ietf.org/html/rfc6020#section-7.14
   747  type Notification struct {
   748  	Name       string       `yang:"Name,nomerge"`
   749  	Source     *Statement   `yang:"Statement,nomerge"`
   750  	Parent     Node         `yang:"Parent,nomerge"`
   751  	Extensions []*Statement `yang:"Ext"`
   752  
   753  	Anydata     []*AnyData   `yang:"anydata"`
   754  	Anyxml      []*AnyXML    `yang:"anyxml"`
   755  	Choice      []*Choice    `yang:"choice"`
   756  	Container   []*Container `yang:"container"`
   757  	Description *Value       `yang:"description"`
   758  	Grouping    []*Grouping  `yang:"grouping"`
   759  	IfFeature   []*Value     `yang:"if-feature"`
   760  	Leaf        []*Leaf      `yang:"leaf"`
   761  	LeafList    []*LeafList  `yang:"leaf-list"`
   762  	List        []*List      `yang:"list"`
   763  	Reference   *Value       `yang:"reference"`
   764  	Status      *Value       `yang:"status"`
   765  	Typedef     []*Typedef   `yang:"typedef"`
   766  	Uses        []*Uses      `yang:"uses"`
   767  }
   768  
   769  func (Notification) Kind() string              { return "notification" }
   770  func (s *Notification) ParentNode() Node       { return s.Parent }
   771  func (s *Notification) NName() string          { return s.Name }
   772  func (s *Notification) Statement() *Statement  { return s.Source }
   773  func (s *Notification) Exts() []*Statement     { return s.Extensions }
   774  func (s *Notification) Groupings() []*Grouping { return s.Grouping }
   775  func (s *Notification) Typedefs() []*Typedef   { return s.Typedef }
   776  
   777  // An Augment is defined in: http://tools.ietf.org/html/rfc6020#section-7.15
   778  // and http://tools.ietf.org/html/rfc7950#section-7.17 ("augment" sub-statement)
   779  type Augment struct {
   780  	Name       string       `yang:"Name,nomerge"`
   781  	Source     *Statement   `yang:"Statement,nomerge"`
   782  	Parent     Node         `yang:"Parent,nomerge"`
   783  	Extensions []*Statement `yang:"Ext"`
   784  
   785  	Anydata      []*AnyData      `yang:"anydata"`
   786  	Action       []*Action       `yang:"action"`
   787  	Anyxml       []*AnyXML       `yang:"anyxml"`
   788  	Case         []*Case         `yang:"case"`
   789  	Choice       []*Choice       `yang:"choice"`
   790  	Container    []*Container    `yang:"container"`
   791  	Description  *Value          `yang:"description"`
   792  	IfFeature    []*Value        `yang:"if-feature"`
   793  	Leaf         []*Leaf         `yang:"leaf"`
   794  	LeafList     []*LeafList     `yang:"leaf-list"`
   795  	List         []*List         `yang:"list"`
   796  	Notification []*Notification `yang:"notification"`
   797  	Reference    *Value          `yang:"reference"`
   798  	Status       *Value          `yang:"status"`
   799  	Uses         []*Uses         `yang:"uses"`
   800  	When         *Value          `yang:"when"`
   801  }
   802  
   803  func (Augment) Kind() string             { return "augment" }
   804  func (s *Augment) ParentNode() Node      { return s.Parent }
   805  func (s *Augment) NName() string         { return s.Name }
   806  func (s *Augment) Statement() *Statement { return s.Source }
   807  func (s *Augment) Exts() []*Statement    { return s.Extensions }
   808  
   809  // An Identity is defined in: http://tools.ietf.org/html/rfc6020#section-7.16
   810  type Identity struct {
   811  	Name       string       `yang:"Name,nomerge"`
   812  	Source     *Statement   `yang:"Statement,nomerge" json:"-"`
   813  	Parent     Node         `yang:"Parent,nomerge" json:"-"`
   814  	Extensions []*Statement `yang:"Ext" json:"-"`
   815  
   816  	Base        []*Value    `yang:"base" json:"-"`
   817  	Description *Value      `yang:"description" json:"-"`
   818  	IfFeature   []*Value    `yang:"if-feature" json:"-"`
   819  	Reference   *Value      `yang:"reference" json:"-"`
   820  	Status      *Value      `yang:"status" json:"-"`
   821  	Values      []*Identity `json:",omitempty"`
   822  }
   823  
   824  func (Identity) Kind() string             { return "identity" }
   825  func (s *Identity) ParentNode() Node      { return s.Parent }
   826  func (s *Identity) NName() string         { return s.Name }
   827  func (s *Identity) Statement() *Statement { return s.Source }
   828  func (s *Identity) Exts() []*Statement    { return s.Extensions }
   829  
   830  // PrefixedName returns the prefix-qualified name for the identity
   831  func (s *Identity) PrefixedName() string {
   832  	return fmt.Sprintf("%s:%s", RootNode(s).GetPrefix(), s.Name)
   833  }
   834  
   835  // modulePrefixedName returns the module-qualified name for the identity.
   836  func (s *Identity) modulePrefixedName() string {
   837  	return fmt.Sprintf("%s:%s", module(s).Name, s.Name)
   838  }
   839  
   840  // IsDefined behaves the same as the implementation for Enum - it returns
   841  // true if an identity with the name is defined within the Values of the
   842  // identity
   843  func (s *Identity) IsDefined(name string) bool {
   844  	return s.GetValue(name) != nil
   845  }
   846  
   847  // GetValue returns a pointer to the identity with name "name" that is within
   848  // the values of the identity
   849  func (s *Identity) GetValue(name string) *Identity {
   850  	for _, v := range s.Values {
   851  		if v.Name == name {
   852  			return v
   853  		}
   854  	}
   855  	return nil
   856  }
   857  
   858  // An Extension is defined in: http://tools.ietf.org/html/rfc6020#section-7.17
   859  type Extension struct {
   860  	Name       string       `yang:"Name,nomerge"`
   861  	Source     *Statement   `yang:"Statement,nomerge" json:"-"`
   862  	Parent     Node         `yang:"Parent,nomerge" json:"-"`
   863  	Extensions []*Statement `yang:"Ext" json:",omitempty"`
   864  
   865  	Argument    *Argument `yang:"argument" json:",omitempty"`
   866  	Description *Value    `yang:"description" json:",omitempty"`
   867  	Reference   *Value    `yang:"reference" json:",omitempty"`
   868  	Status      *Value    `yang:"status" json:",omitempty"`
   869  }
   870  
   871  func (Extension) Kind() string             { return "extension" }
   872  func (s *Extension) ParentNode() Node      { return s.Parent }
   873  func (s *Extension) NName() string         { return s.Name }
   874  func (s *Extension) Statement() *Statement { return s.Source }
   875  func (s *Extension) Exts() []*Statement    { return s.Extensions }
   876  
   877  // An Argument is defined in: http://tools.ietf.org/html/rfc6020#section-7.17.2
   878  type Argument struct {
   879  	Name       string       `yang:"Name,nomerge"`
   880  	Source     *Statement   `yang:"Statement,nomerge" json:"-"`
   881  	Parent     Node         `yang:"Parent,nomerge" json:"-"`
   882  	Extensions []*Statement `yang:"Ext" json:",omitempty"`
   883  
   884  	YinElement *Value `yang:"yin-element" json:",omitempty"`
   885  }
   886  
   887  func (Argument) Kind() string             { return "argument" }
   888  func (s *Argument) ParentNode() Node      { return s.Parent }
   889  func (s *Argument) NName() string         { return s.Name }
   890  func (s *Argument) Statement() *Statement { return s.Source }
   891  func (s *Argument) Exts() []*Statement    { return s.Extensions }
   892  
   893  // An Element is defined in: http://tools.ietf.org/html/rfc6020#section-7.17.2.2
   894  type Element struct {
   895  	Name       string       `yang:"Name,nomerge"`
   896  	Source     *Statement   `yang:"Statement,nomerge"`
   897  	Parent     Node         `yang:"Parent,nomerge"`
   898  	Extensions []*Statement `yang:"Ext"`
   899  
   900  	YinElement *Value `yang:"yin-element"`
   901  }
   902  
   903  func (Element) Kind() string             { return "element" }
   904  func (s *Element) ParentNode() Node      { return s.Parent }
   905  func (s *Element) NName() string         { return s.Name }
   906  func (s *Element) Statement() *Statement { return s.Source }
   907  func (s *Element) Exts() []*Statement    { return s.Extensions }
   908  
   909  // A Feature is defined in: http://tools.ietf.org/html/rfc6020#section-7.18.1
   910  type Feature struct {
   911  	Name       string       `yang:"Name,nomerge"`
   912  	Source     *Statement   `yang:"Statement,nomerge" json:"-"`
   913  	Parent     Node         `yang:"Parent,nomerge" json:"-"`
   914  	Extensions []*Statement `yang:"Ext" json:",omitempty"`
   915  
   916  	Description *Value   `yang:"description" json:",omitempty"`
   917  	IfFeature   []*Value `yang:"if-feature" json:",omitempty"`
   918  	Status      *Value   `yang:"status" json:",omitempty"`
   919  	Reference   *Value   `yang:"reference" json:",omitempty"`
   920  }
   921  
   922  func (Feature) Kind() string             { return "feature" }
   923  func (s *Feature) ParentNode() Node      { return s.Parent }
   924  func (s *Feature) NName() string         { return s.Name }
   925  func (s *Feature) Statement() *Statement { return s.Source }
   926  func (s *Feature) Exts() []*Statement    { return s.Extensions }
   927  
   928  // A Deviation is defined in: http://tools.ietf.org/html/rfc6020#section-7.18.3
   929  type Deviation struct {
   930  	Name       string       `yang:"Name,nomerge"`
   931  	Source     *Statement   `yang:"Statement,nomerge"`
   932  	Parent     Node         `yang:"Parent,nomerge"`
   933  	Extensions []*Statement `yang:"Ext"`
   934  
   935  	Description *Value     `yang:"description"`
   936  	Deviate     []*Deviate `yang:"deviate,required"`
   937  	Reference   *Value     `yang:"reference"`
   938  }
   939  
   940  func (Deviation) Kind() string             { return "deviation" }
   941  func (s *Deviation) ParentNode() Node      { return s.Parent }
   942  func (s *Deviation) NName() string         { return s.Name }
   943  func (s *Deviation) Statement() *Statement { return s.Source }
   944  func (s *Deviation) Exts() []*Statement    { return s.Extensions }
   945  
   946  // A Deviate is defined in: http://tools.ietf.org/html/rfc6020#section-7.18.3.2
   947  type Deviate struct {
   948  	Name       string       `yang:"Name,nomerge"`
   949  	Source     *Statement   `yang:"Statement,nomerge"`
   950  	Parent     Node         `yang:"Parent,nomerge"`
   951  	Extensions []*Statement `yang:"Ext"`
   952  
   953  	Config      *Value   `yang:"config"`
   954  	Default     *Value   `yang:"default"`
   955  	Mandatory   *Value   `yang:"mandatory"`
   956  	MaxElements *Value   `yang:"max-elements"`
   957  	MinElements *Value   `yang:"min-elements"`
   958  	Must        []*Must  `yang:"must"`
   959  	Type        *Type    `yang:"type"`
   960  	Unique      []*Value `yang:"unique"`
   961  	Units       *Value   `yang:"units"`
   962  }
   963  
   964  func (Deviate) Kind() string             { return "deviate" }
   965  func (s *Deviate) ParentNode() Node      { return s.Parent }
   966  func (s *Deviate) NName() string         { return s.Name }
   967  func (s *Deviate) Statement() *Statement { return s.Source }
   968  func (s *Deviate) Exts() []*Statement    { return s.Extensions }
   969  
   970  // An Enum is defined in: http://tools.ietf.org/html/rfc6020#section-9.6.4
   971  type Enum struct {
   972  	Name       string       `yang:"Name,nomerge"`
   973  	Source     *Statement   `yang:"Statement,nomerge"`
   974  	Parent     Node         `yang:"Parent,nomerge"`
   975  	Extensions []*Statement `yang:"Ext"`
   976  
   977  	Description *Value   `yang:"description"`
   978  	IfFeature   []*Value `yang:"if-feature"`
   979  	Reference   *Value   `yang:"reference"`
   980  	Status      *Value   `yang:"status"`
   981  	Value       *Value   `yang:"value"`
   982  }
   983  
   984  func (Enum) Kind() string             { return "enum" }
   985  func (s *Enum) ParentNode() Node      { return s.Parent }
   986  func (s *Enum) NName() string         { return s.Name }
   987  func (s *Enum) Statement() *Statement { return s.Source }
   988  func (s *Enum) Exts() []*Statement    { return s.Extensions }
   989  
   990  // A Bit is defined in: http://tools.ietf.org/html/rfc6020#section-9.7.4
   991  type Bit struct {
   992  	Name       string       `yang:"Name,nomerge"`
   993  	Source     *Statement   `yang:"Statement,nomerge"`
   994  	Parent     Node         `yang:"Parent,nomerge"`
   995  	Extensions []*Statement `yang:"Ext"`
   996  
   997  	Description *Value   `yang:"description"`
   998  	IfFeature   []*Value `yang:"if-feature"`
   999  	Reference   *Value   `yang:"reference"`
  1000  	Status      *Value   `yang:"status"`
  1001  	Position    *Value   `yang:"position"`
  1002  }
  1003  
  1004  func (Bit) Kind() string             { return "bit" }
  1005  func (s *Bit) ParentNode() Node      { return s.Parent }
  1006  func (s *Bit) NName() string         { return s.Name }
  1007  func (s *Bit) Statement() *Statement { return s.Source }
  1008  func (s *Bit) Exts() []*Statement    { return s.Extensions }
  1009  
  1010  // A Range is defined in: http://tools.ietf.org/html/rfc6020#section-9.2.4
  1011  type Range struct {
  1012  	Name       string       `yang:"Name,nomerge"`
  1013  	Source     *Statement   `yang:"Statement,nomerge"`
  1014  	Parent     Node         `yang:"Parent,nomerge"`
  1015  	Extensions []*Statement `yang:"Ext"`
  1016  
  1017  	Description  *Value `yang:"description"`
  1018  	ErrorAppTag  *Value `yang:"error-app-tag"`
  1019  	ErrorMessage *Value `yang:"error-message"`
  1020  	Reference    *Value `yang:"reference"`
  1021  }
  1022  
  1023  func (Range) Kind() string             { return "range" }
  1024  func (s *Range) ParentNode() Node      { return s.Parent }
  1025  func (s *Range) NName() string         { return s.Name }
  1026  func (s *Range) Statement() *Statement { return s.Source }
  1027  func (s *Range) Exts() []*Statement    { return s.Extensions }
  1028  
  1029  // A Length is defined in: http://tools.ietf.org/html/rfc6020#section-9.4.4
  1030  type Length struct {
  1031  	Name       string       `yang:"Name,nomerge"`
  1032  	Source     *Statement   `yang:"Statement,nomerge"`
  1033  	Parent     Node         `yang:"Parent,nomerge"`
  1034  	Extensions []*Statement `yang:"Ext"`
  1035  
  1036  	Description  *Value `yang:"description"`
  1037  	ErrorAppTag  *Value `yang:"error-app-tag"`
  1038  	ErrorMessage *Value `yang:"error-message"`
  1039  	Reference    *Value `yang:"reference"`
  1040  }
  1041  
  1042  func (Length) Kind() string             { return "length" }
  1043  func (s *Length) ParentNode() Node      { return s.Parent }
  1044  func (s *Length) NName() string         { return s.Name }
  1045  func (s *Length) Statement() *Statement { return s.Source }
  1046  func (s *Length) Exts() []*Statement    { return s.Extensions }
  1047  
  1048  // A Pattern is defined in: http://tools.ietf.org/html/rfc6020#section-9.4.6
  1049  type Pattern struct {
  1050  	Name       string       `yang:"Name,nomerge"`
  1051  	Source     *Statement   `yang:"Statement,nomerge"`
  1052  	Parent     Node         `yang:"Parent,nomerge"`
  1053  	Extensions []*Statement `yang:"Ext"`
  1054  
  1055  	Description  *Value `yang:"description"`
  1056  	ErrorAppTag  *Value `yang:"error-app-tag"`
  1057  	ErrorMessage *Value `yang:"error-message"`
  1058  	Reference    *Value `yang:"reference"`
  1059  }
  1060  
  1061  func (Pattern) Kind() string             { return "pattern" }
  1062  func (s *Pattern) ParentNode() Node      { return s.Parent }
  1063  func (s *Pattern) NName() string         { return s.Name }
  1064  func (s *Pattern) Statement() *Statement { return s.Source }
  1065  func (s *Pattern) Exts() []*Statement    { return s.Extensions }
  1066  
  1067  // An Action is defined in http://tools.ietf.org/html/rfc7950#section-7.15
  1068  //
  1069  // Action define an RPC operation connected to a specific container or list data
  1070  // node in the schema. In the schema tree, Action differ from RPC only in where
  1071  // in the tree they are found. RPC nodes are only found as sub-statements of a
  1072  // Module, while Action are found only as sub-statements of Container, List,
  1073  // Grouping and Augment nodes.
  1074  type Action struct {
  1075  	Name       string       `yang:"Name,nomerge"`
  1076  	Source     *Statement   `yang:"Statement,nomerge"`
  1077  	Parent     Node         `yang:"Parent,nomerge"`
  1078  	Extensions []*Statement `yang:"Ext"`
  1079  
  1080  	Description *Value      `yang:"description"`
  1081  	Grouping    []*Grouping `yang:"grouping"`
  1082  	IfFeature   []*Value    `yang:"if-feature"`
  1083  	Input       *Input      `yang:"input"`
  1084  	Output      *Output     `yang:"output"`
  1085  	Reference   *Value      `yang:"reference"`
  1086  	Status      *Value      `yang:"status"`
  1087  	Typedef     []*Typedef  `yang:"typedef"`
  1088  }
  1089  
  1090  func (Action) Kind() string              { return "action" }
  1091  func (s *Action) ParentNode() Node       { return s.Parent }
  1092  func (s *Action) NName() string          { return s.Name }
  1093  func (s *Action) Statement() *Statement  { return s.Source }
  1094  func (s *Action) Exts() []*Statement     { return s.Extensions }
  1095  func (s *Action) Groupings() []*Grouping { return s.Grouping }
  1096  func (s *Action) Typedefs() []*Typedef   { return s.Typedef }