This commit is contained in:
YannAhlgrim
2026-05-22 15:20:05 +02:00
parent 73ef20c4aa
commit 4accaa2edc
3 changed files with 94 additions and 1 deletions
+46 -1
View File
@@ -1,3 +1,5 @@
use crate::token;
trait NodeTrait {
fn token_literal(&self) -> String;
}
@@ -9,6 +11,14 @@ trait StatementTrait: NodeTrait {
trait ExpressionTrait: NodeTrait {
fn expression_node(&self);
}
struct Expression {
//
}
impl NodeTrait for Expression {
fn token_literal(&self) -> String {
todo!()
}
}
struct Statement {
//
@@ -23,7 +33,7 @@ impl StatementTrait for Statement {
fn statement_node(&self) {}
}
struct Program {
pub struct Program {
statements: Vec<Statement>,
}
@@ -36,3 +46,38 @@ impl NodeTrait for Program {
}
}
}
struct LetStatement {
token: token::Token,
name: Identifier,
value: Expression,
}
impl NodeTrait for LetStatement {
fn token_literal(&self) -> String {
String::from(&self.token.literal)
}
}
impl StatementTrait for LetStatement {
fn statement_node(&self) {
todo!()
}
}
struct Identifier {
token: token::Token,
value: String,
}
impl NodeTrait for Identifier {
fn token_literal(&self) -> String {
String::from(&self.token.literal)
}
}
impl ExpressionTrait for Identifier {
fn expression_node(&self) {
todo!()
}
}