forked from AbleScript/ablescript
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),
|
||||
}
|
||||
}
|
||||
Not(expr) => Bool(!self.eval_expr(expr)?.into_bool()),
|
||||
Not(expr) => !self.eval_expr(expr)?,
|
||||
Literal(value) => value.clone(),
|
||||
ExprKind::Cart(members) => Value::Cart(
|
||||
members
|
||||
|
@ -539,7 +539,7 @@ mod tests {
|
|||
span: 1..1
|
||||
})
|
||||
.unwrap(),
|
||||
Value::Int(42)
|
||||
Value::Int(-2147483648)
|
||||
);
|
||||
|
||||
// And the same for divide by zero.
|
||||
|
@ -547,7 +547,7 @@ mod tests {
|
|||
env.eval_expr(&Expr {
|
||||
kind: ExprKind::BinOp {
|
||||
lhs: Box::new(Expr {
|
||||
kind: ExprKind::Literal(Value::Int(1)),
|
||||
kind: ExprKind::Literal(Value::Int(84)),
|
||||
span: 1..1,
|
||||
}),
|
||||
rhs: Box::new(Expr {
|
||||
|
@ -559,7 +559,7 @@ mod tests {
|
|||
span: 1..1
|
||||
})
|
||||
.unwrap(),
|
||||
Value::Int(42)
|
||||
Value::Int(2)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ pub enum Token {
|
|||
#[token("!=")]
|
||||
NotEqual,
|
||||
|
||||
#[token("!|aint")] // also add aint as a not keyword
|
||||
#[regex("!|aint")] // also add aint as a not keyword
|
||||
Not,
|
||||
|
||||
// Keywords
|
||||
|
|
|
@ -99,6 +99,7 @@ impl<'source> Parser<'source> {
|
|||
| Token::Abool(_)
|
||||
| Token::Bool(_)
|
||||
| Token::Nul
|
||||
| Token::Not
|
||||
| Token::LeftBracket
|
||||
| Token::LeftParen => Ok(Stmt::new(
|
||||
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 {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
let other = other.clone();
|
||||
|
|
Loading…
Reference in a new issue