removed `!=` in favour of `ain't`

pull/7/head
ondra05 2022-04-08 17:44:35 +02:00
parent 4c20ef179e
commit 87555a6184
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())),
}