Expand description
§Literify
Stringifies (and concats) literal within the passed token stream inside ~()
group. It is also possible to concaternate with other strings inside the group.
This can be useful when you need to stringify a literal for a use in macro,
but macro expects a literal token tree, so usage of stringify!
is not possible.
§Example
use logos::Logos;
literify::literify! {
#[derive(Debug, PartialEq, Logos)]
enum Token {
#[token(~("amog" u s))]
Amogus,
#[token(~(.))]
Dot,
}
}
let mut lexer = Token::lexer("amogus.");
assert_eq!(
lexer.next(),
Some(Ok(Token::Amogus)),
);
assert_eq!(
lexer.next(),
Some(Ok(Token::Dot)),
)
Macros§
- literify
- Stringify (and concat, also with strings) identifiers inside token stream