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 {
|
2020-06-13 01:49:13 -07:00
|
|
|
Asterisk,
|
2019-04-15 22:40:02 -07:00
|
|
|
At,
|
|
|
|
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,
|
|
|
|
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,
|
|
|
|
StringCooked,
|
2019-11-07 10:55:15 -08:00
|
|
|
StringRaw,
|
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 {
|
2020-06-13 01:49:13 -07:00
|
|
|
Asterisk => "'*'",
|
2020-02-10 20:07:06 -08:00
|
|
|
At => "'@'",
|
|
|
|
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",
|
|
|
|
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 => "'+'",
|
|
|
|
StringCooked => "cooked string",
|
|
|
|
StringRaw => "raw string",
|
|
|
|
Text => "command text",
|
|
|
|
Whitespace => "whitespace",
|
|
|
|
Unspecified => "unspecified",
|
|
|
|
})
|
2019-04-15 22:40:02 -07:00
|
|
|
}
|
|
|
|
}
|