evaluator

This commit is contained in:
Yann Ahlgrim
2026-07-11 20:25:22 +02:00
parent 30bcf7c6b2
commit 5869d8acc2
5 changed files with 189 additions and 3 deletions
+50
View File
@@ -0,0 +1,50 @@
pub enum ObjectType {
INTEGER,
BOOLEAN,
NULL,
}
pub trait Object {
fn object_type(&self) -> ObjectType;
fn inspect(&self) -> String;
}
pub struct Integer {
pub value: i64,
}
impl Object for Integer {
fn object_type(&self) -> ObjectType {
ObjectType::INTEGER
}
fn inspect(&self) -> String {
self.value.to_string()
}
}
pub struct Boolean {
pub value: bool,
}
impl Object for Boolean {
fn object_type(&self) -> ObjectType {
ObjectType::BOOLEAN
}
fn inspect(&self) -> String {
self.value.to_string()
}
}
pub struct Null;
impl Object for Null {
fn object_type(&self) -> ObjectType {
ObjectType::NULL
}
fn inspect(&self) -> String {
"null".to_string()
}
}