parser

package
v0.0.0-...-8593f40 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Access

type Access string
const (
	// In order from least to greatest
	AccessWriteOnly           Access = "write-only" // Do not use
	AccessNotImplemented      Access = "not-implemented"
	AccessNotAccessible       Access = "not-accessible"
	AccessAccessibleForNotify Access = "accesible-for-notify"
	AccessReadOnly            Access = "read-only"
	AccessReadWrite           Access = "read-write"
	AccessReadCreate          Access = "read-create"
)

func (Access) ToSmi

func (a Access) ToSmi() types.Access

type AgentCapabilities

type AgentCapabilities struct {
	Pos lexer.Position

	ProductRelease string                  `parser:"\"PRODUCT-RELEASE\" @Text"`                                   // Required
	Status         Status                  `parser:"\"STATUS\" @( \"current\" | \"deprecated\" | \"obsolete\" )"` // Required - RFC1444 Section 5.2 defines "deprecated" value
	Description    string                  `parser:"\"DESCRIPTION\" @Text"`                                       // Required
	Reference      string                  `parser:"( \"REFERENCE\" @Text )?"`
	Modules        []AgentCapabilityModule `parser:"@@*"`
}

type AgentCapabilityModule

type AgentCapabilityModule struct {
	Pos lexer.Position

	Module     types.SmiIdentifier        `parser:"\"SUPPORTS\" @Ident"`                                      // Required
	Includes   []types.SmiIdentifier      `parser:"\"INCLUDES\" \"{\" @Ident ( \",\" @Ident )* \",\"? \"}\""` // Required
	Variations []AgentCapabilityVariation `parser:"@@*"`
}

type AgentCapabilityVariation

type AgentCapabilityVariation struct {
	Pos lexer.Position

	Name        types.SmiIdentifier   `parser:"\"VARIATION\" @Ident"` // Required
	Syntax      *Syntax               `parser:"( \"SYNTAX\" @@ )?"`
	WriteSyntax *Syntax               `parser:"( \"WRITE-SYNTAX\" @@ )?"`
	Access      *Access               `` /* 145-byte string literal not displayed */
	Creation    []types.SmiIdentifier `parser:"( \"CREATION-REQUIRES\" \"{\" @Ident ( \",\" @Ident )* \",\"? \"}\" )?"`
	Defval      *string               ``                               /* 155-byte string literal not displayed */
	Description string                `parser:"\"DESCRIPTION\" @Text"` // Required
}

type Compliance

type Compliance struct {
	Pos lexer.Position

	Group  *ComplianceGroup  `parser:"@@"`
	Object *ComplianceObject `parser:"| @@"`
}

type ComplianceGroup

type ComplianceGroup struct {
	Pos lexer.Position

	Name        types.SmiIdentifier `parser:"\"GROUP\" @Ident"`
	Description string              `parser:"\"DESCRIPTION\" @Text"`
}

type ComplianceModuleName

type ComplianceModuleName string

func (*ComplianceModuleName) Parse

type ComplianceObject

type ComplianceObject struct {
	Pos lexer.Position

	Name        types.SmiIdentifier `parser:"\"OBJECT\" @Ident"`
	Syntax      *Syntax             `parser:"( \"SYNTAX\" @@ )?"`
	WriteSyntax *Syntax             `parser:"( \"WRITE-SYNTAX\" @@ )?"`
	MinAccess   *Access             `` /* 131-byte string literal not displayed */
	Description string              `parser:"\"DESCRIPTION\" @Text"`
}

type Date

type Date string

func (Date) ToTime

func (d Date) ToTime() (t time.Time)

type Implicit

type Implicit struct {
	Pos lexer.Position

	Application bool       `parser:"\"[\" @\"APPLICATION\"?"`
	Number      int        `parser:"@Int \"]\""`
	Syntax      SyntaxType `parser:"\"IMPLICIT\" @@"`
}

type Import

type Import struct {
	Pos lexer.Position

	Names  []types.SmiIdentifier `parser:"@Ident ( \",\" @Ident )* \",\"?"`
	Module types.SmiIdentifier   `parser:"\"FROM\" @Ident"`
}

type Index

