2019-04-15 22:40:02 -07:00
|
|
|
use crate::common::*;
|
|
|
|
|
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,
|
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,
|
2019-11-07 10:55:15 -08:00
|
|
|
Identifier,
|
2019-04-15 22:40:02 -07:00
|
|
|
Indent,
|
|
|
|
InterpolationEnd,
|
|
|
|
InterpolationStart,
|
|
|
|
ParenL,
|
|
|
|
ParenR,
|
|
|
|
Plus,
|
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::*;
|
2020-02-10 20:07:06 -08:00
|
|
|
write!(f, "{}", match *self {
|
2021-07-22 00:20:25 -07:00
|
|
|
AmpersandAmpersand => "'&&'",
|
2020-06-13 01:49:13 -07:00
|
|
|
Asterisk => "'*'",
|
2020-02-10 20:07:06 -08:00
|
|
|
At => "'@'",
|
2021-04-05 21:28:37 -07:00
|
|
|
Backtick => "backtick",
|
2020-10-26 18:16:42 -07:00
|
|
|
BangEquals => "'!='",
|
|
|
|
BraceL => "'{'",
|
|
|
|
BraceR => "'}'",
|
2020-02-10 20:07:06 -08:00
|
|
|
BracketL => "'['",
|
|
|
|
BracketR => "']'",
|
|
|
|
Colon => "':'",
|
|
|
|
ColonEquals => "':='",
|
|
|
|
Comma => "','",
|
|
|
|
Comment => "comment",
|
|
|
|
Dedent => "dedent",
|
2021-03-25 18:35:24 -07:00
|
|
|
Dollar => "'$'",
|
2020-02-10 20:07:06 -08:00
|
|
|
Eof => "end of file",
|
|
|
|
Eol => "end of line",
|
|
|
|
Equals => "'='",
|
2020-10-26 18:16:42 -07:00
|
|
|
EqualsEquals => "'=='",
|
2020-02-10 20:07:06 -08:00
|
|
|
Identifier => "identifier",
|
|
|
|
Indent => "indent",
|
|
|
|
InterpolationEnd => "'}}'",
|
|
|
|
InterpolationStart => "'{{'",
|
|
|
|
ParenL => "'('",
|
|
|
|
ParenR => "')'",
|
|
|
|
Plus => "'+'",
|
2021-04-05 21:28:37 -07:00
|
|
|
StringToken => "string",
|
2020-02-10 20:07:06 -08:00
|
|
|
Text => "command text",
|
|
|
|
Unspecified => "unspecified",
|
2021-04-05 21:28:37 -07:00
|
|
|
Whitespace => "whitespace",
|
2020-02-10 20:07:06 -08:00
|
|
|
})
|
2019-04-15 22:40:02 -07:00
|
|
|
}
|
|
|
|
}
|