diff --git a/ast/include/ast/ast_raw_structs.h b/ast/include/ast/ast_raw_structs.h index 55b73e8b..dccfe6cc 100644 --- a/ast/include/ast/ast_raw_structs.h +++ b/ast/include/ast/ast_raw_structs.h @@ -6,7 +6,7 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/06/14 17:46:58 by maiboyer #+# #+# */ -/* Updated: 2024/07/20 16:28:03 by maiboyer ### ########.fr */ +/* Updated: 2024/07/21 15:29:33 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -388,7 +388,7 @@ struct s_ast_heredoc_redirection /// $@ /// ``` -struct s_ast_expansion +struct s_ast_expansion { t_str var_name; bool len_operator; @@ -409,6 +409,14 @@ struct s_ast_arithmetic_expansion t_ast_node expr; }; +struct s_ast_binary_op +{ + t_ast_node operator; +}; + +{ + t_ast_node expr; +}; /// Command Substitution /// ```shell /// $(command) diff --git a/ast/src/from_node.c b/ast/src/from_node.c index 5f89e35d..50c8fe0b 100644 --- a/ast/src/from_node.c +++ b/ast/src/from_node.c @@ -1,8 +1,3 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* from_node.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/06/17 12:41:56 by maiboyer #+# #+# */ @@ -72,6 +67,8 @@ sym_while_statement sym_word */ +#include +#include #include #undef ERROR @@ -618,6 +615,29 @@ t_error build_sym_heredoc_start(t_parse_node self, t_const_str input, t_ast_node #include +t_error build_sym_arithmetic_binary_expression(t_parse_node self, t_const_str input, t_ast_node *out); +{ + t_usize i; + t_ast_node *ret; + + i = 0; + ret = ast_alloc(AST_ARITHMETIC_EXPANSION); + while (str[i] == '\0') + { + if (str[i] == '+') + ret->operator = '+'; + if (str[i] == '-') + ret->operator = '-'; + if (str[i] == '/') + ret->operator = '/'; + if (str[i] == '%') + ret->operator = '%'; + if (str[i] == '*') + ret->operator = '*'; + } + +} + t_error build_sym_command_substitution(t_parse_node self, t_const_str input, t_ast_node *out) { t_ast_node ret;