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)?; es.assign_var(name, id, value)?;
Ok(InterpreterFlowControl::default()) Ok(InterpreterFlowControl::default())
} }
ExprNode::Logical { ExprNode::Logical(binary_expr) => self.on_logic(
left, es,
operator, &binary_expr.left,
right, &binary_expr.operator,
} => self.on_logic(es, left, operator, right), &binary_expr.right,
ExprNode::Binary { ),
left, ExprNode::Binary(binary_expr) => self.on_binary(
operator, es,
right, &binary_expr.left,
} => self.on_binary(es, left, operator, right), &binary_expr.operator,
&binary_expr.right,
),
ExprNode::Unary { operator, right } => self.on_unary(es, operator, right), ExprNode::Unary { operator, right } => self.on_unary(es, operator, right),
ExprNode::Grouping { expression } => expression.interpret(es), ExprNode::Grouping { expression } => expression.interpret(es),
ExprNode::Litteral { value } => self.on_litteral(value), 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 { ExprNode::Call {
callee, callee,
right_paren, right_paren,