#[non_exhaustive]pub enum TokenRole {
}Expand description
What a token means when it is lowered on its own.
§Examples
use lower_lang::{Escapes, TokenRole};
let var = TokenRole::Var { sigil: 1 }; // `$name`, name `name`
let string = TokenRole::Str(Escapes::Standard);
assert_ne!(var, string);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Name
An identifier: a name, a variable reference, a binding, or a type name.
Var
A sigiled variable such as $x; the first sigil bytes are not part
of the name.
Label
A loop label such as 'outer.
Lifetime
A region (lifetime) such as 'a, as a generic parameter or argument.
Int
An integer literal (0x, 0o, 0b prefixes and _ separators
accepted; a registered suffix sets its type).
Float
A floating-point literal.
Number
A number: a float if it has a fraction or an exponent, else an integer.
Str(Escapes)
A string literal, quotes included in the token.
RawStr
A raw string literal, taken verbatim: optional ASCII prefix letters
(r, R, br), optional # fences, then one quote character (",
', or `), or a tripled one (""", Python), closed by the same
quote(s) and the same number of #s. Rust r#"a "b""#, Python
r'\d+'. Malformed fences are an
InvalidLiteral.
Heredoc(Escapes)
A PHP heredoc (Standard escapes) or nowdoc (None) as one token:
<<<ID (or <<<"ID", <<<'ID'), a newline, the body lines, and the
closing identifier on its own line. Per PHP 7.3+, the whitespace before
the closing identifier is removed from every body line (a line
indented less, or tabs mixed with spaces, is an
InvalidLiteral), and the newline
before the closing identifier is not part of the string. A heredoc
with interpolation is an Interp node instead.
StrPart(Escapes)
A literal piece of an interpolated string: the text between embedded expressions, without quotes; escapes decoded.
Char(Escapes)
A character literal, quotes included.
Bytes(Escapes)
A byte-string literal, quotes (and a leading b) included.
True
true.
False
false.
Null
null / nil / None-as-keyword.
Wild
_: a wildcard pattern, or an inferred type.
Rest
.. inside a pattern.
Type(TypeName)
A type keyword (int, mixed, Self, !).