return expr
This commit is contained in:
@@ -3,22 +3,22 @@ use {
|
||||
SyntaxKind::{self, ERROR},
|
||||
};
|
||||
|
||||
pub(crate) struct TokenSet {
|
||||
pub tokens: &'static [SyntaxKind],
|
||||
#[derive(Clone, Copy)]
|
||||
pub(crate) struct TokenSet(pub(crate) u128);
|
||||
fn mask(kind: SyntaxKind) -> u128 {
|
||||
1u128 << (kind as usize)
|
||||
}
|
||||
|
||||
impl TokenSet {
|
||||
pub fn contains(&self, kind: SyntaxKind) -> bool {
|
||||
self.tokens.contains(&kind)
|
||||
self.0 & mask(kind) != 0
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! token_set {
|
||||
($($t:ident),*) => {
|
||||
TokenSet {
|
||||
tokens: &[$($t),*],
|
||||
}
|
||||
TokenSet($(1u128 << ($t as usize))|*)
|
||||
};
|
||||
|
||||
($($t:ident),* ,) => {
|
||||
@@ -26,6 +26,17 @@ macro_rules! token_set {
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! token_set_union {
|
||||
($($ts:expr),*) => {
|
||||
TokenSet($($ts.0)|*)
|
||||
};
|
||||
|
||||
($($ts:expr),* ,) => {
|
||||
token_set_union!($($ts),*)
|
||||
};
|
||||
}
|
||||
|
||||
/// `Parser` struct provides the low-level API for
|
||||
/// navigating through the stream of tokens and
|
||||
/// constructing the parse tree. The actual parsing
|
||||
|
||||
Reference in New Issue
Block a user