AST - Getter expression
This commit is contained in:
parent
7306fa0cfa
commit
0cebffbf9b
1 changed files with 20 additions and 0 deletions
20
src/ast.rs
20
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<ExprNode>,
|
||||
/// 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<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
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue