oak_fsharp/kind/
mod.rs

1use oak_core::SyntaxKind;
2use serde::Serialize;
3
4#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize)]
5pub enum FSharpSyntaxKind {
6    // 基础 tokens
7    Whitespace,
8    Newline,
9
10    // 标识符和字面
11    Identifier,
12    IntegerLiteral,
13    FloatLiteral,
14    StringLiteral,
15    CharLiteral,
16    BooleanLiteral,
17    UnitLiteral,
18
19    // 关键- 基础
20    Let,
21    Rec,
22    And,
23    In,
24    If,
25    Then,
26    Else,
27    Elif,
28    Match,
29    With,
30    When,
31    Function,
32    Fun,
33
34    // 关键- 类型
35    Type,
36    Val,
37    Mutable,
38    Of,
39    As,
40
41    // 关键- 模块和命名空
42    Module,
43    Namespace,
44    Open,
45
46    // 关键- 异常处理
47    Try,
48    Finally,
49    Exception,
50    Raise,
51    Failwith,
52
53    // 关键- 循环和控制流
54    For,
55    To,
56    Downto,
57    Do,
58    Done,
59    While,
60    Yield,
61    Return,
62
63    // 关键- 面向对象
64    Class,
65    Interface,
66    Inherit,
67    Abstract,
68    Override,
69    Default,
70    Member,
71    Static,
72    New,
73
74    // 关键- 其他
75    Lazy,
76    Async,
77    Seq,
78    Use,
79    Begin,
80    End,
81    Struct,
82    Sig,
83
84    // 关键字 - 布尔和特殊值
85    True,
86    False,
87    Null,
88    Or,
89
90    // 关键字 - 访问修饰符
91    Public,
92    Private,
93    Internal,
94
95    // 关键字 - 其他
96    Inline,
97    Extern,
98    Upcast,
99    Downcast,
100    Assert,
101    Global,
102    Base,
103    This,
104    Void,
105
106    // 类型关键字
107    Obj,
108    Unit,
109    Int,
110    Float,
111    String,
112    Bool,
113    Char,
114    Byte,
115    SByte,
116    Int16,
117    UInt16,
118    Int32,
119    UInt32,
120    Int64,
121    UInt64,
122    NativeInt,
123    UNativeInt,
124    Decimal,
125    BigInt,
126
127    // 运算- 算术
128    Plus,     // +
129    Minus,    // -
130    Star,     // *
131    Slash,    // /
132    Percent,  // %
133    StarStar, // **
134
135    // 运算- 比较
136    Equal,        // =
137    NotEqual,     // <>
138    LessThan,     // <
139    LessEqual,    // <=
140    GreaterThan,  // >
141    GreaterEqual, // >=
142
143    // 运算- 逻辑
144    AndAnd, // &&
145    OrOr,   // ||
146    Not,    // not
147
148    // 运算- 位运
149    BitwiseAnd, // &&&
150    BitwiseOr,  // |||
151    BitwiseXor, // ^^^
152    BitwiseNot, // ~~~
153    LeftShift,  // <<<
154    RightShift, // >>>
155
156    // 运算- 特殊
157    Arrow,       // ->
158    DoubleArrow, // =>
159    Pipe,        // |
160    PipeRight,   // |>
161    DoublePipe,  // ||
162    Cons,        // ::
163    At,          // @
164    Compose,     // >>
165    ComposeBack, // <<
166    Dollar,      // $
167
168    // 运算符 - 其他
169    LogicalAnd, // &&
170    LogicalOr,  // ||
171    Ampersand,  // &
172    Caret,      // ^
173    Tilde,      // ~
174    Less,       // <
175    Greater,    // >
176
177    // 分隔符
178    LeftParen,         // (
179    RightParen,        // )
180    LeftBracket,       // [
181    RightBracket,      // ]
182    LeftArrayBracket,  // [|
183    RightArrayBracket, // |]
184    LeftBrace,         // {
185    RightBrace,        // }
186    LeftAngle,         // <
187    RightAngle,        // >
188
189    // 标点符号
190    Comma,       // ,
191    Semicolon,   // ;
192    Colon,       // :
193    DoubleColon, // ::
194    Dot,         // .
195    Question,    // ?
196    Underscore,  // _
197    Apostrophe,  // '
198    Backtick,    // `
199    Hash,        // #
200
201    // 注释
202    LineComment,  // //
203    BlockComment, // (* *)
204
205    // 特殊
206    Error,
207    Eof,
208}
209
210impl SyntaxKind for FSharpSyntaxKind {
211    fn is_trivia(&self) -> bool {
212        matches!(self, Self::Whitespace | Self::Newline | Self::LineComment | Self::BlockComment)
213    }
214
215    fn is_comment(&self) -> bool {
216        matches!(self, Self::LineComment | Self::BlockComment)
217    }
218
219    fn is_whitespace(&self) -> bool {
220        matches!(self, Self::Whitespace | Self::Newline)
221    }
222
223    fn is_token_type(&self) -> bool {
224        !matches!(self, Self::Error | Self::Eof)
225    }
226
227    fn is_element_type(&self) -> bool {
228        false
229    }
230}