syntax/ast/generated/
tokens.rs

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