pub struct KindSet(/* private fields */);
Expand description
Match a token against one or more Kinds.
Each Kind represents the token “type”. KindSet is a bitmask of all possible Kinds. This is useful for efficiently comparing a token to see if it matches N token Kinds.
§Example
use css_lexer::*;
let mut lexer = Lexer::new(&EmptyAtomSet::ATOMS, "width: 1px");
// The first token is either an AtKeyword, Ident or Function:
assert_eq!(lexer.advance(), KindSet::new(&[Kind::AtKeyword, Kind::Ident, Kind::Function]));
Implementations§
Source§impl KindSet
impl KindSet
Sourcepub const TRIVIA: KindSet
pub const TRIVIA: KindSet
A KindSet that matches all trivia; Kind::Whitespace and Kind::Comment.
Sourcepub const WHITESPACE: KindSet
pub const WHITESPACE: KindSet
A KindSet that matches just Whitespace. This is the same as Kind::Whitespace but can be useful to apply to functions that expect a KindSet rather than Kind.
Sourcepub const COMMENTS: KindSet
pub const COMMENTS: KindSet
A KindSet that matches just Whitespace. This is the same as Kind::Comment but can be useful to apply to functions that expect a KindSet rather than Kind.
Sourcepub const RIGHT_CURLY_OR_SEMICOLON: KindSet
pub const RIGHT_CURLY_OR_SEMICOLON: KindSet
A KindSet that matches either Kind::RightCurly or Kind::Semicolon. This is useful for matching stop-tokens, for example checking the end of a declaration.
Sourcepub const LEFT_CURLY_OR_SEMICOLON: KindSet
pub const LEFT_CURLY_OR_SEMICOLON: KindSet
A KindSet that matches either Kind::LeftCurly or Kind::Semicolon. This is useful for matching stop-tokens, for example checking the end of an at-rule prelude.
Sourcepub const LEFT_CURLY_RIGHT_PAREN_OR_SEMICOLON: KindSet
pub const LEFT_CURLY_RIGHT_PAREN_OR_SEMICOLON: KindSet
A KindSet that matches either Kind::LeftCurly or Kind::RightParen or Kind::Semicolon. This is useful for matching stop-tokens, for example checking the end of a function.
Sourcepub const LEFT_CURLY_RIGHT_PAREN_COMMA_OR_SEMICOLON: KindSet
pub const LEFT_CURLY_RIGHT_PAREN_COMMA_OR_SEMICOLON: KindSet
A KindSet that matches either Kind::LeftCurly or Kind::RightParen or Kind::Comma or Kind::Semicolon. This is useful for matching stop-tokens, for example checking the end of a function or Selector.
Sourcepub const IDENT_LIKE: KindSet
pub const IDENT_LIKE: KindSet
A KindSet that matches either Kind::Ident, Kind::AtKeyword, Kind::Function, Kind::Hash.
Sourcepub const DELIM_LIKE: KindSet
pub const DELIM_LIKE: KindSet
A KindSet that matches any single character token, such as Kind::Delim or Kind::Colon - Kind::RightCurly.