Interpreter - Handle AST refactorings

This commit is contained in:
Emmanuel BENOîT 2023-01-09 07:51:40 +01:00
parent b12c7a05cf
commit dbd0f6d20f

View file

@ -333,20 +333,24 @@ impl Interpretable for ExprNode {
es.assign_var(name, id, value)?;
Ok(InterpreterFlowControl::default())
}
ExprNode::Logical {
left,
operator,
right,
} => self.on_logic(es, left, operator, right),
ExprNode::Binary {
left,
operator,
right,
} => self.on_binary(es, left, operator, right),
ExprNode::Logical(binary_expr) => self.on_logic(
es,
&binary_expr.left,
&binary_expr.operator,
&binary_expr.right,
),
ExprNode::Binary(binary_expr) => self.on_binary(
es,
&binary_expr.left,
&binary_expr.operator,
&binary_expr.right,
),
ExprNode::Unary { operator, right } => self.on_unary(es, operator, right),
ExprNode::Grouping { expression } => expression.interpret(es),
ExprNode::Litteral { value } => self.on_litteral(value),
ExprNode::Variable { name, id } => Ok(es.lookup_var(name, id)?.into()),
ExprNode::Variable(var_expr) => {
Ok(es.lookup_var(&var_expr.token, &var_expr.id)?.into())
}
ExprNode::Call {
callee,
right_paren,