598f1c3200
Use a `Token` to represent the error context, instead of a mess of fields. Remove write_message_context in favor of `Token::write_context`.
66 lines
1.3 KiB
Rust
66 lines
1.3 KiB
Rust
use crate::common::*;
|
|
|
|
#[derive(Debug, PartialEq, Clone, Copy, Ord, PartialOrd, Eq)]
|
|
pub(crate) enum TokenKind {
|
|
At,
|
|
Backtick,
|
|
BracketL,
|
|
BracketR,
|
|
Colon,
|
|
ColonEquals,
|
|
Comma,
|
|
Comment,
|
|
Dedent,
|
|
Eof,
|
|
Eol,
|
|
Equals,
|
|
Identifier,
|
|
Indent,
|
|
InterpolationEnd,
|
|
InterpolationStart,
|
|
ParenL,
|
|
ParenR,
|
|
Plus,
|
|
StringCooked,
|
|
StringRaw,
|
|
Text,
|
|
Unspecified,
|
|
Whitespace,
|
|
}
|
|
|
|
impl Display for TokenKind {
|
|
fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
|
|
use TokenKind::*;
|
|
write!(
|
|
f,
|
|
"{}",
|
|
match *self {
|
|
At => "'@'",
|
|
Backtick => "backtick",
|
|
BracketL => "'['",
|
|
BracketR => "']'",
|
|
Colon => "':'",
|
|
ColonEquals => "':='",
|
|
Comma => "','",
|
|
Comment => "comment",
|
|
Dedent => "dedent",
|
|
Eof => "end of file",
|
|
Eol => "end of line",
|
|
Equals => "'='",
|
|
Identifier => "identifier",
|
|
Indent => "indent",
|
|
InterpolationEnd => "'}}'",
|
|
InterpolationStart => "'{{'",
|
|
ParenL => "'('",
|
|
ParenR => "')'",
|
|
Plus => "'+'",
|
|
StringCooked => "cooked string",
|
|
StringRaw => "raw string",
|
|
Text => "command text",
|
|
Whitespace => "whitespace",
|
|
Unspecified => "unspecified",
|
|
}
|
|
)
|
|
}
|
|
}
|