type Index struct {
	Pos lexer.Position

	Implied bool                `parser:"@\"IMPLIED\"?"`
	Name    types.SmiIdentifier `parser:"@Ident"`
}

type Macro

type Macro struct {
	Pos lexer.Position

	Name types.SmiIdentifier `parser:"@Ident \"MACRO\" Assign"`
	Body MacroBody           `parser:"@@"`
}

type MacroBody

type MacroBody struct {
	Pos lexer.Position

	TypeNotation  string
	ValueNotation string
	Tokens        map[string]string
}

func (*MacroBody) Parse

func (m *MacroBody) Parse(lex *lexer.PeekingLexer) error

type Module

type Module struct {
	Pos lexer.Position

	Name types.SmiIdentifier `parser:"@Ident"`
	Body ModuleBody          `parser:"\"DEFINITIONS\" Assign \"BEGIN\" @@ \"END\""`
}

func Parse

func Parse(r io.Reader) (*Module, error)

func ParseFile

func ParseFile(path string) (*Module, error)

type ModuleBody

type ModuleBody struct {
	Pos lexer.Position

	Imports  []Import              `parser:"( \"IMPORTS\" @@+ \";\" )?"`
	Exports  []types.SmiIdentifier `parser:"( \"EXPORTS\"  @Ident ( \",\" @Ident )* \";\" )?"`
	Identity *ModuleIdentity       `parser:"( @@"`
	Types    []Type                `parser:"| @@"`
	Nodes    []Node                `parser:"| @@"`
	Macros   []Macro               `parser:"| @@ )*"`
}

type ModuleCompliance

type ModuleCompliance struct {
	Pos lexer.Position

	Status      Status                   `parser:"\"STATUS\" @( \"current\" | \"deprecated\" | \"obsolete\" )"` // Required - RFC1444 Section 4.1 defines "deprecated" value
	Description string                   `parser:"\"DESCRIPTION\" @Text"`                                       // Required
	Reference   string                   `parser:"( \"REFERENCE\" @Text )?"`
	Modules     []ModuleComplianceModule `parser:"( \"MODULE\" @@ )+"`
}

type ModuleComplianceModule

type ModuleComplianceModule struct {
	Pos lexer.Position

	Name            ComplianceModuleName  `parser:"@@"`
	MandatoryGroups []types.SmiIdentifier `parser:"( \"MANDATORY-GROUPS\" \"{\" @Ident ( \",\" @Ident )* \",\"? \"}\" )?"`
	Compliances     []Compliance          `parser:"@@*"`
}

type ModuleIdentity

type ModuleIdentity struct {
	Pos lexer.Position

	Name         types.SmiIdentifier `parser:"@Ident \"MODULE-IDENTITY\""`
	LastUpdated  Date                `parser:"\"LAST-UPDATED\" @ExtUTCTime"` // Required
	Organization string              `parser:"\"ORGANIZATION\" @Text"`       // Required
	ContactInfo  string              `parser:"\"CONTACT-INFO\" @Text"`       // Required
	Description  string              `parser:"\"DESCRIPTION\" @Text"`        // Required
	Revisions    []Revision          `parser:"( \"REVISION\" @@ )*"`
	Oid          Oid                 `parser:"Assign \"{\" @@ \"}\""`
}

type NamedNumber

type NamedNumber struct {
	Pos lexer.Position

	Name  types.SmiIdentifier `parser:"@Ident"`
	Value string              `parser:"\"(\" @( \"-\"? Int ) \")\""`
}

type Node

type Node struct {
	Pos lexer.Position

	Name              types.SmiIdentifier `parser:"@Ident"`
	ObjectIdentifier  bool                `parser:"( ( ( @ObjectIdentifier"`
	ObjectIdentity    *ObjectIdentity     `parser:"| ( \"OBJECT-IDENTITY\" @@ )"`
	ObjectGroup       *ObjectGroup        `parser:"| ( \"OBJECT-GROUP\" @@ )"`
	ObjectType        *ObjectType         `parser:"| ( \"OBJECT-TYPE\" @@ )"`
	NotificationGroup *NotificationGroup  `parser:"| ( \"NOTIFICATION-GROUP\" @@ )"`
	NotificationType  *NotificationType   `parser:"| ( \"NOTIFICATION-TYPE\" @@ )"`
	ModuleCompliance  *ModuleCompliance   `parser:"| ( \"MODULE-COMPLIANCE\" @@ )"`
	AgentCapabilities *AgentCapabilities  `parser:"| ( \"AGENT-CAPABILITIES\" @@ ) )"`
	Oid               *Oid                `parser:"Assign \"{\" @@ \"}\" )"`
	TrapType          *TrapType           `parser:"| ( ( \"TRAP-TYPE\" @@ )"`
	SubIdentifier     *types.SmiSubId     `parser:"Assign @Int ) )"`
}

type NotificationGroup

type NotificationGroup struct {
	Pos lexer.Position

	Notifications []types.SmiIdentifier `parser:"\"NOTIFICATIONS\" \"{\" @Ident ( \",\" @Ident )* \",\"? \"}\""` // Required
	Status        Status                `parser:"\"STATUS\" @( \"current\" | \"deprecated\" | \"obsolete\" )"`   // Required
	Description   string                `parser:"\"DESCRIPTION\" @Text"`                                         // Required
	Reference     string                `parser:"( \"REFERENCE\" @Text )?"`
}

type NotificationType

type NotificationType struct {
	Pos lexer.Position

	Objects     []types.SmiIdentifier `parser:"( \"OBJECTS\" \"{\" @Ident ( \",\" @Ident )* \",\"? \"}\" )?"`
	Status      Status                `parser:"\"STATUS\" @( \"current\" | \"deprecated\" | \"obsolete\" )"` // Required
	Description string                `parser:"\"DESCRIPTION\" @Text"`                                       // Required
	Reference   string                `parser:"( \"REFERENCE\" @Text )?"`
}

type ObjectGroup

type ObjectGroup struct {
	Pos lexer.Position

	Objects     []types.SmiIdentifier `parser:"\"OBJECTS\" \"{\" @Ident ( \",\" @Ident )* \",\"? \"}\""`     // Required
	Status      Status                `parser:"\"STATUS\" @( \"current\" | \"deprecated\" | \"obsolete\" )"` // Required
	Description string                `parser:"\"DESCRIPTION\" @Text"`                                       // Required
	Reference   string                `parser:"( \"REFERENCE\" @Text )?"`
}

type ObjectIdentity

type ObjectIdentity struct {
	Pos lexer.Position

	Status      Status `parser:"\"STATUS\" @( \"current\" | \"deprecated\" | \"obsolete\" )"` // Required
	Description string `parser:"\"DESCRIPTION\" @Text"`                                       // Required
	Reference   string `parser:"( \"REFERENCE\" @Text )?"`
}

type ObjectType

type ObjectType struct {
	Pos lexer.Position

	Syntax Syntax `parser:"\"SYNTAX\" @@"` // Required
	Units  string `parser:"( \"UNITS\" @Text )?"`
	Access Access `` // Required
	/* 160-byte string literal not displayed */
	Status      Status               `parser:"\"STATUS\" @( \"mandatory\" | \"optional\" | \"current\" | \"deprecated\" | \"obsolete\" )"` // Required
	Description string               `parser:"( \"DESCRIPTION\" @Text )?"`                                                                 // Required RFC 1212+
	Reference   string               `parser:"( \"REFERENCE\" @Text )?"`
	Index       []Index              `parser:"( ( \"INDEX\" \"{\" @@ ( \",\" @@ )* \",\"? \"}\" )"` // Required for "row" without AUGMENTS
	Augments    *types.SmiIdentifier `parser:"| ( \"AUGMENTS\" \"{\" @Ident \"}\" ) )?"`            // Required for "row" without INDEX
	Defval      *string              ``                                                             /* 155-byte string literal not displayed */
}

type Oid

type Oid struct {
	Pos lexer.Position

	SubIdentifiers []SubIdentifier `parser:"@@+"`
}

type Range

type Range struct {
	Pos lexer.Position

	Start string `parser:"@( \"-\"? Int | BinString | HexString )"`
	End   string `parser:"( \"..\" @( \"-\"? Int | BinString | HexString ) )?"`
}

