adding the start of arit
This commit is contained in:
parent
f490f834f7
commit
102b41d170
2 changed files with 25 additions and 2 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/26 10:55:52 by rparodi #+# #+# */
|
||||
/* Updated: 2024/07/26 11:27:49 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/07/27 12:30:19 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/26 15:14:50 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/07/26 15:20:41 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/07/27 12:44:46 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -23,6 +23,7 @@
|
|||
#include "me/types.h"
|
||||
#include "me/vec/vec_estr.h"
|
||||
#include "me/vec/vec_str.h"
|
||||
#include "me/convert/str_to_numbers.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
@ -35,3 +36,25 @@ t_error run_arithmetic_postfix(t_ast_arithmetic_postfix *arithmetic_postfix, t_s
|
|||
t_error run_arithmetic_ternary(t_ast_arithmetic_ternary *arithmetic_ternary, t_state *state, void *out);
|
||||
t_error run_arithmetic_unary(t_ast_arithmetic_unary *arithmetic_unary, t_state *state, void *out);
|
||||
t_error run_arithmetic_expansion(t_ast_arithmetic_expansion *arithmetic_expansion, t_state *state, void *out);
|
||||
|
||||
t_error run_arithmetic_binary(t_ast_arithmetic_binary *arithmetic_binary, t_state *state, void *out)
|
||||
{
|
||||
t_i64 ret;
|
||||
t_i64 left;
|
||||
t_i64 right;
|
||||
|
||||
if (str_to_i64(arithmetic_binary->lhs->data, 10, &left))
|
||||
return (ERROR);
|
||||
if (str_to_i64(arithmetic_binary->rhs->data, 10, &right))
|
||||
return (ERROR);
|
||||
if (arithmetic_binary->op == ARITH_PLUS)
|
||||
ret = arithmetic_binary->lhs->data + arithmetic_binary->rhs->data;
|
||||
if (arithmetic_binary->op == ARITH_MINUS)
|
||||
ret = arithmetic_binary->lhs->data - arithmetic_binary->rhs->data;
|
||||
if (arithmetic_binary->op == ARITH_MULT)
|
||||
ret = arithmetic_binary->lhs->data * arithmetic_binary->rhs->data;
|
||||
if (arithmetic_binary->op == ARITH_MOD)
|
||||
ret = arithmetic_binary->lhs->data % arithmetic_binary->rhs->data;
|
||||
if (arithmetic_binary->op == ARITH_DIVIDE)
|
||||
ret = arithmetic_binary->lhs->data / arithmetic_binary->rhs->data;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue