syntax/ast/generated/
tokens.rs1use crate::{
4 SyntaxKind::{self, *},
5 SyntaxToken,
6 ast::AstToken,
7};
8use std::{fmt, hash};
9pub struct Byte {
10 pub(crate) syntax: SyntaxToken,
11}
12impl std::fmt::Display for Byte {
13 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14 std::fmt::Display::fmt(&self.syntax, f)
15 }
16}
17impl AstToken for Byte {
18 fn can_cast(kind: SyntaxKind) -> bool { kind == BYTE }
19 fn cast(syntax: SyntaxToken) -> Option<Self> {
20 if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
21 }
22 fn syntax(&self) -> &SyntaxToken { &self.syntax }
23}
24impl fmt::Debug for Byte {
25 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
26 f.debug_struct("Byte").field("syntax", &self.syntax).finish()
27 }
28}
29impl Clone for Byte {
30 fn clone(&self) -> Self { Self { syntax: self.syntax.clone() } }
31}
32impl hash::Hash for Byte {
33 fn hash<H: hash::Hasher>(&self, state: &mut H) { self.syntax.hash(state); }
34}
35impl Eq for Byte {}
36impl PartialEq for Byte {
37 fn eq(&self, other: &Self) -> bool { self.syntax == other.syntax }
38}
39pub struct ByteString {
40 pub(crate) syntax: SyntaxToken,
41}
42impl std::fmt::Display for ByteString {
43 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
44 std::fmt::Display::fmt(&self.syntax, f)
45 }
46}
47impl AstToken for ByteString {
48 fn can_cast(kind: SyntaxKind) -> bool { kind == BYTE_STRING }
49 fn cast(syntax: SyntaxToken) -> Option<Self> {
50 if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
51 }
52 fn syntax(&self) -> &SyntaxToken { &self.syntax }
53}
54impl fmt::Debug for ByteString {
55 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
56 f.debug_struct("ByteString").field("syntax", &self.syntax).finish()
57 }
58}
59impl Clone for ByteString {
60 fn clone(&self) -> Self { Self { syntax: self.syntax.clone() } }
61}
62impl hash::Hash for ByteString {
63 fn hash<H: hash::Hasher>(&self, state: &mut H) { self.syntax.hash(state); }
64}
65impl Eq for ByteString {}
66impl PartialEq for ByteString {
67 fn eq(&self, other: &Self) -> bool { self.syntax == other.syntax }
68}
69pub struct CString {
70 pub(crate) syntax: SyntaxToken,
71}
72impl std::fmt::Display for CString {
73 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
74 std::fmt::Display::fmt(&self.syntax, f)
75 }
76}
77impl AstToken for CString {
78 fn can_cast(kind: SyntaxKind) -> bool { kind == C_STRING }
79 fn cast(syntax: SyntaxToken) -> Option<Self> {
80 if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
81 }
82 fn syntax(&self) -> &SyntaxToken { &self.syntax }
83}
84impl fmt::Debug for CString {
85 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
86 f.debug_struct("CString").field("syntax", &self.syntax).finish()
87 }
88}
89impl Clone for CString {
90 fn clone(&self) -> Self { Self { syntax: self.syntax.clone() } }
91}
92impl hash::Hash for CString {
93 fn hash<H: hash::Hasher>(&self, state: &mut H) { self.syntax.hash(state); }
94}
95impl Eq for CString {}
96impl PartialEq for CString {
97 fn eq(&self, other: &Self) -> bool { self.syntax == other.syntax }
98}
99pub struct Char {
100 pub(crate) syntax: SyntaxToken,
101}
102impl std::fmt::Display for Char {
103 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
104 std::fmt::Display::fmt(&self.syntax, f)
105 }
106}
107impl AstToken for Char {
108 fn can_cast(kind: SyntaxKind) -> bool { kind == CHAR }
109 fn cast(syntax: SyntaxToken) -> Option<Self> {
110 if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
111 }
112 fn syntax(&self) -> &SyntaxToken { &self.syntax }
113}
114impl fmt::Debug for Char {
115 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
116 f.debug_struct("Char").field("syntax", &self.syntax).finish()
117 }
118}
119impl Clone for Char {
120 fn clone(&self) -> Self { Self { syntax: self.syntax.clone() } }
121}
122impl hash::Hash for Char {
123 fn hash<H: hash::Hasher>(&self, state: &mut H) { self.syntax.hash(state); }
124}
125impl Eq for Char {}
126impl PartialEq for Char {
127 fn eq(&self, other: &Self) -> bool { self.syntax == other.syntax }
128}
129pub struct Comment {
130 pub(crate) syntax: SyntaxToken,
131}
132impl std::fmt::Display for Comment {
133 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
134 std::fmt::Display::fmt(&self.syntax, f)
135 }
136}
137impl AstToken for Comment {
138 fn can_cast(kind: SyntaxKind) -> bool { kind == COMMENT }
139 fn cast(syntax: SyntaxToken) -> Option<Self> {
140 if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
141 }
142 fn syntax(&self) -> &SyntaxToken { &self.syntax }
143}
144impl fmt::Debug for Comment {
145 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
146 f.debug_struct("Comment").field("syntax", &self.syntax).finish()
147 }
148}
149impl Clone for Comment {
150 fn clone(&self) -> Self { Self { syntax: self.syntax.clone() } }
151}
152impl hash::Hash for Comment {
153 fn hash<H: hash::Hasher>(&self, state: &mut H) { self.syntax.hash(state); }
154}
155impl Eq for Comment {}
156impl PartialEq for Comment {
157 fn eq(&self, other: &Self) -> bool { self.syntax == other.syntax }
158}
159pub struct FloatNumber {
160 pub(crate) syntax: SyntaxToken,
161}
162impl std::fmt::Display for FloatNumber {
163 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
164 std::fmt::Display::fmt(&self.syntax, f)
165 }
166}
167impl AstToken for FloatNumber {
168 fn can_cast(kind: SyntaxKind) -> bool { kind == FLOAT_NUMBER }
169 fn cast(syntax: SyntaxToken) -> Option<Self> {
170 if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
171 }
172 fn syntax(&self) -> &SyntaxToken { &self.syntax }
173}
174impl fmt::Debug for FloatNumber {
175 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
176 f.debug_struct("FloatNumber").field("syntax", &self.syntax).finish()
177 }
178}
179impl Clone for FloatNumber {
180 fn clone(&self) -> Self { Self { syntax: self.syntax.clone() } }
181}
182impl hash::Hash for FloatNumber {
183 fn hash<H: hash::Hasher>(&self, state: &mut H) { self.syntax.hash(state); }
184}
185impl Eq for FloatNumber {}
186impl PartialEq for FloatNumber {
187 fn eq(&self, other: &Self) -> bool { self.syntax == other.syntax }
188}
189pub struct Ident {
190 pub(crate) syntax: SyntaxToken,
191}
192impl std::fmt::Display for Ident {
193 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
194 std::fmt::Display::fmt(&self.syntax, f)
195 }
196}
197impl AstToken for Ident {
198 fn can_cast(kind: SyntaxKind) -> bool { kind == IDENT }
199 fn cast(syntax: SyntaxToken) -> Option<Self> {
200 if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
201 }
202 fn syntax(&self) -> &SyntaxToken { &self.syntax }
203}
204impl fmt::Debug for Ident {
205 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
206 f.debug_struct("Ident").field("syntax", &self.syntax).finish()
207 }
208}
209impl Clone for Ident {
210 fn clone(&self) -> Self { Self { syntax: self.syntax.clone() } }
211}
212impl hash::Hash for Ident {
213 fn hash<H: hash::Hasher>(&self, state: &mut H) { self.syntax.hash(state); }
214}
215impl Eq for Ident {}
216impl PartialEq for Ident {
217 fn eq(&self, other: &Self) -> bool { self.syntax == other.syntax }
218}
219pub struct IntNumber {
220 pub(crate) syntax: SyntaxToken,
221}
222impl std::fmt::Display for IntNumber {
223 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
224 std::fmt::Display::fmt(&self.syntax, f)
225 }
226}
227impl AstToken for IntNumber {
228 fn can_cast(kind: SyntaxKind) -> bool { kind == INT_NUMBER }
229 fn cast(syntax: SyntaxToken) -> Option<Self> {
230 if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
231 }
232 fn syntax(&self) -> &SyntaxToken { &self.syntax }
233}
234impl fmt::Debug for IntNumber {
235 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
236 f.debug_struct("IntNumber").field("syntax", &self.syntax).finish()
237 }
238}
239impl Clone for IntNumber {
240 fn clone(&self) -> Self { Self { syntax: self.syntax.clone() } }
241}
242impl hash::Hash for IntNumber {
243 fn hash<H: hash::Hasher>(&self, state: &mut H) { self.syntax.hash(state); }
244}
245impl Eq for IntNumber {}
246impl PartialEq for IntNumber {
247 fn eq(&self, other: &Self) -> bool { self.syntax == other.syntax }
248}
249pub struct String {
250 pub(crate) syntax: SyntaxToken,
251}
252impl std::fmt::Display for String {
253 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
254 std::fmt::Display::fmt(&self.syntax, f)
255 }
256}
257impl AstToken for String {
258 fn can_cast(kind: SyntaxKind) -> bool { kind == STRING }
259 fn cast(syntax: SyntaxToken) -> Option<Self> {
260 if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
261 }
262 fn syntax(&self) -> &SyntaxToken { &self.syntax }
263}
264impl fmt::Debug for String {
265 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
266 f.debug_struct("String").field("syntax", &self.syntax).finish()
267 }
268}
269impl Clone for String {
270 fn clone(&self) -> Self { Self { syntax: self.syntax.clone() } }
271}
272impl hash::Hash for String {
273 fn hash<H: hash::Hasher>(&self, state: &mut H) { self.syntax.hash(state); }
274}
275impl Eq for String {}
276impl PartialEq for String {
277 fn eq(&self, other: &Self) -> bool { self.syntax == other.syntax }
278}
279pub struct Whitespace {
280 pub(crate) syntax: SyntaxToken,
281}
282impl std::fmt::Display for Whitespace {
283 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
284 std::fmt::Display::fmt(&self.syntax, f)
285 }
286}
287impl AstToken for Whitespace {
288 fn can_cast(kind: SyntaxKind) -> bool { kind == WHITESPACE }
289 fn cast(syntax: SyntaxToken) -> Option<Self> {
290 if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
291 }
292 fn syntax(&self) -> &SyntaxToken { &self.syntax }
293}
294impl fmt::Debug for Whitespace {
295 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
296 f.debug_struct("Whitespace").field("syntax", &self.syntax).finish()
297 }
298}
299impl Clone for Whitespace {
300 fn clone(&self) -> Self { Self { syntax: self.syntax.clone() } }
301}
302impl hash::Hash for Whitespace {
303 fn hash<H: hash::Hasher>(&self, state: &mut H) { self.syntax.hash(state); }
304}
305impl Eq for Whitespace {}
306impl PartialEq for Whitespace {
307 fn eq(&self, other: &Self) -> bool { self.syntax == other.syntax }
308}