Per RFC2578 Appendix A, not all valid ASN.1 refinements are allowed by SMI Specifically, MIN and MAX are not valid range values, nor is '<' permitted on the lower or upper end point

type Revision

type Revision struct {
	Pos lexer.Position

	Date        Date   `parser:"@ExtUTCTime"`
	Description string `parser:"\"DESCRIPTION\" @Text"`
}

type Sequence

type Sequence struct {
	Pos lexer.Position

	Type    SequenceType    `parser:"@( \"CHOICE\" | \"SEQUENCE\" )"`
	Entries []SequenceEntry `parser:"\"{\" @@ ( \",\" @@ )* \",\"? \"}\""`
}

type SequenceEntry

type SequenceEntry struct {
	Pos lexer.Position

	Descriptor types.SmiIdentifier `parser:"@Ident"`
	Syntax     SyntaxType          `parser:"@@"`
}

type SequenceType

type SequenceType string
const (
	SequenceTypeChoice   SequenceType = "CHOICE"
	SequenceTypeSequence SequenceType = "SEQUENCE"
)

type Status

type Status string
const (
	StatusMandatory  Status = "mandatory"
	StatusOptional   Status = "optional"
	StatusCurrent    Status = "current"
	StatusDeprecated Status = "deprecated"
	StatusObsolete   Status = "obsolete"
)

func (Status) ToSmi

func (s Status) ToSmi() types.Status

type SubIdentifier

type SubIdentifier struct {
	Pos    lexer.Position
	Name   *types.SmiIdentifier
	Number *types.SmiSubId
}

func (*SubIdentifier) Parse

func (x *SubIdentifier) Parse(lex *lexer.PeekingLexer) error

type SubType

type SubType struct {
	Pos lexer.Position

	OctetString []Range `parser:"( ( \"SIZE\" \"(\" ( @@ ( \"|\" @@ )* ) \")\" )"`
	Integer     []Range `parser:"| @@ ( \"|\" @@ )* )"`
}

type Syntax

type Syntax struct {
	Pos lexer.Position

	Sequence *types.SmiIdentifier `parser:"( \"SEQUENCE\" \"OF\" @Ident )"`
	Type     *SyntaxType          `parser:"| @@"`
}

type SyntaxType

type SyntaxType struct {
	Pos lexer.Position

	Name    types.SmiIdentifier `parser:"@( OctetString | ObjectIdentifier | Ident )"`
	SubType *SubType            `parser:"( ( \"(\" @@ \")\" )"`
	Enum    []NamedNumber       `parser:"| ( \"{\" @@ ( \",\" @@ )* \",\"? \"}\" ) )?"`
}

type TextualConvention

type TextualConvention struct {
	Pos lexer.Position

	DisplayHint string     `parser:"( \"DISPLAY-HINT\" @Text )?"`
	Status      Status     `parser:"\"STATUS\" @( \"current\" | \"deprecated\" | \"obsolete\" )"` // Required
	Description string     `parser:"\"DESCRIPTION\" @Text"`                                       // Required
	Reference   string     `parser:"( \"REFERENCE\" @Text )?"`
	Syntax      SyntaxType `parser:"\"SYNTAX\" @@"` // Required
}

type TrapType

type TrapType struct {
	Pos lexer.Position

	Enterprise  types.SmiIdentifier   `parser:"\"ENTERPRISE\" @Ident"`
	Objects     []types.SmiIdentifier `parser:"( \"VARIABLES\" \"{\" @Ident ( \",\" @Ident )* \",\"? \"}\" )?"`
	Description string                `parser:"( \"DESCRIPTION\" @Text )?"`
	Reference   string                `parser:"( \"REFERENCE\" @Text )?"`
}

type Type

type Type struct {
	Pos lexer.Position

	Name              types.SmiIdentifier `parser:"@Ident Assign"`
	TextualConvention *TextualConvention  `parser:"( ( \"TEXTUAL-CONVENTION\" @@ )"`
	Sequence          *Sequence           `parser:"| @@"`
	Implicit          *Implicit           `parser:"| @@"`
	Syntax            *SyntaxType         `parser:"| @@ )"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL