Not is now lexing and parsing correctly
This commit is contained in:
parent
92f2c62d59
commit
82239be160
|
@ -151,7 +151,7 @@ impl ExecEnv {
|
||||||
NotEqual => Value::Bool(lhs != rhs),
|
NotEqual => Value::Bool(lhs != rhs),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Not(expr) => Bool(!self.eval_expr(expr)?.into_bool()),
|
Not(expr) => !self.eval_expr(expr)?,
|
||||||
Literal(value) => value.clone(),
|
Literal(value) => value.clone(),
|
||||||
ExprKind::Cart(members) => Value::Cart(
|
ExprKind::Cart(members) => Value::Cart(
|
||||||
members
|
members
|
||||||
|
@ -539,7 +539,7 @@ mod tests {
|
||||||
span: 1..1
|
span: 1..1
|
||||||
})
|
})
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
Value::Int(42)
|
Value::Int(-2147483648)
|
||||||
);
|
);
|
||||||
|
|
||||||
// And the same for divide by zero.
|
// And the same for divide by zero.
|
||||||
|
@ -547,7 +547,7 @@ mod tests {
|
||||||
env.eval_expr(&Expr {
|
env.eval_expr(&Expr {
|
||||||
kind: ExprKind::BinOp {
|
kind: ExprKind::BinOp {
|
||||||
lhs: Box::new(Expr {
|
lhs: Box::new(Expr {
|
||||||
kind: ExprKind::Literal(Value::Int(1)),
|
kind: ExprKind::Literal(Value::Int(84)),
|
||||||
span: 1..1,
|
span: 1..1,
|
||||||
}),
|
}),
|
||||||
rhs: Box::new(Expr {
|
rhs: Box::new(Expr {
|
||||||
|
@ -559,7 +559,7 @@ mod tests {
|
||||||
span: 1..1
|
span: 1..1
|
||||||
})
|
})
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
Value::Int(42)
|
Value::Int(2)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ pub enum Token {
|
||||||
#[token("!=")]
|
#[token("!=")]
|
||||||
NotEqual,
|
NotEqual,
|
||||||
|
|
||||||
#[token("!|aint")] // also add aint as a not keyword
|
#[regex("!|aint")] // also add aint as a not keyword
|
||||||
Not,
|
Not,
|
||||||
|
|
||||||
// Keywords
|
// Keywords
|
||||||
|
|
|
@ -99,6 +99,7 @@ impl<'source> Parser<'source> {
|
||||||
| Token::Abool(_)
|
| Token::Abool(_)
|
||||||
| Token::Bool(_)
|
| Token::Bool(_)
|
||||||
| Token::Nul
|
| Token::Nul
|
||||||
|
| Token::Not
|
||||||
| Token::LeftBracket
|
| Token::LeftBracket
|
||||||
| Token::LeftParen => Ok(Stmt::new(
|
| Token::LeftParen => Ok(Stmt::new(
|
||||||
self.value_flow(token)?,
|
self.value_flow(token)?,
|
||||||
|
|
|
@ -418,6 +418,14 @@ impl ops::Div for Value {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ops::Not for Value {
|
||||||
|
type Output = Value;
|
||||||
|
|
||||||
|
fn not(self) -> Self::Output {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl PartialEq for Value {
|
impl PartialEq for Value {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
let other = other.clone();
|
let other = other.clone();
|
||||||
|
|
Loading…
Reference in a new issue