fix(ast): Equality prior than rational
This commit is contained in:
+24
-4
@@ -262,8 +262,6 @@ impl Parser {
|
|||||||
TokenValue::Greater => BinaryOp::Greater,
|
TokenValue::Greater => BinaryOp::Greater,
|
||||||
TokenValue::LessEqual => BinaryOp::LessEqual,
|
TokenValue::LessEqual => BinaryOp::LessEqual,
|
||||||
TokenValue::GreaterEqual => BinaryOp::GreaterEqual,
|
TokenValue::GreaterEqual => BinaryOp::GreaterEqual,
|
||||||
TokenValue::DoubleEqual => BinaryOp::Equal,
|
|
||||||
TokenValue::NotEqual => BinaryOp::NotEqual,
|
|
||||||
_ => break,
|
_ => break,
|
||||||
};
|
};
|
||||||
self.advance(1);
|
self.advance(1);
|
||||||
@@ -280,15 +278,37 @@ impl Parser {
|
|||||||
}
|
}
|
||||||
Ok(left)
|
Ok(left)
|
||||||
}
|
}
|
||||||
fn parse_logical_and(&mut self) -> Result<Expr, ParseProcessError> {
|
fn parse_equality(&mut self) -> Result<Expr, ParseProcessError> {
|
||||||
let mut left = self.parse_relational()?;
|
let mut left = self.parse_relational()?;
|
||||||
|
loop {
|
||||||
|
let op = match self.peek().value {
|
||||||
|
TokenValue::DoubleEqual => BinaryOp::Equal,
|
||||||
|
TokenValue::NotEqual => BinaryOp::NotEqual,
|
||||||
|
_ => break,
|
||||||
|
};
|
||||||
|
self.advance(1);
|
||||||
|
let right = self.parse_relational()?;
|
||||||
|
let span = Span::from_two(left.span, right.span);
|
||||||
|
left = Expr {
|
||||||
|
value: ExprValue::BinaryOp {
|
||||||
|
lhs: Box::new(left),
|
||||||
|
op,
|
||||||
|
rhs: Box::new(right),
|
||||||
|
},
|
||||||
|
span,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
Ok(left)
|
||||||
|
}
|
||||||
|
fn parse_logical_and(&mut self) -> Result<Expr, ParseProcessError> {
|
||||||
|
let mut left = self.parse_equality()?;
|
||||||
loop {
|
loop {
|
||||||
let op = match self.peek().value {
|
let op = match self.peek().value {
|
||||||
TokenValue::And => BinaryOp::And,
|
TokenValue::And => BinaryOp::And,
|
||||||
_ => break,
|
_ => break,
|
||||||
};
|
};
|
||||||
self.advance(1);
|
self.advance(1);
|
||||||
let right = self.parse_relational()?;
|
let right = self.parse_equality()?;
|
||||||
let span = Span::from_two(left.span, right.span);
|
let span = Span::from_two(left.span, right.span);
|
||||||
left = Expr {
|
left = Expr {
|
||||||
value: ExprValue::BinaryOp {
|
value: ExprValue::BinaryOp {
|
||||||
|
|||||||
Reference in New Issue
Block a user