1use oak_core::{SyntaxKind, Token};
2
3pub type DelphiToken = Token<DelphiSyntaxKind>;
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
8pub enum DelphiSyntaxKind {
9 Identifier,
11 String,
12 Number,
13 Whitespace,
14 Newline,
15
16 Program,
18 Unit,
19 Interface,
20 Implementation,
21 Uses,
22 Type,
23 Var,
24 Const,
25 Function,
26 Procedure,
27 Begin,
28 End,
29 If,
30 Then,
31 Else,
32 While,
33 Do,
34 For,
35 To,
36 Downto,
37 Repeat,
38 Until,
39 Case,
40 Of,
41 With,
42 Try,
43 Except,
44 Finally,
45 Raise,
46 Class,
47 Object,
48 Record,
49 Array,
50 Set,
51 File,
52 Packed,
53 String_,
54 Integer,
55 Real,
56 Boolean,
57 Char,
58 Pointer,
59 Nil,
60 True_,
61 False_,
62 And_,
63 Or_,
64 Not_,
65 Div,
66 Mod,
67 In_,
68 Is_,
69 As_,
70
71 Plus,
73 Minus,
74 Star,
75 Slash,
76 Equal,
77 NotEqual,
78 Less,
79 Greater,
80 LessEqual,
81 GreaterEqual,
82 Assign,
83 Dot,
84 DotDot,
85 Caret,
86 At,
87
88 LeftParen,
90 RightParen,
91 LeftBracket,
92 RightBracket,
93 Semicolon,
94 Comma,
95 Colon,
96
97 Comment,
99
100 Error,
102 Eof,
103}
104
105impl DelphiSyntaxKind {
106 pub fn is_keyword(&self) -> bool {
108 matches!(
109 self,
110 Self::Program
111 | Self::Unit
112 | Self::Interface
113 | Self::Implementation
114 | Self::Uses
115 | Self::Type
116 | Self::Var
117 | Self::Const
118 | Self::Function
119 | Self::Procedure
120 | Self::Begin
121 | Self::End
122 | Self::If
123 | Self::Then
124 | Self::Else
125 | Self::While
126 | Self::Do
127 | Self::For
128 | Self::To
129 | Self::Downto
130 | Self::Repeat
131 | Self::Until
132 | Self::Case
133 | Self::Of
134 | Self::With
135 | Self::Try
136 | Self::Except
137 | Self::Finally
138 | Self::Raise
139 | Self::Class
140 | Self::Object
141 | Self::Record
142 | Self::Array
143 | Self::Set
144 | Self::File
145 | Self::Packed
146 | Self::String_
147 | Self::Integer
148 | Self::Real
149 | Self::Boolean
150 | Self::Char
151 | Self::Pointer
152 | Self::Nil
153 | Self::True_
154 | Self::False_
155 | Self::And_
156 | Self::Or_
157 | Self::Not_
158 | Self::Div
159 | Self::Mod
160 | Self::In_
161 | Self::Is_
162 | Self::As_
163 )
164 }
165}
166
167impl SyntaxKind for DelphiSyntaxKind {
168 fn is_trivia(&self) -> bool {
169 matches!(self, Self::Whitespace | Self::Newline | Self::Comment)
170 }
171
172 fn is_comment(&self) -> bool {
173 matches!(self, Self::Comment)
174 }
175
176 fn is_whitespace(&self) -> bool {
177 matches!(self, Self::Whitespace | Self::Newline)
178 }
179
180 fn is_token_type(&self) -> bool {
181 !matches!(self, Self::Error | Self::Eof)
182 }
183
184 fn is_element_type(&self) -> bool {
185 false
186 }
187}