removed != in favour of ain't

This commit is contained in:
Erin 2022-04-08 17:44:35 +02:00 committed by ondra05
parent 89326fd344
commit 60505735c9
3 changed files with 11 additions and 14 deletions

View file

@ -187,7 +187,7 @@ impl BinOpKind {
Token::GreaterThan => Ok(Self::Greater),
Token::LessThan => Ok(Self::Less),
Token::EqualEqual => Ok(Self::Equal),
Token::NotEqual => Ok(Self::NotEqual),
Token::Aint => Ok(Self::NotEqual),
t => Err(crate::error::ErrorKind::UnexpectedToken(t)),
}
}

View file

@ -56,9 +56,6 @@ pub enum Token {
#[token("==")]
EqualEqual,
#[token("!=")]
NotEqual,
#[token("ain't")]
Aint,

View file

@ -198,14 +198,22 @@ impl<'source> Parser<'source> {
},
// Operations
Token::Aint if buf.is_none() => Ok(Spanned::new(
{
let next = self.checked_next()?;
Expr::Aint(Box::new(self.parse_expr(next, buf)?))
},
start..self.lexer.span().end,
)),
Token::Plus
| Token::Minus
| Token::Star
| Token::FwdSlash
| Token::EqualEqual
| Token::NotEqual
| Token::LessThan
| Token::GreaterThan => Ok(Spanned::new(
| Token::GreaterThan
| Token::Aint => Ok(Spanned::new(
self.binop_flow(
BinOpKind::from_token(token).map_err(|e| Error::new(e, self.lexer.span()))?,
buf,
@ -213,14 +221,6 @@ impl<'source> Parser<'source> {
start..self.lexer.span().end,
)),
Token::Aint => Ok(Spanned::new(
{
let next = self.checked_next()?;
Expr::Aint(Box::new(self.parse_expr(next, buf)?))
},
start..self.lexer.span().end,
)),
Token::LeftParen => self.expr_flow(Token::RightParen),
t => Err(Error::new(ErrorKind::UnexpectedToken(t), self.lexer.span())),
}