pub enum Token {
Show 42 variants
Module,
Where,
Import,
As,
Exposing,
Type,
Alias,
Port,
If,
Then,
Else,
Case,
Of,
Let,
In,
Infix,
LeftParen,
RightParen,
LeftBracket,
RightBracket,
LeftBrace,
RightBrace,
Comma,
Pipe,
Equals,
Colon,
Dot,
DotDot,
Backslash,
Underscore,
Arrow,
Operator(String),
Minus,
LowerName(String),
UpperName(String),
Literal(Literal),
LineComment(String),
BlockComment(String),
DocComment(String),
Glsl(String),
Newline,
Eof,
}Expand description
A token produced by the Elm lexer.
Variants§
Module
module
Where
where
Import
import
As
as
Exposing
exposing
Type
type
Alias
alias
Port
port
If
if
Then
then
Else
else
Case
case
Of
of
Let
let
In
in
Infix
infix
LeftParen
(
RightParen
)
LeftBracket
[
RightBracket
]
LeftBrace
{
RightBrace
}
Comma
,
Pipe
|
Equals
=
Colon
:
Dot
.
DotDot
..
Backslash
\
Underscore
_
Arrow
->
Operator(String)
Any operator: +, -, *, /, //, ^, ++, ::, <|, |>,
>>, <<, ==, /=, <, >, <=, >=, &&, ||, </>, etc.
We store operators as strings rather than individual variants because
Elm’s operator set is extensible (via infix declarations in core
packages), and the parser handles precedence/associativity.
Minus
- when used as prefix negation (contextually disambiguated from
the - operator).
LowerName(String)
A lowercase identifier: foo, myFunction, x1
UpperName(String)
An uppercase identifier: Maybe, Cmd, Html
Literal(Literal)
A literal value (char, string, int, hex, float).
LineComment(String)
A single-line comment: -- ...
BlockComment(String)
A block comment: {- ... -} (may be nested)
DocComment(String)
A documentation comment: {-| ... -}
Glsl(String)
A GLSL shader block: [glsl| ... |]
Newline
A newline. The lexer emits these so the parser can track indentation-sensitive layout.
Eof
End of file.
Implementations§
Source§impl Token
impl Token
Sourcepub fn keyword(s: &str) -> Option<Token>
pub fn keyword(s: &str) -> Option<Token>
Look up a keyword from a lowercase identifier string.
Returns None if the string is not a keyword.
Sourcepub fn is_comment(&self) -> bool
pub fn is_comment(&self) -> bool
Returns true if this token is a comment.
Sourcepub fn is_whitespace(&self) -> bool
pub fn is_whitespace(&self) -> bool
Returns true if this token is whitespace or a newline.