1use oak_core::{SyntaxKind, Token};
2use serde::{Deserialize, Serialize};
3
4pub type MsilToken = Token<MsilSyntaxKind>;
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
8pub enum MsilSyntaxKind {
9 Root,
11 Assembly,
12 Module,
13 Class,
14 Method,
15 Instruction,
16 Label,
17 Directive,
18 Type,
19 Identifier,
20 Number,
21 String,
22 Comment,
23 ErrorNode,
24
25 AssemblyKeyword, ExternKeyword, ModuleKeyword, ClassKeyword, MethodKeyword, PublicKeyword, PrivateKeyword, StaticKeyword, LeftBrace, RightBrace, LeftParen, RightParen, LeftBracket, RightBracket, Dot, Colon, Semicolon, Comma, IdentifierToken,
49 NumberToken,
50 StringToken,
51
52 Whitespace,
54 CommentToken,
55 Eof,
56 Error,
57}
58
59impl SyntaxKind for MsilSyntaxKind {
60 fn is_trivia(&self) -> bool {
61 matches!(self, Self::Whitespace | Self::CommentToken)
62 }
63
64 fn is_comment(&self) -> bool {
65 matches!(self, Self::CommentToken)
66 }
67
68 fn is_whitespace(&self) -> bool {
69 matches!(self, Self::Whitespace)
70 }
71
72 fn is_token_type(&self) -> bool {
73 !matches!(
74 self,
75 Self::Root
76 | Self::Assembly
77 | Self::Module
78 | Self::Class
79 | Self::Method
80 | Self::Instruction
81 | Self::Label
82 | Self::Directive
83 | Self::Type
84 | Self::ErrorNode
85 )
86 }
87
88 fn is_element_type(&self) -> bool {
89 matches!(
90 self,
91 Self::Root
92 | Self::Assembly
93 | Self::Module
94 | Self::Class
95 | Self::Method
96 | Self::Instruction
97 | Self::Label
98 | Self::Directive
99 | Self::Type
100 | Self::ErrorNode
101 )
102 }
103}