removed != in favour of ain't

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

View file

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

View file

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

View file

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