Documentation ¶
Overview ¶
Copyright (c) 2019-2020, AT&T Intellectual Property. All rights reserved.
Copyright (c) 2014 by Brocade Communications Systems, Inc. All rights reserved.
Copyright 2011 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
SPDX-License-Identifier: MPL-2.0 and BSD-3-Clause
Index ¶
- Variables
- func GetModules(trees map[string]*Tree) map[string]*Module
- func GetModulesAndSubmodules(mods map[string]*Tree) (map[string]*Module, map[string]*Module)
- type AbsoluteSchemaArg
- type ArgInterner
- type Argument
- type BoolArg
- type Cardinality
- type DataDef
- type DateArg
- type DescendantSchemaArg
- type DeviateArg
- type EmptyArg
- type FractionDigitsArg
- type GEnv
- type HasArgument
- type IdArg
- type IdRefArg
- type IntArg
- type KeyArg
- type Lb
- type LengthArg
- type MaxValueArg
- type Module
- type Namespace
- type Node
- type NodeCardinality
- type NodeType
- func (t NodeType) IsConfigdNode() bool
- func (t NodeType) IsDataNode() bool
- func (t NodeType) IsDeviateNode() bool
- func (t NodeType) IsExtensionNode() bool
- func (t NodeType) IsOpdDefNode() bool
- func (t NodeType) IsOpdExtension() bool
- func (t NodeType) IsTypeRestriction() bool
- func (t NodeType) String() string
- func (t NodeType) Type() NodeType
- type OrdByArg
- type PatternArg
- type Pos
- type PrefixArg
- type RangeArg
- type RangeArgBdrySlice
- type SchemaArg
- type Scope
- type StatusArg
- type StringArg
- type StringInterner
- type TEnv
- type Tree
- func New(name string, card NodeCardinality) *Tree
- func NewWithInterners(name string, card NodeCardinality, stringInterner *StringInterner, ...) *Tree
- func Parse(name, text string, extCard NodeCardinality) (*Tree, error)
- func ParseWithInterners(name, text string, extCard NodeCardinality, stringInterner *StringInterner, ...) (*Tree, error)
- type TypeDef
- type TypeRestriction
- type UintArg
- type UniqueArg
- type UriArg
- type YangVersionArg
Constants ¶
This section is empty.
Variables ¶
var ErrCard = errors.New("cardinality mismatch")
var ErrNoShadow = errors.New("cannot shadow")
Functions ¶
Types ¶
type AbsoluteSchemaArg ¶
type AbsoluteSchemaArg struct {
// contains filtered or unexported fields
}
func (*AbsoluteSchemaArg) Parse ¶
func (a *AbsoluteSchemaArg) Parse() error
func (*AbsoluteSchemaArg) Path ¶
func (a *AbsoluteSchemaArg) Path() []xml.Name
type ArgInterner ¶
type ArgInterner struct {
// contains filtered or unexported fields
}
func NewArgInterner ¶
func NewArgInterner() *ArgInterner
type Cardinality ¶
type Cardinality struct {
Start, End rune
}
type DescendantSchemaArg ¶
type DescendantSchemaArg struct {
// contains filtered or unexported fields
}
func (*DescendantSchemaArg) Parse ¶
func (a *DescendantSchemaArg) Parse() error
func (*DescendantSchemaArg) Path ¶
func (a *DescendantSchemaArg) Path() []xml.Name
type DeviateArg ¶
type DeviateArg struct {
// contains filtered or unexported fields
}
func (*DeviateArg) Parse ¶
func (a *DeviateArg) Parse() error
type FractionDigitsArg ¶
type FractionDigitsArg struct {
// contains filtered or unexported fields
}
func (*FractionDigitsArg) Parse ¶
func (a *FractionDigitsArg) Parse() error
type HasArgument ¶
type HasArgument interface { Argument() Argument ArgBool() bool ArgDate() string ArgDescendantSchema() []xml.Name ArgFractionDigits() int ArgIdRef() xml.Name ArgId() string ArgInt() int ArgKey() []string ArgLength() []Lb ArgMax() uint ArgOrdBy() string ArgPattern() *regexp.Regexp ArgPrefix() string ArgRange() RangeArgBdrySlice ArgSchema() []xml.Name ArgStatus() string ArgString() string ArgUint() uint ArgUnique() [][]xml.Name ArgUri() string ArgWhen() string ArgMust() string ArgPath() string // contains filtered or unexported methods }
type IdArg ¶
type IdArg struct {
// contains filtered or unexported fields
}
type MaxValueArg ¶
type MaxValueArg struct {
// contains filtered or unexported fields
}
func (*MaxValueArg) Parse ¶
func (a *MaxValueArg) Parse() error
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
func (*Module) GetSubmodules ¶
type Namespace ¶
type Namespace interface { GetNodeNamespace(mod Node, modules map[string]*Module) string GetNodeModulename(mod Node) string GetNodeSubmoduleName() string GetModuleByPrefix( pfx string, modules map[string]*Module, skipUnknown bool, ) (Node, error) YangPrefixToNamespace( prefix string, modules map[string]*Module, skipUnknown bool, ) (string, error) }
type Node ¶
type Node interface { Type() NodeType Statement() string Name() string String() string Clone(m Node) Node HasArgument Namespace Root() Node UsesRoot() Node Children() []Node ChildrenByType(t NodeType) []Node ChildByType(t NodeType) Node LookupChild(t NodeType, name string) Node // Needed to merge in imports and includes AddChildren(new ...Node) ReplaceChild(old Node, new ...Node) ReplaceChildByType(typ NodeType, new Node) // 'when' statements added directly under 'augment' need special handling. // We store them on the children, but run 'as parent'. As we add the // children before we parse the 'when' statement, we have to store the // knowledge on the node. As we might want this for other purposes, // 'AddedByAugment()' seems a reasonable name. AddWhenChildren(fromAugment bool, new ...Node) AddedByAugment() bool NotSupported() bool MarkNotSupported() GetCardinalityEnd(t NodeType) rune // // (agj) TODO - Combine environment types // Tenv() *TEnv LookupType(string) (Node, bool) Genv() *GEnv LookupGrouping(string) (Node, bool) // This is where file and line numbers are stored ErrorContext() (location, context string) // Shortcuts for child values. Possibly not needed Min() uint Max() uint OrdBy() string Desc() string Ref() string Presence() bool Keys() []string Def() string HasDef() bool Config() bool HasConfig() bool Units() string Mandatory() bool FracDigit() int Msg() string Cmsg() string Value() int Revision() string Prefix() string Ns() string Path() string Status() string OnEnter() string Privileged() bool Local() bool Secret() bool PassOpcArgs() bool AppTag() string // contains filtered or unexported methods }
func NewFakeNodeByType ¶
func NewFakeNodeByType(extCard NodeCardinality, ntype NodeType, name string) Node
type NodeCardinality ¶
type NodeCardinality func(NodeType) map[NodeType]Cardinality
type NodeType ¶
type NodeType int
const ( NodeUnknown NodeType = iota //Unknown node (yang extension) NodeModule NodeImport NodeInclude NodeRevision NodeSubmodule NodeBelongsTo NodeTypedef //Special purpose nodes according to RFC NodeDataDef NodeContainer NodeLeaf NodeLeafList NodeList NodeChoice NodeUses NodeAnyxml NodeCase NodeDataDefEnd //Additional node for augment data-def NodeGrouping NodeMust NodeRpc NodeInput NodeOutput NodeNotification NodeAugment NodeIdentity NodeExtension NodeArgument NodeFeature NodeDeviation NodeDeviate NodeDeviateAdd NodeDeviateDelete NodeDeviateReplace NodeDeviateNotSupported NodeDeviateEnd // Start of Type Restrictions NodeTypeRestrictionStart NodeTyp NodeRange NodeLength NodePattern NodeEnum NodeBit NodePath NodeFractionDigits NodeRequireInstance NodeTypeRestrictionEnd // End of Type Restrictions NodeContact NodeDescription NodeNamespace NodeOrganization NodePrefix NodeReference NodeYangVersion NodeRevisionDate NodeDefault NodeStatus NodeUnits NodeConfig NodeIfFeature NodePresence NodeWhen NodeErrorAppTag NodeErrorMessage NodeMandatory NodeMinElements NodeMaxElements NodeOrderedBy NodeKey NodeUnique NodeRefine NodeBase NodeYinElement NodeValue NodePosition NodeConfigdStart NodeConfigdHelp NodeConfigdValidate NodeConfigdNormalize NodeConfigdSyntax NodeConfigdPriority NodeConfigdAllowed NodeConfigdBegin NodeConfigdEnd NodeConfigdCreate NodeConfigdDelete NodeConfigdUpdate NodeConfigdSubst NodeConfigdSecret NodeConfigdErrMsg NodeConfigdPHelp NodeConfigdCallRpc NodeConfigdGetState NodeConfigdDeferActions NodeConfigdMust NodeConfigdStop NodeOpdDef NodeOpdArgument NodeOpdAugment NodeOpdCommand NodeOpdOption NodeOpdDefEnd NodeOpdInherit NodeOpdRepeatable NodeOpdPassOpcArgs NodeOpdPrivileged NodeOpdLocal NodeOpdSecret // OPD extensions which can extend non-opd nodes NodeOpdExtensionStart NodeOpdHelp NodeOpdAllowed NodeOpdOnEnter NodeOpdPatternHelp NodeOpdExtensionEnd NodeTypeIndexSize // MUST BE LAST. NOT A VALID NODE TYPE )
func NodeTypeFromName ¶
func (NodeType) IsConfigdNode ¶
func (NodeType) IsDataNode ¶
func (NodeType) IsDeviateNode ¶
func (NodeType) IsExtensionNode ¶
func (NodeType) IsOpdDefNode ¶
func (NodeType) IsOpdExtension ¶
func (NodeType) IsTypeRestriction ¶
type PatternArg ¶
func (*PatternArg) Parse ¶
func (a *PatternArg) Parse() error
Go's regexp engine doesn't anchor regexps to start and end of line, whereas YANG pattern statements use XSD regexps that do this implicitly. So, we need to explicitly anchor pattern regexps to get the correct behaviour. As these patterns may be branched (contain '|' (or)), we need to parenthesise the pattern before anchoring it.
func (*PatternArg) String ¶
func (a *PatternArg) String() string
func (*PatternArg) Validate ¶
func (a *PatternArg) Validate(s string) bool
type RangeArgBdrySlice ¶
type RangeArgBdrySlice []argRb
type StringInterner ¶
type StringInterner struct {
// contains filtered or unexported fields
}
func NewStringInterner ¶
func NewStringInterner() *StringInterner
func (*StringInterner) Intern ¶
func (i *StringInterner) Intern(in string) string
type Tree ¶
type Tree struct { Root Node // top-level root of the tree. ParseName string // contains filtered or unexported fields }
Tree is the representation of a single parsed template.
func New ¶
func New(name string, card NodeCardinality) *Tree
Parsing. New allocates a new parse tree with the given name.
func NewWithInterners ¶
func NewWithInterners( name string, card NodeCardinality, stringInterner *StringInterner, argInterner *ArgInterner, ) *Tree
func ParseWithInterners ¶
func ParseWithInterners( name, text string, extCard NodeCardinality, stringInterner *StringInterner, argInterner *ArgInterner, ) (*Tree, error)
func (*Tree) ErrorContextPosition ¶
type TypeRestriction ¶
type TypeRestriction interface { Node // contains filtered or unexported methods }
type YangVersionArg ¶
type YangVersionArg struct {
// contains filtered or unexported fields
}
func (*YangVersionArg) Parse ¶
func (a *YangVersionArg) Parse() error