2022-06-18 21:56:31 -07:00
|
|
|
use super::*;
|
2019-04-15 22:40:02 -07:00
|
|
|
|
2019-11-07 10:55:15 -08:00
|
|
|
#[derive(Debug, PartialEq, Clone, Copy, Ord, PartialOrd, Eq)]
|
2019-09-21 15:35:03 -07:00
|
|
|
pub(crate) enum TokenKind {
|
2021-07-22 00:20:25 -07:00
|
|
|
AmpersandAmpersand,
|
2020-06-13 01:49:13 -07:00
|
|
|
Asterisk,
|
2019-04-15 22:40:02 -07:00
|
|
|
At,
|
2021-04-05 21:28:37 -07:00
|
|
|
Backtick,
|
2020-10-26 18:16:42 -07:00
|
|
|
BangEquals,
|
|
|
|
BraceL,
|
|
|
|
BraceR,
|
2019-11-10 23:17:47 -08:00
|
|
|
BracketL,
|
|
|
|
BracketR,
|
2021-11-04 21:35:57 -07:00
|
|
|
ByteOrderMark,
|
2019-04-15 22:40:02 -07:00
|
|
|
Colon,
|
2019-04-18 11:48:02 -07:00
|
|
|
ColonEquals,
|
2019-04-15 22:40:02 -07:00
|
|
|
Comma,
|
|
|
|
Comment,
|
|
|
|
Dedent,
|
2021-03-25 18:35:24 -07:00
|
|
|
Dollar,
|
2019-04-15 22:40:02 -07:00
|
|
|
Eof,
|
|
|
|
Eol,
|
|
|
|
Equals,
|
2020-10-26 18:16:42 -07:00
|
|
|
EqualsEquals,
|
2021-09-16 16:45:56 -07:00
|
|
|
EqualsTilde,
|
2019-11-07 10:55:15 -08:00
|
|
|
Identifier,
|
2019-04-15 22:40:02 -07:00
|
|
|
Indent,
|
|
|
|
InterpolationEnd,
|
|
|
|
InterpolationStart,
|
|
|
|
ParenL,
|
|
|
|
ParenR,
|
|
|
|
Plus,
|
2022-06-25 02:39:06 -07:00
|
|
|
Slash,
|
2021-04-05 21:28:37 -07:00
|
|
|
StringToken,
|
2019-04-15 22:40:02 -07:00
|
|
|
Text,
|
2019-11-13 19:32:50 -08:00
|
|
|
Unspecified,
|
2019-04-15 22:40:02 -07:00
|
|
|
Whitespace,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Display for TokenKind {
|
|
|
|
fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
|
|
|
|
use TokenKind::*;
|
2021-09-16 06:44:40 -07:00
|
|
|
write!(
|
|
|
|
f,
|
|
|
|
"{}",
|
|
|
|
match *self {
|
|
|
|
AmpersandAmpersand => "'&&'",
|
|
|
|
Asterisk => "'*'",
|
|
|
|
At => "'@'",
|
|
|
|
Backtick => "backtick",
|
|
|
|
BangEquals => "'!='",
|
|
|
|
BraceL => "'{'",
|
|
|
|
BraceR => "'}'",
|
|
|
|
BracketL => "'['",
|
|
|
|
BracketR => "']'",
|
2021-11-04 21:35:57 -07:00
|
|
|
ByteOrderMark => "byte order mark",
|
2021-09-16 06:44:40 -07:00
|
|
|
Colon => "':'",
|
|
|
|
ColonEquals => "':='",
|
|
|
|
Comma => "','",
|
|
|
|
Comment => "comment",
|
|
|
|
Dedent => "dedent",
|
|
|
|
Dollar => "'$'",
|
|
|
|
Eof => "end of file",
|
|
|
|
Eol => "end of line",
|
|
|
|
Equals => "'='",
|
|
|
|
EqualsEquals => "'=='",
|
2021-11-04 21:35:57 -07:00
|
|
|
EqualsTilde => "'=~'",
|
2021-09-16 06:44:40 -07:00
|
|
|
Identifier => "identifier",
|
|
|
|
Indent => "indent",
|
|
|
|
InterpolationEnd => "'}}'",
|
|
|
|
InterpolationStart => "'{{'",
|
|
|
|
ParenL => "'('",
|
|
|
|
ParenR => "')'",
|
|
|
|
Plus => "'+'",
|
2022-06-25 02:39:06 -07:00
|
|
|
Slash => "'/'",
|
2021-09-16 06:44:40 -07:00
|
|
|
StringToken => "string",
|
|
|
|
Text => "command text",
|
|
|
|
Unspecified => "unspecified",
|
|
|
|
Whitespace => "whitespace",
|
|
|
|
}
|
|
|
|
)
|
2019-04-15 22:40:02 -07:00
|
|
|
}
|
|
|
|
}
|