diff --git a/src/ast.rs b/src/ast.rs index aa54d8c..7532df0 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -105,6 +105,15 @@ pub struct BinaryExpr { pub right: Box, } +/// A variable reference expression. +#[derive(Debug, Clone)] +pub struct VariableExpr { + /// The name of the variable, or the "this" keyword. + pub token: Token, + /// Identifier used for variable resolution. + pub id: usize, +} + /// An AST node that represents an expression. #[derive(Debug, Clone)] pub enum ExprNode { @@ -135,11 +144,7 @@ pub enum ExprNode { Litteral { value: Token }, /// A reference to a variable. - Variable { - name: Token, - /// Identifier used for variable resolution. - id: usize, - }, + Variable(VariableExpr), /// A lambda function. Lambda { diff --git a/src/dumper.rs b/src/dumper.rs index 36e0cfa..20c4ccd 100644 --- a/src/dumper.rs +++ b/src/dumper.rs @@ -217,8 +217,8 @@ fn dump_expr_node(dumper: &mut Dumper, expr: &ExprNode) { dumper.current_line().push_str(&value.lexeme); } - ExprNode::Variable { name, id: _ } => { - dumper.current_line().push_str(&name.lexeme); + ExprNode::Variable(var) => { + dumper.current_line().push_str(&var.token.lexeme); } ExprNode::Lambda { params, body } => {