pub enum TokenPattern {
Exact(TokenKind),
Category(TokenCategory),
Any,
Optional(Box<TokenPattern>),
Sequence(Vec<TokenPattern>),
Alternatives(Vec<TokenPattern>),
}Expand description
A simple pattern for matching token sequences.
Variants§
Exact(TokenKind)
Match a specific token kind.
Category(TokenCategory)
Match any token in the given category.
Any
Match any token (wildcard).
Optional(Box<TokenPattern>)
Match an optional token.
Sequence(Vec<TokenPattern>)
Match a sequence of patterns.
Alternatives(Vec<TokenPattern>)
Match one of the alternatives.
Implementations§
Source§impl TokenPattern
impl TokenPattern
Sourcepub fn matches_single(&self, tok: &Token) -> bool
pub fn matches_single(&self, tok: &Token) -> bool
Check if a single token matches this pattern (non-recursive).
Trait Implementations§
Source§impl Clone for TokenPattern
impl Clone for TokenPattern
Source§fn clone(&self) -> TokenPattern
fn clone(&self) -> TokenPattern
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TokenPattern
impl RefUnwindSafe for TokenPattern
impl Send for TokenPattern
impl Sync for TokenPattern
impl Unpin for TokenPattern
impl UnsafeUnpin for TokenPattern
impl UnwindSafe for TokenPattern
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more