Updated WIP
This commit is contained in:
parent
7540096f6d
commit
993efe4287
11 changed files with 170 additions and 426 deletions
|
|
@ -12,5 +12,6 @@ run_arithmetic/_run_arith \
|
|||
run_arithmetic/_to_ast_node \
|
||||
run_arithmetic/arithmetic \
|
||||
run_arithmetic/arithmetic_operation \
|
||||
run_arithmetic/operator_bis \
|
||||
run_ast \
|
||||
|
||||
|
|
|
|||
|
|
@ -6,13 +6,12 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/30 17:56:29 by rparodi #+# #+# */
|
||||
/* Updated: 2024/08/30 17:58:54 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/09/02 13:45:52 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "exec/_run_arith.h"
|
||||
#include "me/types.h"
|
||||
#include "me/convert/str_to_numbers.h"
|
||||
|
||||
/// ADD OPERATOR STUFF
|
||||
t_error _binary_get_op(t_ast_arithmetic_operator op, t_arith_op_func *out)
|
||||
|
|
|
|||
50
exec/src/run_arithmetic/operator_bis.c
Normal file
50
exec/src/run_arithmetic/operator_bis.c
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* operator_bis.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/02 13:45:46 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/09/02 13:50:59 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "exec/_run_arith.h"
|
||||
#include "me/types.h"
|
||||
|
||||
|
||||
t_error _postfix_op_dec(t_ast_node self, t_state *state, t_i64 *out)
|
||||
{
|
||||
(void)(self);
|
||||
(void)(state);
|
||||
(void)(out);
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
t_error _postfix_op_inc(t_ast_node self, t_state *state, t_i64 *out)
|
||||
{
|
||||
(void)(self);
|
||||
(void)(state);
|
||||
(void)(out);
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
t_error _unary_op_minus(t_ast_node self, t_state *state, t_i64 *out)
|
||||
{
|
||||
t_i64 val;
|
||||
|
||||
(void)(self);
|
||||
(void)(state);
|
||||
(void)(out);
|
||||
if (_get_node_number(self, state, &val))
|
||||
return (ERROR);
|
||||
val = -val;
|
||||
*out = val;
|
||||
return (NO_ERROR);
|
||||
}
|
||||
|
||||
t_error _unary_op_plus(t_ast_node self, t_state *state, t_i64 *out)
|
||||
{
|
||||
return (_get_node_number(self, state, out));
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/11 17:22:29 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/08/14 18:30:23 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/09/02 13:44:31 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ t_error _handle_no_operator(t_ast_expansion *self, t_state *state, t_expansion_r
|
|||
if (val == NULL)
|
||||
return (value->exists = false, NO_ERROR);
|
||||
value->exists = true;
|
||||
value->value = *val;
|
||||
value->value = str_clone(*val);
|
||||
return (NO_ERROR);
|
||||
};
|
||||
|
||||
|
|
@ -306,10 +306,17 @@ t_error _ast_get_str__expansion(t_ast_node elem, t_word_iterator *state, t_vec_e
|
|||
|
||||
t_error _ast_get_str__arimethic_expansion(t_ast_node elem, t_word_iterator *state, t_vec_estr *out)
|
||||
{
|
||||
t_str out_str;
|
||||
t_i64 out_num;
|
||||
|
||||
if (elem == NULL || state == NULL || out == NULL || elem->kind != AST_ARITHMETIC_EXPANSION)
|
||||
return (ERROR);
|
||||
// vec_estr_push(out, (t_expandable_str){.do_expand = state->res.kind == AST_WORD_NO_QUOTE, .value = str_clone(exp_out.value)});
|
||||
return (ERROR);
|
||||
if (run_arithmetic_expansion(&elem->data.arithmetic_expansion, state->state, &out_num))
|
||||
return (ERROR);
|
||||
if (i64_to_str(out_num, &out_str))
|
||||
return (ERROR);
|
||||
vec_estr_push(out, (t_expandable_str){.do_expand = state->res.kind == AST_WORD_NO_QUOTE, .value = out_str});
|
||||
return (NO_ERROR);
|
||||
}
|
||||
|
||||
t_error _ast_get_str__command_substitution(t_ast_node elem, t_word_iterator *state, t_vec_estr *out)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue