1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
//! Token types produced by the SMI/MIB [`Lexer`](super::Lexer).
//!
//! Contains the [`Token`] struct (pairing a [`TokenKind`] with a [`Span`])
//! and the [`TokenKind`] enum covering all SMIv1/SMIv2 token categories:
//! identifiers, literals, punctuation, and keywords.
use crate::types::Span;
/// A single lexed token with its classification and source location.
///
/// Use [`TokenKind`] to determine what the token represents, and
/// [`Span`] to index back into the original source bytes.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Token {
/// What kind of token this is (keyword, identifier, literal, etc.).
pub kind: TokenKind,
/// Byte range in the source text that produced this token.
pub span: Span,
}
/// Classification of a [`Token`].
///
/// Variants are grouped into special tokens, identifiers, literals,
/// punctuation, and several keyword categories (structural, clause,
/// macro, type, tag, status/access).
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[repr(u8)]
pub enum TokenKind {
// -- Special --
/// Unrecognized or malformed input.
Error,
/// End of input. Always the last token in a stream.
Eof,
/// A reserved ASN.1 keyword (e.g. `TRUE`, `FALSE`, `NULL`) that must
/// not appear as an identifier in MIB files.
ForbiddenKeyword,
/// An `--`-delimited comment.
Comment,
// -- Identifiers --
/// An identifier starting with an uppercase letter (type or module name).
UppercaseIdent,
/// An identifier starting with a lowercase letter (value reference).
LowercaseIdent,
// -- Literals --
/// A non-negative decimal integer, e.g. `42`.
Number,
/// A negative decimal integer, e.g. `-1`.
NegativeNumber,
/// A double-quoted string literal, e.g. `"hello"`.
QuotedString,
/// A hex string literal, e.g. `'0A1B'H`.
HexString,
/// A binary string literal, e.g. `'01010101'B`.
BinString,
// -- Single-character punctuation --
/// `[`
LBracket,
/// `]`
RBracket,
/// `{`
LBrace,
/// `}`
RBrace,
/// `(`
LParen,
/// `)`
RParen,
/// `:`
Colon,
/// `;`
Semicolon,
/// `,`
Comma,
/// `.`
Dot,
/// `|`
Pipe,
/// `-` (standalone, not part of a negative number)
Minus,
// -- Multi-character operators --
/// `..` (range separator in SIZE/value constraints)
DotDot,
/// `::=` (assignment operator)
ColonColonEqual,
// -- Structural keywords (first keyword range) --
/// `DEFINITIONS`
KwDefinitions,
/// `BEGIN`
KwBegin,
/// `END`
KwEnd,
/// `IMPORTS`
KwImports,
/// `EXPORTS` - triggers body-skipping in the lexer.
KwExports,
/// `FROM`
KwFrom,
/// `OBJECT`
KwObject,
/// `IDENTIFIER`
KwIdentifier,
/// `SEQUENCE`
KwSequence,
/// `OF`
KwOf,
/// `CHOICE`
KwChoice,
/// `MACRO` - triggers body-skipping in the lexer.
KwMacro,
// -- Clause keywords --
/// `SYNTAX`
KwSyntax,
/// `MAX-ACCESS`
KwMaxAccess,
/// `MIN-ACCESS`
KwMinAccess,
/// `ACCESS` (SMIv1)
KwAccess,
/// `STATUS`
KwStatus,
/// `DESCRIPTION`
KwDescription,
/// `REFERENCE`
KwReference,
/// `INDEX`
KwIndex,
/// `DEFVAL`
KwDefval,
/// `AUGMENTS`
KwAugments,
/// `UNITS`
KwUnits,
/// `DISPLAY-HINT`
KwDisplayHint,
/// `OBJECTS`
KwObjects,
/// `NOTIFICATIONS`
KwNotifications,
/// `MODULE`
KwModule,
/// `MANDATORY-GROUPS`
KwMandatoryGroups,
/// `GROUP`
KwGroup,
/// `WRITE-SYNTAX`
KwWriteSyntax,
/// `PRODUCT-RELEASE`
KwProductRelease,
/// `SUPPORTS`
KwSupports,
/// `INCLUDES`
KwIncludes,
/// `VARIATION`
KwVariation,
/// `CREATION-REQUIRES`
KwCreationRequires,
/// `REVISION`
KwRevision,
/// `LAST-UPDATED`
KwLastUpdated,
/// `ORGANIZATION`
KwOrganization,
/// `CONTACT-INFO`
KwContactInfo,
/// `IMPLIED`
KwImplied,
/// `SIZE`
KwSize,
/// `ENTERPRISE` (SMIv1 TRAP-TYPE)
KwEnterprise,
/// `VARIABLES` (SMIv1 TRAP-TYPE)
KwVariables,
// -- MACRO invocation keywords --
/// `MODULE-IDENTITY` (SMIv2)
KwModuleIdentity,
/// `MODULE-COMPLIANCE` (SMIv2)
KwModuleCompliance,
/// `OBJECT-GROUP` (SMIv2)
KwObjectGroup,
/// `NOTIFICATION-GROUP` (SMIv2)
KwNotificationGroup,
/// `AGENT-CAPABILITIES` (SMIv2)
KwAgentCapabilities,
/// `OBJECT-TYPE` (SMIv1/v2)
KwObjectType,
/// `OBJECT-IDENTITY` (SMIv2)
KwObjectIdentity,
/// `NOTIFICATION-TYPE` (SMIv2)
KwNotificationType,
/// `TEXTUAL-CONVENTION` (SMIv2)
KwTextualConvention,
/// `TRAP-TYPE` (SMIv1)
KwTrapType,
// -- Type keywords --
/// `INTEGER` or `Integer`
KwInteger,
/// `Unsigned32`
KwUnsigned32,
/// `Counter32`
KwCounter32,
/// `Counter64`
KwCounter64,
/// `Gauge32`
KwGauge32,
/// `IpAddress`
KwIpAddress,
/// `Opaque`
KwOpaque,
/// `TimeTicks`
KwTimeTicks,
/// `BITS`
KwBits,
/// `OCTET` (first half of `OCTET STRING`)
KwOctet,
/// `STRING` (second half of `OCTET STRING`)
KwString,
// -- SMIv1 type aliases --
/// `Counter` (SMIv1 alias for Counter32)
KwCounter,
/// `Gauge` (SMIv1 alias for Gauge32)
KwGauge,
/// `NetworkAddress` (SMIv1)
KwNetworkAddress,
// -- ASN.1 tag keywords --
/// `APPLICATION`
KwApplication,
/// `IMPLICIT`
KwImplicit,
/// `UNIVERSAL`
KwUniversal,
// -- Status/Access value keywords (last keyword range) --
/// `current`
KwCurrent,
/// `deprecated`
KwDeprecated,
/// `obsolete`
KwObsolete,
/// `mandatory` (SMIv1)
KwMandatory,
/// `optional` (SMIv1)
KwOptional,
/// `read-only`
KwReadOnly,
/// `read-write`
KwReadWrite,
/// `read-create`
KwReadCreate,
/// `write-only` (deprecated)
KwWriteOnly,
/// `not-accessible`
KwNotAccessible,
/// `accessible-for-notify`
KwAccessibleForNotify,
/// `not-implemented` (AGENT-CAPABILITIES)
KwNotImplemented,
}
impl TokenKind {
/// Returns `true` if this is any keyword token (structural, clause, macro,
/// type, tag, or status/access).
pub fn is_keyword(self) -> bool {
self.is_structural_keyword()
|| self.is_clause_keyword()
|| self.is_macro_keyword()
|| self.is_type_keyword()
|| self.is_tag_keyword()
|| self.is_status_access_keyword()
}
/// Returns `true` for [`UppercaseIdent`](Self::UppercaseIdent) or
/// [`LowercaseIdent`](Self::LowercaseIdent).
pub fn is_identifier(self) -> bool {
matches!(self, TokenKind::UppercaseIdent | TokenKind::LowercaseIdent)
}
/// Returns `true` for built-in SMI type keywords (`INTEGER`, `Counter32`,
/// `OCTET`, `STRING`, `NetworkAddress`, etc.).
pub fn is_type_keyword(self) -> bool {
matches!(
self,
TokenKind::KwInteger
| TokenKind::KwUnsigned32
| TokenKind::KwCounter32
| TokenKind::KwCounter64
| TokenKind::KwGauge32
| TokenKind::KwIpAddress
| TokenKind::KwOpaque
| TokenKind::KwTimeTicks
| TokenKind::KwBits
| TokenKind::KwOctet
| TokenKind::KwString
| TokenKind::KwCounter
| TokenKind::KwGauge
| TokenKind::KwNetworkAddress
)
}
/// Returns `true` for SMI macro invocation keywords (`MODULE-IDENTITY`,
/// `OBJECT-TYPE`, `TRAP-TYPE`, etc.).
pub fn is_macro_keyword(self) -> bool {
matches!(
self,
TokenKind::KwModuleIdentity
| TokenKind::KwModuleCompliance
| TokenKind::KwObjectGroup
| TokenKind::KwNotificationGroup
| TokenKind::KwAgentCapabilities
| TokenKind::KwObjectType
| TokenKind::KwObjectIdentity
| TokenKind::KwNotificationType
| TokenKind::KwTextualConvention
| TokenKind::KwTrapType
)
}
/// Returns `true` for clause keywords used within macro bodies (`SYNTAX`,
/// `STATUS`, `DESCRIPTION`, `INDEX`, `DEFVAL`, etc.).
pub fn is_clause_keyword(self) -> bool {
matches!(
self,
TokenKind::KwSyntax
| TokenKind::KwMaxAccess
| TokenKind::KwMinAccess
| TokenKind::KwAccess
| TokenKind::KwStatus
| TokenKind::KwDescription
| TokenKind::KwReference
| TokenKind::KwIndex
| TokenKind::KwDefval
| TokenKind::KwAugments
| TokenKind::KwUnits
| TokenKind::KwDisplayHint
| TokenKind::KwObjects
| TokenKind::KwNotifications
| TokenKind::KwModule
| TokenKind::KwMandatoryGroups
| TokenKind::KwGroup
| TokenKind::KwWriteSyntax
| TokenKind::KwProductRelease
| TokenKind::KwSupports
| TokenKind::KwIncludes
| TokenKind::KwVariation
| TokenKind::KwCreationRequires
| TokenKind::KwRevision
| TokenKind::KwLastUpdated
| TokenKind::KwOrganization
| TokenKind::KwContactInfo
| TokenKind::KwImplied
| TokenKind::KwSize
| TokenKind::KwEnterprise
| TokenKind::KwVariables
)
}
/// Returns `true` for ASN.1 tag keywords (`APPLICATION`, `IMPLICIT`,
/// `UNIVERSAL`).
pub fn is_tag_keyword(self) -> bool {
matches!(
self,
TokenKind::KwApplication | TokenKind::KwImplicit | TokenKind::KwUniversal
)
}
/// Returns `true` for status or access value keywords (`current`,
/// `deprecated`, `read-only`, `not-accessible`, etc.).
pub fn is_status_access_keyword(self) -> bool {
matches!(
self,
TokenKind::KwCurrent
| TokenKind::KwDeprecated
| TokenKind::KwObsolete
| TokenKind::KwMandatory
| TokenKind::KwOptional
| TokenKind::KwReadOnly
| TokenKind::KwReadWrite
| TokenKind::KwReadCreate
| TokenKind::KwWriteOnly
| TokenKind::KwNotAccessible
| TokenKind::KwAccessibleForNotify
| TokenKind::KwNotImplemented
)
}
/// Returns `true` for structural keywords that frame the module
/// (`DEFINITIONS`, `BEGIN`, `END`, `IMPORTS`, `FROM`, `MACRO`, etc.).
pub fn is_structural_keyword(self) -> bool {
matches!(
self,
TokenKind::KwDefinitions
| TokenKind::KwBegin
| TokenKind::KwEnd
| TokenKind::KwImports
| TokenKind::KwExports
| TokenKind::KwFrom
| TokenKind::KwObject
| TokenKind::KwIdentifier
| TokenKind::KwSequence
| TokenKind::KwOf
| TokenKind::KwChoice
| TokenKind::KwMacro
)
}
/// 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`](Self::libsmi_name), and other
/// tokens use descriptive labels like `"identifier"` or `"number"`.
pub fn display_name(self) -> &'static str {
match self {
TokenKind::Error => "<error>",
TokenKind::Eof => "end of file",
TokenKind::ForbiddenKeyword => "reserved keyword",
TokenKind::Comment => "comment",
TokenKind::UppercaseIdent => "identifier",
TokenKind::LowercaseIdent => "identifier",
TokenKind::Number => "number",
TokenKind::NegativeNumber => "negative number",
TokenKind::QuotedString => "quoted string",
TokenKind::HexString => "hex string",
TokenKind::BinString => "binary string",
TokenKind::LBracket => "'['",
TokenKind::RBracket => "']'",
TokenKind::LBrace => "'{'",
TokenKind::RBrace => "'}'",
TokenKind::LParen => "'('",
TokenKind::RParen => "')'",
TokenKind::Colon => "':'",
TokenKind::Semicolon => "';'",
TokenKind::Comma => "','",
TokenKind::Dot => "'.'",
TokenKind::Pipe => "'|'",
TokenKind::Minus => "'-'",
TokenKind::DotDot => "'..'",
TokenKind::ColonColonEqual => "'::='",
_ => self.libsmi_name(),
}
}
/// 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`).
pub fn libsmi_name(self) -> &'static str {
match self {
TokenKind::Error => "ERROR",
TokenKind::Eof => "EOF",
TokenKind::ForbiddenKeyword => "FORBIDDEN_KEYWORD",
TokenKind::Comment => "COMMENT",
TokenKind::UppercaseIdent => "UPPERCASE_IDENTIFIER",
TokenKind::LowercaseIdent => "LOWERCASE_IDENTIFIER",
TokenKind::Number => "NUMBER",
TokenKind::NegativeNumber => "NEGATIVENUMBER",
TokenKind::QuotedString => "QUOTED_STRING",
TokenKind::HexString => "HEX_STRING",
TokenKind::BinString => "BIN_STRING",
TokenKind::LBracket => "LBRACKET",
TokenKind::RBracket => "RBRACKET",
TokenKind::LBrace => "LBRACE",
TokenKind::RBrace => "RBRACE",
TokenKind::LParen => "LPAREN",
TokenKind::RParen => "RPAREN",
TokenKind::Colon => "COLON",
TokenKind::Semicolon => "SEMICOLON",
TokenKind::Comma => "COMMA",
TokenKind::Dot => "DOT",
TokenKind::Pipe => "PIPE",
TokenKind::Minus => "MINUS",
TokenKind::DotDot => "DOT_DOT",
TokenKind::ColonColonEqual => "COLON_COLON_EQUAL",
TokenKind::KwDefinitions => "DEFINITIONS",
TokenKind::KwBegin => "BEGIN",
TokenKind::KwEnd => "END",
TokenKind::KwImports => "IMPORTS",
TokenKind::KwExports => "EXPORTS",
TokenKind::KwFrom => "FROM",
TokenKind::KwObject => "OBJECT",
TokenKind::KwIdentifier => "IDENTIFIER",
TokenKind::KwSequence => "SEQUENCE",
TokenKind::KwOf => "OF",
TokenKind::KwChoice => "CHOICE",
TokenKind::KwMacro => "MACRO",
TokenKind::KwSyntax => "SYNTAX",
TokenKind::KwMaxAccess => "MAX_ACCESS",
TokenKind::KwMinAccess => "MIN_ACCESS",
TokenKind::KwAccess => "ACCESS",
TokenKind::KwStatus => "STATUS",
TokenKind::KwDescription => "DESCRIPTION",
TokenKind::KwReference => "REFERENCE",
TokenKind::KwIndex => "INDEX",
TokenKind::KwDefval => "DEFVAL",
TokenKind::KwAugments => "AUGMENTS",
TokenKind::KwUnits => "UNITS",
TokenKind::KwDisplayHint => "DISPLAY_HINT",
TokenKind::KwObjects => "OBJECTS",
TokenKind::KwNotifications => "NOTIFICATIONS",
TokenKind::KwModule => "MODULE",
TokenKind::KwMandatoryGroups => "MANDATORY_GROUPS",
TokenKind::KwGroup => "GROUP",
TokenKind::KwWriteSyntax => "WRITE_SYNTAX",
TokenKind::KwProductRelease => "PRODUCT_RELEASE",
TokenKind::KwSupports => "SUPPORTS",
TokenKind::KwIncludes => "INCLUDES",
TokenKind::KwVariation => "VARIATION",
TokenKind::KwCreationRequires => "CREATION_REQUIRES",
TokenKind::KwRevision => "REVISION",
TokenKind::KwLastUpdated => "LAST_UPDATED",
TokenKind::KwOrganization => "ORGANIZATION",
TokenKind::KwContactInfo => "CONTACT_INFO",
TokenKind::KwImplied => "IMPLIED",
TokenKind::KwSize => "SIZE",
TokenKind::KwEnterprise => "ENTERPRISE",
TokenKind::KwVariables => "VARIABLES",
TokenKind::KwModuleIdentity => "MODULE_IDENTITY",
TokenKind::KwModuleCompliance => "MODULE_COMPLIANCE",
TokenKind::KwObjectGroup => "OBJECT_GROUP",
TokenKind::KwNotificationGroup => "NOTIFICATION_GROUP",
TokenKind::KwAgentCapabilities => "AGENT_CAPABILITIES",
TokenKind::KwObjectType => "OBJECT_TYPE",
TokenKind::KwObjectIdentity => "OBJECT_IDENTITY",
TokenKind::KwNotificationType => "NOTIFICATION_TYPE",
TokenKind::KwTextualConvention => "TEXTUAL_CONVENTION",
TokenKind::KwTrapType => "TRAP_TYPE",
TokenKind::KwInteger => "INTEGER",
TokenKind::KwUnsigned32 => "UNSIGNED32",
TokenKind::KwCounter32 => "COUNTER32",
TokenKind::KwCounter64 => "COUNTER64",
TokenKind::KwGauge32 => "GAUGE32",
TokenKind::KwIpAddress => "IPADDRESS",
TokenKind::KwOpaque => "OPAQUE",
TokenKind::KwTimeTicks => "TIMETICKS",
TokenKind::KwBits => "BITS",
TokenKind::KwOctet => "OCTET",
TokenKind::KwString => "STRING",
TokenKind::KwCounter => "COUNTER",
TokenKind::KwGauge => "GAUGE",
TokenKind::KwNetworkAddress => "NETWORKADDRESS",
TokenKind::KwApplication => "APPLICATION",
TokenKind::KwImplicit => "IMPLICIT",
TokenKind::KwUniversal => "UNIVERSAL",
TokenKind::KwCurrent => "CURRENT",
TokenKind::KwDeprecated => "DEPRECATED",
TokenKind::KwObsolete => "OBSOLETE",
TokenKind::KwMandatory => "MANDATORY",
TokenKind::KwOptional => "OPTIONAL",
TokenKind::KwReadOnly => "READ_ONLY",
TokenKind::KwReadWrite => "READ_WRITE",
TokenKind::KwReadCreate => "READ_CREATE",
TokenKind::KwWriteOnly => "WRITE_ONLY",
TokenKind::KwNotAccessible => "NOT_ACCESSIBLE",
TokenKind::KwAccessibleForNotify => "ACCESSIBLE_FOR_NOTIFY",
TokenKind::KwNotImplemented => "NOT_IMPLEMENTED",
}
}
}
impl std::fmt::Display for TokenKind {
/// Formats using the [`libsmi_name`](TokenKind::libsmi_name) representation.
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.libsmi_name())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn keyword_classification() {
assert!(TokenKind::KwDefinitions.is_keyword());
assert!(TokenKind::KwNotImplemented.is_keyword());
assert!(TokenKind::KwMacro.is_structural_keyword());
assert!(!TokenKind::KwSyntax.is_structural_keyword());
assert!(TokenKind::KwSyntax.is_clause_keyword());
assert!(TokenKind::KwVariables.is_clause_keyword());
assert!(!TokenKind::KwModuleIdentity.is_clause_keyword());
assert!(TokenKind::KwModuleIdentity.is_macro_keyword());
assert!(TokenKind::KwTrapType.is_macro_keyword());
assert!(TokenKind::KwInteger.is_type_keyword());
assert!(TokenKind::KwNetworkAddress.is_type_keyword());
assert!(TokenKind::KwApplication.is_tag_keyword());
assert!(TokenKind::KwUniversal.is_tag_keyword());
assert!(TokenKind::KwCurrent.is_status_access_keyword());
assert!(TokenKind::KwNotImplemented.is_status_access_keyword());
}
#[test]
fn non_keywords_are_not_keywords() {
assert!(!TokenKind::Error.is_keyword());
assert!(!TokenKind::UppercaseIdent.is_keyword());
assert!(!TokenKind::Number.is_keyword());
assert!(!TokenKind::LBrace.is_keyword());
assert!(!TokenKind::ColonColonEqual.is_keyword());
}
#[test]
fn identifier_classification() {
assert!(TokenKind::UppercaseIdent.is_identifier());
assert!(TokenKind::LowercaseIdent.is_identifier());
assert!(!TokenKind::KwObject.is_identifier());
assert!(!TokenKind::Number.is_identifier());
}
#[test]
fn libsmi_names() {
assert_eq!(TokenKind::Eof.libsmi_name(), "EOF");
assert_eq!(TokenKind::KwObjectType.libsmi_name(), "OBJECT_TYPE");
assert_eq!(
TokenKind::ColonColonEqual.libsmi_name(),
"COLON_COLON_EQUAL"
);
assert_eq!(TokenKind::KwReadOnly.libsmi_name(), "READ_ONLY");
}
}