diff options
author | Igor Aleksanov <[email protected]> | 2020-08-14 05:34:07 +0100 |
---|---|---|
committer | Igor Aleksanov <[email protected]> | 2020-08-14 05:34:07 +0100 |
commit | c26c911ec1e6c2ad1dcb7d155a6a1d528839ad1a (patch) | |
tree | 7cff36c38234be0afb65273146d8247083a5cfeb /crates/parser/src/syntax_kind.rs | |
parent | 3c018bf84de5c693b5ee1c6bec0fed3b201c2060 (diff) | |
parent | f1f73649a686dc6e6449afc35e0fa6fed00e225d (diff) |
Merge branch 'master' into add-disable-diagnostics
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 | } | ||