Skip to main content

TokenKind

Enum TokenKind 

Source
#[repr(u8)]
pub enum TokenKind {
Show 107 variants Error = 0, Eof = 1, ForbiddenKeyword = 2, Comment = 3, UppercaseIdent = 4, LowercaseIdent = 5, Number = 6, NegativeNumber = 7, QuotedString = 8, HexString = 9, BinString = 10, LBracket = 11, RBracket = 12, LBrace = 13, RBrace = 14, LParen = 15, RParen = 16, Colon = 17, Semicolon = 18, Comma = 19, Dot = 20, Pipe = 21, Minus = 22, DotDot = 23, ColonColonEqual = 24, KwDefinitions = 25, KwBegin = 26, KwEnd = 27, KwImports = 28, KwExports = 29, KwFrom = 30, KwObject = 31, KwIdentifier = 32, KwSequence = 33, KwOf = 34, KwChoice = 35, KwMacro = 36, KwSyntax = 37, KwMaxAccess = 38, KwMinAccess = 39, KwAccess = 40, KwStatus = 41, KwDescription = 42, KwReference = 43, KwIndex = 44, KwDefval = 45, KwAugments = 46, KwUnits = 47, KwDisplayHint = 48, KwObjects = 49, KwNotifications = 50, KwModule = 51, KwMandatoryGroups = 52, KwGroup = 53, KwWriteSyntax = 54, KwProductRelease = 55, KwSupports = 56, KwIncludes = 57, KwVariation = 58, KwCreationRequires = 59, KwRevision = 60, KwLastUpdated = 61, KwOrganization = 62, KwContactInfo = 63, KwImplied = 64, KwSize = 65, KwEnterprise = 66, KwVariables = 67, KwModuleIdentity = 68, KwModuleCompliance = 69, KwObjectGroup = 70, KwNotificationGroup = 71, KwAgentCapabilities = 72, KwObjectType = 73, KwObjectIdentity = 74, KwNotificationType = 75, KwTextualConvention = 76, KwTrapType = 77, KwInteger = 78, KwUnsigned32 = 79, KwCounter32 = 80, KwCounter64 = 81, KwGauge32 = 82, KwIpAddress = 83, KwOpaque = 84, KwTimeTicks = 85, KwBits = 86, KwOctet = 87, KwString = 88, KwCounter = 89, KwGauge = 90, KwNetworkAddress = 91, KwApplication = 92, KwImplicit = 93, KwUniversal = 94, KwCurrent = 95, KwDeprecated = 96, KwObsolete = 97, KwMandatory = 98, KwOptional = 99, KwReadOnly = 100, KwReadWrite = 101, KwReadCreate = 102, KwWriteOnly = 103, KwNotAccessible = 104, KwAccessibleForNotify = 105, KwNotImplemented = 106,
}
Expand description

Classification of a Token.

Variants are grouped into special tokens, identifiers, literals, punctuation, and several keyword categories (structural, clause, macro, type, tag, status/access).

Variants§

§

Error = 0

Unrecognized or malformed input.

§

Eof = 1

End of input. Always the last token in a stream.

§

ForbiddenKeyword = 2

A reserved ASN.1 keyword (e.g. TRUE, FALSE, NULL) that must not appear as an identifier in MIB files.

§

Comment = 3

An ---delimited comment.

§

UppercaseIdent = 4

An identifier starting with an uppercase letter (type or module name).

§

LowercaseIdent = 5

An identifier starting with a lowercase letter (value reference).

§

Number = 6

A non-negative decimal integer, e.g. 42.

§

NegativeNumber = 7

A negative decimal integer, e.g. -1.

§

QuotedString = 8

A double-quoted string literal, e.g. "hello".

§

HexString = 9

A hex string literal, e.g. '0A1B'H.

§

BinString = 10

A binary string literal, e.g. '01010101'B.

§

LBracket = 11

[

§

RBracket = 12

]

§

LBrace = 13

{

§

RBrace = 14

}

§

LParen = 15

(

§

RParen = 16

)

§

Colon = 17

:

§

Semicolon = 18

;

§

Comma = 19

,

§

Dot = 20

.

§

Pipe = 21

|

§

Minus = 22

- (standalone, not part of a negative number)

§

DotDot = 23

.. (range separator in SIZE/value constraints)

§

ColonColonEqual = 24

::= (assignment operator)

§

KwDefinitions = 25

DEFINITIONS

§

KwBegin = 26

BEGIN

§

KwEnd = 27

END

§

KwImports = 28

IMPORTS

§

KwExports = 29

EXPORTS - triggers body-skipping in the lexer.

§

KwFrom = 30

FROM

§

KwObject = 31

OBJECT

§

KwIdentifier = 32

IDENTIFIER

§

KwSequence = 33

SEQUENCE

§

KwOf = 34

OF

§

KwChoice = 35

CHOICE

§

KwMacro = 36

MACRO - triggers body-skipping in the lexer.

§

KwSyntax = 37

SYNTAX

§

KwMaxAccess = 38

MAX-ACCESS

§

KwMinAccess = 39

MIN-ACCESS

§

KwAccess = 40

ACCESS (SMIv1)

§

KwStatus = 41

STATUS

§

KwDescription = 42

DESCRIPTION

§

KwReference = 43

REFERENCE

§

KwIndex = 44

INDEX

§

KwDefval = 45

DEFVAL

§

KwAugments = 46

AUGMENTS

§

KwUnits = 47

UNITS

§

KwDisplayHint = 48

DISPLAY-HINT

§

KwObjects = 49

OBJECTS

§

KwNotifications = 50

NOTIFICATIONS

§

KwModule = 51

MODULE

§

KwMandatoryGroups = 52

MANDATORY-GROUPS

§

KwGroup = 53

GROUP

§

KwWriteSyntax = 54

WRITE-SYNTAX

§

KwProductRelease = 55

PRODUCT-RELEASE

§

KwSupports = 56

SUPPORTS

§

KwIncludes = 57

INCLUDES

§

KwVariation = 58

VARIATION

§

KwCreationRequires = 59

CREATION-REQUIRES

§

KwRevision = 60

REVISION

§

KwLastUpdated = 61

LAST-UPDATED

§

KwOrganization = 62

ORGANIZATION

§

KwContactInfo = 63

CONTACT-INFO

§

KwImplied = 64

IMPLIED

§

KwSize = 65

SIZE

§

KwEnterprise = 66

ENTERPRISE (SMIv1 TRAP-TYPE)

§

KwVariables = 67

VARIABLES (SMIv1 TRAP-TYPE)

§

KwModuleIdentity = 68

MODULE-IDENTITY (SMIv2)

§

KwModuleCompliance = 69

MODULE-COMPLIANCE (SMIv2)

§

KwObjectGroup = 70

OBJECT-GROUP (SMIv2)

§

KwNotificationGroup = 71

NOTIFICATION-GROUP (SMIv2)

§

KwAgentCapabilities = 72

AGENT-CAPABILITIES (SMIv2)

§

KwObjectType = 73

OBJECT-TYPE (SMIv1/v2)

§

KwObjectIdentity = 74

OBJECT-IDENTITY (SMIv2)

§

KwNotificationType = 75

NOTIFICATION-TYPE (SMIv2)

§

KwTextualConvention = 76

TEXTUAL-CONVENTION (SMIv2)

§

KwTrapType = 77

TRAP-TYPE (SMIv1)

§

KwInteger = 78

INTEGER or Integer

§

KwUnsigned32 = 79

Unsigned32

§

KwCounter32 = 80

Counter32

§

KwCounter64 = 81

Counter64

§

KwGauge32 = 82

Gauge32

§

KwIpAddress = 83

IpAddress

§

KwOpaque = 84

Opaque

§

KwTimeTicks = 85

TimeTicks

§

KwBits = 86

BITS

§

KwOctet = 87

OCTET (first half of OCTET STRING)

§

KwString = 88

STRING (second half of OCTET STRING)

§

KwCounter = 89

Counter (SMIv1 alias for Counter32)

§

KwGauge = 90

Gauge (SMIv1 alias for Gauge32)

§

KwNetworkAddress = 91

NetworkAddress (SMIv1)

§

KwApplication = 92

APPLICATION

§

KwImplicit = 93

IMPLICIT

§

KwUniversal = 94

UNIVERSAL

§

KwCurrent = 95

current

§

KwDeprecated = 96

deprecated

§

KwObsolete = 97

obsolete

§

KwMandatory = 98

mandatory (SMIv1)

§

KwOptional = 99

optional (SMIv1)

§

KwReadOnly = 100

read-only

§

KwReadWrite = 101

read-write

§

KwReadCreate = 102

read-create

§

KwWriteOnly = 103

write-only (deprecated)

§

KwNotAccessible = 104

not-accessible

§

KwAccessibleForNotify = 105

accessible-for-notify

§

KwNotImplemented = 106

not-implemented (AGENT-CAPABILITIES)

Implementations§

Source§

impl TokenKind

Source

pub fn is_keyword(self) -> bool

Returns true if this is any keyword token (structural, clause, macro, type, tag, or status/access).

Source

pub fn is_identifier(self) -> bool

Returns true for UppercaseIdent or LowercaseIdent.

Source

pub fn is_type_keyword(self) -> bool

Returns true for built-in SMI type keywords (INTEGER, Counter32, OCTET, STRING, NetworkAddress, etc.).

Source

pub fn is_macro_keyword(self) -> bool

Returns true for SMI macro invocation keywords (MODULE-IDENTITY, OBJECT-TYPE, TRAP-TYPE, etc.).

Source

pub fn is_clause_keyword(self) -> bool

Returns true for clause keywords used within macro bodies (SYNTAX, STATUS, DESCRIPTION, INDEX, DEFVAL, etc.).

Source

pub fn is_tag_keyword(self) -> bool

Returns true for ASN.1 tag keywords (APPLICATION, IMPLICIT, UNIVERSAL).

Source

pub fn is_status_access_keyword(self) -> bool

Returns true for status or access value keywords (current, deprecated, read-only, not-accessible, etc.).

Source

pub fn is_structural_keyword(self) -> bool

Returns true for structural keywords that frame the module (DEFINITIONS, BEGIN, END, IMPORTS, FROM, MACRO, etc.).

Source

pub fn display_name(self) -> &'static str

Returns a human-readable name suitable for use in error messages.

Punctuation tokens are shown as quoted characters (e.g. '{'), keywords use their libsmi_name, and other tokens use descriptive labels like "identifier" or "number".

Source

pub fn libsmi_name(self) -> &'static str

Returns the libsmi-compatible uppercase name for this token kind.

These names match the token naming conventions used by the libsmi library, with hyphens replaced by underscores (e.g. OBJECT_TYPE, READ_ONLY, COLON_COLON_EQUAL).

Trait Implementations§

Source§

impl Clone for TokenKind

Source§

fn clone(&self) -> TokenKind

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TokenKind

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for TokenKind

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats using the libsmi_name representation.

Source§

impl Hash for TokenKind

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for TokenKind

Source§

fn eq(&self, other: &TokenKind) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for TokenKind

Source§

impl Eq for TokenKind

Source§

impl StructuralPartialEq for TokenKind

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more