1#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
2#[repr(u16)]
3pub enum SyntaxKind {
4 Error,
5 Whitespace,
6 Eof,
7 LineComment,
8 String,
9 Char,
10 EqEq,
11 Neq,
12 Ge,
13 Le,
14 Gt,
15 Lt,
16 And,
17 Or,
18 Comma,
19 Dot,
20 Semicolon,
21 Question,
22 Colon,
23 Ident,
24 TypedIdent,
25 TypeSpec,
26 IdentTypeSpec,
27 ArrayTypeSpec,
28 OptionTypeSpec,
29 TupleTypeSpec,
30 LetKw,
31 IfKw,
32 ElseKw,
33 WhileKw,
34 BreakKw,
35 ContinueKw,
36 FunKw,
37 TrueKw,
38 FalseKw,
39 NoneKw,
40 Equals,
41 Plus,
42 Minus,
43 Star,
44 Slash,
45 Percent,
46 Integer,
47 Float,
48 OpenParen,
49 CloseParen,
50 OpenBracket,
51 CloseBracket,
52 OpenBrace,
53 CloseBrace,
54 Root,
55 FuncDef,
56 ParamList,
57 NoneLiteral,
58 IntLiteral,
59 FloatLiteral,
60 BoolLiteral,
61 StringLiteral,
62 CharLiteral,
63 ArrayLiteral,
64 BinaryExpr,
65 PrefixExpr,
66 ParenExpr,
67 TupleExpr,
68 RefExpr,
69 IfExpr,
70 FnCallExpr,
71 IndexExpr,
72 BlockExpr,
73 Stmt,
74 EmptyStmt,
75 LetStmt,
76 WhileStmt,
77 BreakStmt,
78 ContinueStmt,
79 ExprStmt,
80}
81
82impl SyntaxKind {
83 pub fn is_eof(self) -> bool {
84 self == Self::Eof
85 }
86
87 pub fn is_error(self) -> bool {
88 self == Self::Error
89 }
90
91 pub fn is_trivia(self) -> bool {
92 matches!(self, SyntaxKind::Whitespace | SyntaxKind::LineComment)
93 }
94}
95
96impl From<SyntaxKind> for rowan::SyntaxKind {
97 fn from(kind: SyntaxKind) -> Self {
98 Self(kind as u16)
99 }
100}