Interpreter - Split into multiple modules

This commit is contained in:
Emmanuel BENOîT 2022-12-31 15:49:31 +01:00
parent 81b5f27f0a
commit bf6e150085
3 changed files with 206 additions and 201 deletions
src/interpreter

21
src/interpreter/value.rs Normal file
View file

@ -0,0 +1,21 @@
/// A value being handled by the interpreter.
#[derive(Debug, Clone, PartialEq)]
pub enum Value {
Nil,
Boolean(bool),
String(String),
Number(f64),
}
impl Value {
/// Check whether a value is truthy or not.
pub fn is_truthy(&self) -> bool {
if self == &Value::Nil {
false
} else if let Value::Boolean(b) = self {
*b
} else {
true
}
}
}