pub enum Token<'a> {
Show 19 variants
Separator(char),
Paren(char),
Attribute,
Number(Result<Number, NumberError>),
Word(&'a str),
Operation(char),
LogicalOperation(char),
ShiftOperation(char),
AssignmentOperation(char),
IncrementOperation,
DecrementOperation,
Arrow,
TemplateArgsStart,
TemplateArgsEnd,
Unknown(char),
Trivia,
DocComment(&'a str),
ModuleDocComment(&'a str),
End,
}Variants§
Separator(char)
A separator character: :;,, and . when not part of a numeric
literal.
Paren(char)
A parenthesis-like character: ()[]{}, and also <>.
Note that <> representing template argument brackets are distinguished
using WGSL’s template list discovery algorithm, and are returned
as Token::TemplateArgsStart and Token::TemplateArgsEnd. That is,
we use Paren for <> when they are not parens.
Attribute
The attribute introduction character @.
Number(Result<Number, NumberError>)
A numeric literal, either integral or floating-point, including any type suffix.
Word(&'a str)
An identifier, possibly a reserved word.
Operation(char)
A miscellaneous single-character operator, like an arithmetic unary or
binary operator. This includes =, for assignment and initialization.
LogicalOperation(char)
Certain multi-character logical operators: !=, ==, &&,
||, <= and >=. The value gives the operator’s first
character.
For < and > operators, see Token::Paren.
ShiftOperation(char)
A shift operator: >> or <<.
AssignmentOperation(char)
A compound assignment operator like +=.
When the given character is < or >, those represent the left shift
and right shift assignment operators, <<= and >>=.
IncrementOperation
The ++ operator.
DecrementOperation
The -- operator.
Arrow
The -> token.
TemplateArgsStart
A < representing the start of a template argument list, according to
WGSL’s template list discovery algorithm.
TemplateArgsEnd
A > representing the end of a template argument list, according to
WGSL’s template list discovery algorithm.
Unknown(char)
A character that does not represent a legal WGSL token.
Trivia
Comment or whitespace.
DocComment(&'a str)
A doc comment, beginning with /// or /**.
ModuleDocComment(&'a str)
A module-level doc comment, beginning with //! or /*!.
End
The end of the input.