This commit is contained in:
YannAhlgrim
2026-05-14 18:49:56 +02:00
parent 13d5a20c74
commit 73ef20c4aa
2 changed files with 39 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
trait NodeTrait {
fn token_literal(&self) -> String;
}
trait StatementTrait: NodeTrait {
fn statement_node(&self);
}
trait ExpressionTrait: NodeTrait {
fn expression_node(&self);
}
struct Statement {
//
}
impl NodeTrait for Statement {
fn token_literal(&self) -> String {
todo!()
}
}
impl StatementTrait for Statement {
fn statement_node(&self) {}
}
struct Program {
statements: Vec<Statement>,
}
impl NodeTrait for Program {
fn token_literal(&self) -> String {
if self.statements.is_empty() {
self.statements[0].token_literal()
} else {
String::new()
}
}
}