Variables globales (déclaration, affectation avec une expression et évaluation)

This commit is contained in:
2024-06-03 08:04:53 +02:00
parent de653f9bc5
commit e121ba2160
7 changed files with 154 additions and 32 deletions

View File

@@ -26,12 +26,18 @@ pub struct Unary {
pub right: Box<Expr>,
}
#[derive(Clone)]
pub struct Variable {
pub name: Token,
}
#[derive(Clone)]
pub enum Expr {
BinaryExpr(Binary),
GroupingExpr(Grouping),
LiteralExpr(Literal),
UnaryExpr(Unary),
VariableExpr(Variable),
}
pub trait ExprVisitor<T> {
@@ -40,5 +46,6 @@ pub trait ExprVisitor<T> {
fn visit_literal(&mut self, l: &Literal) ->T;
fn visit_unary(&mut self, u: &Unary) -> T;
fn visit_expr(&mut self, e: &Expr) -> T;
fn visit_variable(&mut self, v: &Variable) -> T;
}