From 50a02eb3593591a02677e1b56f24d7ff0459b9d0 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 12 Aug 2020 17:06:49 +0200 Subject: Rename ra_parser -> parser --- crates/parser/src/syntax_kind.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 crates/parser/src/syntax_kind.rs (limited to 'crates/parser/src/syntax_kind.rs') 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 @@ +//! FIXME: write short doc here + +#[macro_use] +mod generated; + +pub use self::generated::SyntaxKind; + +impl From for SyntaxKind { + fn from(d: u16) -> SyntaxKind { + assert!(d <= (SyntaxKind::__LAST as u16)); + unsafe { std::mem::transmute::(d) } + } +} + +impl From for u16 { + fn from(k: SyntaxKind) -> u16 { + k as u16 + } +} + +impl SyntaxKind { + pub fn is_trivia(self) -> bool { + matches!(self, SyntaxKind::WHITESPACE | SyntaxKind::COMMENT) + } +} -- cgit v1.2.3