oak_solidity/kind/
mod.rs

1#[derive(Copy, Clone, Debug, PartialEq, Eq)]
2pub enum SoliditySyntaxKind {
3    // 空白和换
4    Whitespace,
5    Newline,
6
7    // 注释
8    LineComment,
9    BlockComment,
10
11    // 关键
12    Contract,
13    Interface,
14    Library,
15    Function,
16    Modifier,
17    Event,
18    Struct,
19    Enum,
20    Mapping,
21    Array,
22
23    // 可见性修饰符
24    Public,
25    Private,
26    Internal,
27    External,
28
29    // 状态修饰符
30    Pure,
31    View,
32    Payable,
33    Constant,
34
35    // 类型关键
36    Bool,
37    String,
38    Bytes,
39    Address,
40    Uint,
41    Int,
42    Fixed,
43    Ufixed,
44
45    // 控制
46    If,
47    Else,
48    For,
49    While,
50    Do,
51    Break,
52    Continue,
53    Return,
54    Try,
55    Catch,
56
57    // 其他关键
58    Import,
59    Pragma,
60    Using,
61    Is,
62    Override,
63    Virtual,
64    Abstract,
65
66    // 字面
67    NumberLiteral,
68    StringLiteral,
69    BooleanLiteral,
70    AddressLiteral,
71    HexLiteral,
72
73    // 标识
74    Identifier,
75
76    // 操作
77    Plus,
78    Minus,
79    Star,
80    Slash,
81    Percent,
82    Power,
83    Equal,
84    NotEqual,
85    Less,
86    Greater,
87    LessEqual,
88    GreaterEqual,
89    And,
90    Or,
91    Not,
92    BitAnd,
93    BitOr,
94    BitXor,
95    BitNot,
96    LeftShift,
97    RightShift,
98    Assign,
99    PlusAssign,
100    MinusAssign,
101    StarAssign,
102    SlashAssign,
103    PercentAssign,
104
105    // 分隔
106    LeftParen,
107    RightParen,
108    LeftBrace,
109    RightBrace,
110    LeftBracket,
111    RightBracket,
112    Semicolon,
113    Comma,
114    Dot,
115    Arrow,
116
117    // 特殊
118    Error,
119    Eof,
120}
121
122impl oak_core::SyntaxKind for SoliditySyntaxKind {
123    fn is_trivia(&self) -> bool {
124        matches!(self, Self::Whitespace | Self::Newline | Self::LineComment | Self::BlockComment)
125    }
126
127    fn is_comment(&self) -> bool {
128        matches!(self, Self::LineComment | Self::BlockComment)
129    }
130
131    fn is_whitespace(&self) -> bool {
132        matches!(self, Self::Whitespace | Self::Newline)
133    }
134
135    fn is_token_type(&self) -> bool {
136        !matches!(self, Self::Error | Self::Eof)
137    }
138
139    fn is_element_type(&self) -> bool {
140        false
141    }
142}