pub enum Token {
Literal(Literal),
Identifier(Ident),
Punct {
op: PunctOp,
span: Span,
},
OpenDelim {
delimiter: Delimiter,
span: Span,
},
CloseDelim {
delimiter: Delimiter,
span: Span,
},
DocComment {
text: String,
inner: bool,
span: Span,
},
Error {
message: String,
span: Span,
},
}Expand description
A flattened token that represents elements from a TokenTree stream.
Groups are flattened into OpenDelim and CloseDelim tokens, making parsing simpler by removing nesting from the token stream.
§Examples
use cel_parser::lex_lexer::{LexLexer, Token};
let input: proc_macro2::TokenStream = "name".parse()?;
let token = LexLexer::new(input.into_iter()).next().unwrap();
assert!(matches!(token, Token::Identifier(id) if id == "name"));Variants§
Literal(Literal)
A literal value (integer, string, boolean, or float) with eager discrimination.
Identifier(Ident)
An identifier.
Punct
A punctuation operator storing all one to three characters inline.
OpenDelim
Opening delimiter (flattened from Group).
Fields
CloseDelim
Closing delimiter (flattened from Group).
Fields
DocComment
A recognized //////! doc comment, unwrapped from the #[doc = "..."]/
#![doc = "..."] attribute-shaped token sequence proc_macro2 produces for it. General
#[...] attribute syntax is not supported — see Token::Error.
Fields
Error
An unsupported attribute shape or a literal Syn cannot parse.
Trait Implementations§
Auto Trait Implementations§
impl !Send for Token
impl !Sync for Token
impl Freeze for Token
impl RefUnwindSafe for Token
impl Unpin for Token
impl UnsafeUnpin for Token
impl UnwindSafe for Token
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