diff --git a/src/ast.rs b/src/ast.rs index dabe209..dc7e09c 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -74,6 +74,15 @@ impl StmtNode { } } +/// A getter expression. +#[derive(Debug, Clone)] +pub struct GetExpr { + /// The instance being accessed. + pub instance: Box, + /// The name of the property. + pub name: Token, +} + /// An AST node that represents an expression. #[derive(Debug, Clone)] pub enum ExprNode { @@ -134,6 +143,9 @@ pub enum ExprNode { /// The list of function arguments. arguments: Vec, }, + + /// A get expression. + Get(GetExpr), } /* -------------------------------- * @@ -326,6 +338,14 @@ impl AstDumper for ExprNode { ) } } + + ExprNode::Get(get_expr) => { + format!( + "( get {} {} )", + get_expr.instance.dump(), + get_expr.name.lexeme + ) + } } } }