use crate::prelude::Kw;
crate::define_tokens! {
#[macro_export]
pub macro Token in (::typeward::literals);
true => True #[doc = "The `true` boolean literal token."],
false => False #[doc = "The `false` boolean literal token."],
null => Null #[doc = "The `null` literal token."],
'(' => LParen #[doc = "The `(` left parenthesis token."],
')' => RParen #[doc = "The `)` right parenthesis token."],
'[' => LBracket #[doc = "The `[` left bracket token."],
']' => RBracket #[doc = "The `]` right bracket token."],
'{' => LBrace #[doc = "The `{` left brace token."],
'}' => RBrace #[doc = "The `}` right brace token."],
. => Dot #[doc = "The `.` dot token."],
, => Comma #[doc = "The `,` comma token."],
: => Colon #[doc = "The `:` colon token."],
; => Semi #[doc = "The `;` semicolon token."],
= => Eq #[doc = "The `=` equals token."],
+ => Plus #[doc = "The `+` plus token."],
- => Minus #[doc = "The `-` minus token."],
* => Star #[doc = "The `*` asterisk token."],
/ => Slash #[doc = "The `/` slash token."],
! => Bang #[doc = "The `!` exclamation token."],
& => Amp #[doc = "The `&` ampersand token."],
| => Pipe #[doc = "The `|` pipe token."],
< => Lt #[doc = "The `<` less-than token."],
> => Gt #[doc = "The `>` greater-than token."],
? => Question #[doc = "The `?` question mark token."],
@ => At #[doc = "The `@` at symbol token."],
# => Hash #[doc = "The `#` hash symbol token."],
$ => Dollar #[doc = "The `$` dollar sign token."],
% => Percent #[doc = "The `%` percent sign token."],
^ => Caret #[doc = "The `^` caret token."],
'\t' => Tab #[doc = "The `\\t` tab character token."],
'\n' => Newline #[doc = "The `\\n` newline character token."],
'\r' => CarriageReturn #[doc = "The `\\r` carriage return character token."],
'\0' => NullChar #[doc = "The `\\0` null character token."],
'\\' => Backslash #[doc = "The `\\\\` backslash character token."],
'"' => DoubleQuote #[doc = "The `\\\"` double quote character token."],
"\r\n" => CrLf #[doc = "The `\\r\\n` CRLF newline sequence token."],
' ' => Space #[doc = "The ` ` space character token."],
}
macro_rules! define_char_tokens {
($($ch:ident),* $(,)?) => {
pastey::paste! {
crate::define_tokens! {
#[doc(hidden)]
pub macro CharToken in (::typeward::literals);
$(
$ch => [<$ch Char>] #[allow(non_camel_case_types)],
)*
}
}
};
}
define_char_tokens!(
a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, B, C, D, E, F,
G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z
);
pub type KwTrue = Kw<Token![true]>;
pub type KwFalse = Kw<Token![false]>;
pub type KwNull = Kw<Token![null]>;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn lookup_macros_resolve_tokens() {
assert_eq!(Token![null], Null);
assert_eq!(Token!['('], LParen);
assert_eq!(Token![!], Bang);
assert_eq!(CharToken![a], aChar);
}
}