From 60505735c91840612f3fb8002c6d66186d670507 Mon Sep 17 00:00:00 2001 From: Erin Date: Fri, 8 Apr 2022 17:44:35 +0200 Subject: [PATCH] removed `!=` in favour of `ain't` --- ablescript/src/ast.rs | 2 +- ablescript/src/lexer.rs | 3 --- ablescript/src/parser.rs | 20 ++++++++++---------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/ablescript/src/ast.rs b/ablescript/src/ast.rs index 6877842..4a32589 100644 --- a/ablescript/src/ast.rs +++ b/ablescript/src/ast.rs @@ -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)), } } diff --git a/ablescript/src/lexer.rs b/ablescript/src/lexer.rs index e2d4fea..a67452e 100644 --- a/ablescript/src/lexer.rs +++ b/ablescript/src/lexer.rs @@ -56,9 +56,6 @@ pub enum Token { #[token("==")] EqualEqual, - #[token("!=")] - NotEqual, - #[token("ain't")] Aint, diff --git a/ablescript/src/parser.rs b/ablescript/src/parser.rs index 144514f..fad90be 100644 --- a/ablescript/src/parser.rs +++ b/ablescript/src/parser.rs @@ -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())), }