diff options
Diffstat (limited to 'crates/parser/src/syntax_kind.rs')
-rw-r--r-- | crates/parser/src/syntax_kind.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/crates/parser/src/syntax_kind.rs b/crates/parser/src/syntax_kind.rs new file mode 100644 index 000000000..63204436c --- /dev/null +++ b/crates/parser/src/syntax_kind.rs | |||
@@ -0,0 +1,25 @@ | |||
1 | //! FIXME: write short doc here | ||
2 | |||
3 | #[macro_use] | ||
4 | mod generated; | ||
5 | |||
6 | pub use self::generated::SyntaxKind; | ||
7 | |||
8 | impl From<u16> for SyntaxKind { | ||
9 | fn from(d: u16) -> SyntaxKind { | ||
10 | assert!(d <= (SyntaxKind::__LAST as u16)); | ||
11 | unsafe { std::mem::transmute::<u16, SyntaxKind>(d) } | ||
12 | } | ||
13 | } | ||
14 | |||
15 | impl From<SyntaxKind> for u16 { | ||
16 | fn from(k: SyntaxKind) -> u16 { | ||
17 | k as u16 | ||
18 | } | ||
19 | } | ||
20 | |||
21 | impl SyntaxKind { | ||
22 | pub fn is_trivia(self) -> bool { | ||
23 | matches!(self, SyntaxKind::WHITESPACE | SyntaxKind::COMMENT) | ||
24 | } | ||
25 | } | ||