just/src/token_kind.rs

72 lines
1.5 KiB
Rust
Raw Normal View History

use crate::common::*;
#[derive(Debug, PartialEq, Clone, Copy, Ord, PartialOrd, Eq)]
pub(crate) enum TokenKind {
Asterisk,
At,
BangEquals,
BraceL,
BraceR,
BracketL,
BracketR,
Colon,
ColonEquals,
Comma,
Comment,
Dedent,
Dollar,
Eof,
Eol,
Equals,
EqualsEquals,
Identifier,
Indent,
InterpolationEnd,
InterpolationStart,
ParenL,
ParenR,
Plus,
StringToken(StringKind),
Text,
Unspecified,
Whitespace,
}
impl Display for TokenKind {
fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
use TokenKind::*;
write!(f, "{}", match *self {
Asterisk => "'*'",
At => "'@'",
BangEquals => "'!='",
BraceL => "'{'",
BraceR => "'}'",
BracketL => "'['",
BracketR => "']'",
Colon => "':'",
ColonEquals => "':='",
Comma => "','",
Comment => "comment",
Dedent => "dedent",
Dollar => "'$'",
Eof => "end of file",
Eol => "end of line",
Equals => "'='",
EqualsEquals => "'=='",
Identifier => "identifier",
Indent => "indent",
InterpolationEnd => "'}}'",
InterpolationStart => "'{{'",
ParenL => "'('",
ParenR => "')'",
Plus => "'+'",
StringToken(StringKind::Backtick) => "backtick",
StringToken(StringKind::Cooked) => "cooked string",
StringToken(StringKind::Raw) => "raw string",
Text => "command text",
Whitespace => "whitespace",
Unspecified => "unspecified",
})
}
}