lexer: produce correct token for single !

This commit is contained in:
Ryan Chandler 2022-11-30 00:31:06 +00:00
parent c372b9e9bd
commit e21b6a40ef
No known key found for this signature in database
GPG Key ID: F113BCADDB3B0CCA
3 changed files with 3 additions and 7 deletions

View File

@ -187,7 +187,7 @@ impl Lexer {
}
[b'!', ..] => {
self.next();
TokenKind::BangEquals
TokenKind::Bang
}
[b'&', b'&', ..] => {
self.skip(2);

View File

@ -210,6 +210,7 @@ impl Default for Token {
impl Display for TokenKind {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let s = match self {
Self::BangEquals => "!=",
Self::From => "from",
Self::Print => "print",
Self::BitwiseNot => "~",

View File

@ -2203,12 +2203,7 @@ impl Parser {
prefix(&op, rhs)
}
TokenKind::Dollar => self.dynamic_variable()?,
_ => todo!(
"expr lhs: {:?}, line {} col {}",
self.current.kind,
self.current.span.0,
self.current.span.1
),
_ => return Err(ParseError::UnexpectedToken(self.current.kind.to_string(), self.current.span)),
};
if self.current.kind == TokenKind::SemiColon {