AST - Getter expression

This commit is contained in:
Emmanuel BENOîT 2023-01-08 11:04:32 +01:00
parent 7306fa0cfa
commit 0cebffbf9b

View file

@ -74,6 +74,15 @@ impl StmtNode {
} }
} }
/// A getter expression.
#[derive(Debug, Clone)]
pub struct GetExpr {
/// The instance being accessed.
pub instance: Box<ExprNode>,
/// The name of the property.
pub name: Token,
}
/// An AST node that represents an expression. /// An AST node that represents an expression.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum ExprNode { pub enum ExprNode {
@ -134,6 +143,9 @@ pub enum ExprNode {
/// The list of function arguments. /// The list of function arguments.
arguments: Vec<ExprNode>, arguments: Vec<ExprNode>,
}, },
/// 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
)
}
} }
} }
} }