aboutsummaryrefslogtreecommitdiff
path: root/crates/parser/src/syntax_kind.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/parser/src/syntax_kind.rs')
-rw-r--r--crates/parser/src/syntax_kind.rs25
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]
4mod generated;
5
6pub use self::generated::SyntaxKind;
7
8impl 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
15impl From<SyntaxKind> for u16 {
16 fn from(k: SyntaxKind) -> u16 {
17 k as u16
18 }
19}
20
21impl SyntaxKind {
22 pub fn is_trivia(self) -> bool {
23 matches!(self, SyntaxKind::WHITESPACE | SyntaxKind::COMMENT)
24 }
25}