diff options
Diffstat (limited to 'src/tree.rs')
-rw-r--r-- | src/tree.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/tree.rs b/src/tree.rs new file mode 100644 index 000000000..0924f38d0 --- /dev/null +++ b/src/tree.rs | |||
@@ -0,0 +1,31 @@ | |||
1 | use text::{TextUnit}; | ||
2 | use syntax_kinds::syntax_info; | ||
3 | |||
4 | use std::fmt; | ||
5 | |||
6 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
7 | pub struct SyntaxKind(pub(crate) u32); | ||
8 | |||
9 | impl SyntaxKind { | ||
10 | fn info(self) -> &'static SyntaxInfo { | ||
11 | syntax_info(self) | ||
12 | } | ||
13 | } | ||
14 | |||
15 | impl fmt::Debug for SyntaxKind { | ||
16 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
17 | let name = self.info().name; | ||
18 | f.write_str(name) | ||
19 | } | ||
20 | } | ||
21 | |||
22 | |||
23 | pub(crate) struct SyntaxInfo { | ||
24 | pub name: &'static str, | ||
25 | } | ||
26 | |||
27 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
28 | pub struct Token { | ||
29 | pub kind: SyntaxKind, | ||
30 | pub len: TextUnit, | ||
31 | } \ No newline at end of file | ||