oak_zig/kind/
mod.rs

1#[derive(Copy, Clone, Debug, PartialEq, Eq)]
2pub enum ZigSyntaxKind {
3    // 基础 kind
4    Whitespace,
5    Newline,
6    Comment,
7    Error,
8    Eof,
9
10    // 字面量
11    Identifier,
12    StringLiteral,
13    CharLiteral,
14    IntegerLiteral,
15    FloatLiteral,
16    BooleanLiteral,
17
18    // Zig 关键- 基本结构
19    Const,
20    Var,
21    Fn,
22    Struct,
23    Union,
24    Enum,
25    Opaque,
26    Type,
27    Comptime,
28    Inline,
29    NoInline,
30    Pub,
31    Export,
32    Extern,
33    Packed,
34    Align,
35    CallConv,
36    LinkSection,
37
38    // Zig 关键字 - 控制流
39    If,
40    Else,
41    Switch,
42    While,
43    For,
44    Break,
45    Continue,
46    Return,
47    Defer,
48    ErrDefer,
49    Unreachable,
50    NoReturn,
51
52    // Zig 关键字 - 错误处理
53    ErrorKeyword,
54
55    // Zig 关键字 - 测试和异步
56    Test,
57    Async,
58    Await,
59    Suspend,
60    Resume,
61    Cancel,
62
63    // Zig 关键- 内存管理
64    Undefined,
65    Null,
66    Volatile,
67    AllowZero,
68    NoAlias,
69
70    // Zig 关键- 其他
71    And,
72    Or,
73    AnyFrame,
74    AnyType,
75    ThreadLocal,
76
77    // 基本类型
78    Bool,
79    I8,
80    I16,
81    I32,
82    I64,
83    I128,
84    Isize,
85    U8,
86    U16,
87    U32,
88    U64,
89    U128,
90    Usize,
91    F16,
92    F32,
93    F64,
94    F80,
95    F128,
96    C_Short,
97    C_UShort,
98    C_Int,
99    C_UInt,
100    C_Long,
101    C_ULong,
102    C_LongLong,
103    C_ULongLong,
104    C_LongDouble,
105    C_Void,
106    Void,
107    Comptime_Int,
108    Comptime_Float,
109
110    // 操作符
111    Plus,         // +
112    Minus,        // -
113    Star,         // *
114    Slash,        // /
115    Percent,      // %
116    StarStar,     // **
117    PlusPercent,  // +%
118    MinusPercent, // -%
119    StarPercent,  // *%
120    PlusPlus,     // ++
121
122    // 位操作符
123    Ampersand,      // &
124    Pipe,           // |
125    Caret,          // ^
126    Tilde,          // ~
127    LessLess,       // <<
128    GreaterGreater, // >>
129
130    // 比较操作符
131    Equal,        // ==
132    NotEqual,     // !=
133    Less,         // <
134    Greater,      // >
135    LessEqual,    // <=
136    GreaterEqual, // >=
137
138    // 逻辑操作    AndAnd,         // and
139    OrOr, // or
140
141    // 赋值操作符
142    Assign,               // =
143    PlusAssign,           // +=
144    MinusAssign,          // -=
145    StarAssign,           // *=
146    SlashAssign,          // /=
147    PercentAssign,        // %=
148    AmpersandAssign,      // &=
149    PipeAssign,           // |=
150    CaretAssign,          // ^=
151    LessLessAssign,       // <<=
152    GreaterGreaterAssign, // >>=
153
154    // 标点符号
155    LeftParen,    // (
156    RightParen,   // )
157    LeftBrace,    // {
158    RightBrace,   // }
159    LeftBracket,  // [
160    RightBracket, // ]
161    Semicolon,    // ;
162    Comma,        // ,
163    Dot,          // .
164    DotDot,       // ..
165    DotDotDot,    // ...
166    Colon,        // :
167    Question,     // ?
168    Exclamation,  // !
169    Arrow,        // =>
170    FatArrow,     // =>
171
172    // 特殊操作符
173    OrElse,       // orelse
174    CatchKeyword, // catch
175    TryKeyword,   // try
176    AwaitKeyword, // await
177
178    // 内置函数前缀
179    At, // @
180
181    // 字符串插    StringStart,
182    StringEnd,
183    StringContent,
184    InterpolationStart,
185    InterpolationEnd,
186
187    // 多行字符    MultilineStringStart,
188    MultilineStringEnd,
189    MultilineStringContent,
190
191    // 文档注释
192    DocComment,
193
194    // 编译时指    CompileDirective,
195
196    // 其他
197    Text,
198}
199
200impl oak_core::SyntaxKind for ZigSyntaxKind {
201    fn is_trivia(&self) -> bool {
202        matches!(self, Self::Whitespace | Self::Newline | Self::Comment | Self::DocComment)
203    }
204
205    fn is_comment(&self) -> bool {
206        matches!(self, Self::Comment | Self::DocComment)
207    }
208
209    fn is_whitespace(&self) -> bool {
210        matches!(self, Self::Whitespace | Self::Newline)
211    }
212
213    fn is_token_type(&self) -> bool {
214        !matches!(self, Self::Text)
215    }
216
217    fn is_element_type(&self) -> bool {
218        matches!(self, Self::Text)
219    }
220}