diff --git a/ast/Filelist.ast.mk b/ast/Filelist.ast.mk index 376dabf0..e43465ff 100644 --- a/ast/Filelist.ast.mk +++ b/ast/Filelist.ast.mk @@ -1,11 +1,11 @@ SRC_FILES = \ +_not_done_function \ +_not_done_print \ ast_alloc/ast_alloc \ ast_alloc/ast_alloc_scripting \ ast_free/ast_free \ ast_free/ast_free_scripting \ from_node/from_node \ -not_done_function \ -not_done_print \ print_ast/ast_print_command \ print_ast/ast_print_global \ print_ast/ast_print_node \ diff --git a/ast/include/ast/ast_forward_def.h b/ast/include/ast/_forward_def.h similarity index 95% rename from ast/include/ast/ast_forward_def.h rename to ast/include/ast/_forward_def.h index a8a41106..2b0c02d7 100644 --- a/ast/include/ast/ast_forward_def.h +++ b/ast/include/ast/_forward_def.h @@ -1,17 +1,17 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* ast_forward_def.h :+: :+: :+: */ +/* _forward_def.h :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/06/11 14:24:24 by maiboyer #+# #+# */ -/* Updated: 2024/07/22 16:52:42 by rparodi ### ########.fr */ +/* Updated: 2024/08/02 17:04:12 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ -#ifndef AST_FORWARD_DEF_H -# define AST_FORWARD_DEF_H +#ifndef _FORWARD_DEF_H +# define _FORWARD_DEF_H typedef enum e_ast_node_kind t_ast_node_kind; typedef enum e_ast_word_kind t_ast_word_kind; diff --git a/ast/include/ast/_from_node.h b/ast/include/ast/_from_node.h new file mode 100644 index 00000000..e82b7314 --- /dev/null +++ b/ast/include/ast/_from_node.h @@ -0,0 +1,128 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* _from_node.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/08/02 16:54:31 by maiboyer #+# #+# */ +/* Updated: 2024/08/02 17:00:38 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef _FROM_NODE_H +# define _FROM_NODE_H + +# include "ast/ast.h" +# include "me/types.h" +# include "parser/api.h" + +void _add_negation(t_ast_node *node); +void _append_redirection(t_ast_node node, + t_ast_node redirection); +t_ast_expansion_operator _extract_exp_op(t_parse_node self); +t_str _extract_str(t_parse_node self, t_const_str input); +t_ast_redirection_kind _get_redirection_op(t_parse_node self); +t_ast_arithmetic_operator _parse_operator(t_parse_node self); +t_ast_terminator_kind _select_term(t_parse_node node); +t_vec_ast *_vec_command(t_ast_command *val, t_usize i); +t_error ast_from_node(t_parse_node node, t_const_str input, + t_ast_node *out); +void ast_set_term(t_ast_node *node, + t_ast_terminator_kind term); +t_error build_sym__case_item_last(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_arithmetic_binary_expression(\ + t_parse_node self, t_const_str input, t_ast_node *out); +t_error build_sym_arithmetic_expansion(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_arithmetic_literal(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_arithmetic_parenthesized_expression(\ + t_parse_node self, t_const_str input, t_ast_node *out); +t_error build_sym_arithmetic_postfix_expression(\ + t_parse_node self, t_const_str input, t_ast_node *out); +t_error build_sym_arithmetic_ternary_expression(\ + t_parse_node self, t_const_str input, t_ast_node *out); +t_error build_sym_arithmetic_unary_expression(\ + t_parse_node self, t_const_str input, t_ast_node *out); +t_error build_sym_case_item(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_case_statement(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_command(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_command_name(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_command_substitution(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_comment(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_compound_statement(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_concatenation(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_do_group(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_elif_clause(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_else_clause(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_expansion(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_extglob_pattern(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_file_descriptor(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_file_redirect(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_for_statement(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_function_definition(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_if_statement(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_heredoc_redirect(\ + t_parse_node self, t_const_str input, t_ast_node *out); +t_error build_sym_simple_heredoc_body(\ + t_parse_node self, t_const_str input, t_ast_node *out); +t_error build_sym_heredoc_body(\ + t_parse_node self, t_const_str input, t_ast_node *out); +t_error build_sym_heredoc_content(\ + t_parse_node self, t_const_str input, t_ast_node *out); +t_error build_sym_heredoc_end(\ + t_parse_node self, t_const_str input, t_ast_node *out); +t_error build_sym_heredoc_start(\ + t_parse_node self, t_const_str input, t_ast_node *out); +t_error build_sym_list(t_parse_node self, t_const_str input, + t_ast_node *out); +t_error build_sym_negated_command(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_number(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_pipeline(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_program(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_raw_string(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_redirected_statement(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_regex(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_simple_expansion(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_string(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_string_content(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_subshell(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_variable_assignment(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_while_statement(t_parse_node self, + t_const_str input, t_ast_node *out); +t_error build_sym_word(t_parse_node self, t_const_str input, + t_ast_node *out); + +#endif /* _FROM_NODE_H */ diff --git a/ast/include/ast/_function_declaration.h b/ast/include/ast/_print_ast.h similarity index 92% rename from ast/include/ast/_function_declaration.h rename to ast/include/ast/_print_ast.h index b897a601..e50316a1 100644 --- a/ast/include/ast/_function_declaration.h +++ b/ast/include/ast/_print_ast.h @@ -1,17 +1,17 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* _function_declaration.h :+: :+: :+: */ +/* _print_ast.h :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/07/26 11:30:24 by rparodi #+# #+# */ -/* Updated: 2024/07/30 16:59:21 by maiboyer ### ########.fr */ +/* Updated: 2024/08/02 17:04:04 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ -#ifndef _FUNCTION_DECLARATION_H -# define _FUNCTION_DECLARATION_H +#ifndef _PRINT_AST_H +# define _PRINT_AST_H # include "ast/ast.h" # include "me/types.h" diff --git a/ast/include/ast/ast_raw_structs.h b/ast/include/ast/_raw_structs.h similarity index 97% rename from ast/include/ast/ast_raw_structs.h rename to ast/include/ast/_raw_structs.h index 6f748080..c7430672 100644 --- a/ast/include/ast/ast_raw_structs.h +++ b/ast/include/ast/_raw_structs.h @@ -1,19 +1,19 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* ast_raw_structs.h :+: :+: :+: */ +/* _raw_structs.h :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/06/14 17:46:58 by maiboyer #+# #+# */ -/* Updated: 2024/08/01 09:34:59 by maiboyer ### ########.fr */ +/* Updated: 2024/08/02 17:03:50 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ -#ifndef AST_RAW_STRUCTS_H -# define AST_RAW_STRUCTS_H +#ifndef _RAW_STRUCTS_H +# define _RAW_STRUCTS_H -# include "ast/ast_forward_def.h" +# include "ast/_forward_def.h" # include "me/types.h" # include "me/vec/vec_ast.h" diff --git a/ast/include/ast/ast.h b/ast/include/ast/ast.h index 5f188c36..7c4be9c9 100644 --- a/ast/include/ast/ast.h +++ b/ast/include/ast/ast.h @@ -6,15 +6,15 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/06/11 14:23:40 by maiboyer #+# #+# */ -/* Updated: 2024/07/30 18:41:40 by maiboyer ### ########.fr */ +/* Updated: 2024/08/02 17:02:03 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef AST_H # define AST_H -# include "ast/ast_forward_def.h" // IWYU pragma: keep -# include "ast/ast_raw_structs.h" // IWYU pragma: keep +# include "ast/_forward_def.h" // IWYU pragma: keep +# include "ast/_raw_structs.h" // IWYU pragma: keep enum e_ast_node_kind { @@ -92,6 +92,7 @@ struct s_ast_node t_ast_node_data data; }; -void ast_free(t_ast_node self); +void ast_free(t_ast_node self); +t_ast_node ast_alloc(t_ast_node_kind kind); #endif /* AST_H */ diff --git a/ast/src/not_done_function.c b/ast/src/_not_done_function.c similarity index 100% rename from ast/src/not_done_function.c rename to ast/src/_not_done_function.c diff --git a/ast/src/not_done_print.c b/ast/src/_not_done_print.c similarity index 98% rename from ast/src/not_done_print.c rename to ast/src/_not_done_print.c index 143cca16..05c24534 100644 --- a/ast/src/not_done_print.c +++ b/ast/src/_not_done_print.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "ast/_function_declaration.h" +#include "ast/_print_ast.h" void ast_print_node_if(t_ast_node self) { diff --git a/ast/src/from_node/from_node.c b/ast/src/from_node/from_node.c index 7fe71569..f57a0170 100644 --- a/ast/src/from_node/from_node.c +++ b/ast/src/from_node/from_node.c @@ -6,11 +6,21 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/07/26 10:55:52 by rparodi #+# #+# */ -/* Updated: 2024/08/02 15:48:33 by rparodi ### ########.fr */ +/* Updated: 2024/08/02 16:58:13 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ -#include "./from_node.h" +#include "ast/_from_node.h" +#include "ast/ast.h" +#include "gmr/field_identifiers.h" +#include "gmr/field_identifiers.h" +#include "gmr/symbols.h" +#include "gmr/symbols.h" +#include "me/str/str.h" +#include "me/types.h" +#include "me/vec/vec_ast.h" +#include "parser/api.h" +#include /* sym_arithmetic_binary_expression diff --git a/ast/src/from_node/from_node.h b/ast/src/from_node/from_node.h deleted file mode 100644 index bcd0f922..00000000 --- a/ast/src/from_node/from_node.h +++ /dev/null @@ -1,118 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* from_node.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: rparodi +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/08/02 14:47:50 by rparodi #+# #+# */ -/* Updated: 2024/08/02 15:47:55 by rparodi ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef FROM_NODE_H -# define FROM_NODE_H - -# include "ast/ast.h" -# include "gmr/field_identifiers.h" -# include "gmr/symbols.h" -# include "me/mem/mem.h" -# include "me/str/str.h" -# include "me/types.h" -# include "me/vec/vec_ast.h" -# include "parser/api.h" -# include -# include - -t_ast_node ast_alloc(t_ast_node_kind kind); -t_error build_sym_case_item(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_case_statement(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_command(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_command_name(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_comment(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_compound_statement(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_elif_clause(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_else_clause(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_extglob_pattern(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_file_redirect(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_for_statement(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_function_definition(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_if_statement(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_list(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_negated_command(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_number(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_pipeline(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_program(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_raw_string(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_redirected_statement(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_regex(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_simple_expansion(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_string_content(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_subshell(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_variable_assignment(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_while_statement(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_word(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_expansion(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_command_substitution(\ - t_parse_node self, t_const_str input, t_ast_node *out); - -/* FUNCTION DONE BUT BY RAPH */ -t_error build_sym_arithmetic_binary_expression(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_arithmetic_literal(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_arithmetic_parenthesized_expression(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_arithmetic_postfix_expression(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_arithmetic_ternary_expression(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_arithmetic_unary_expression(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_arithmetic_expansion(\ - t_parse_node self, t_const_str input, t_ast_node *out); - -// TODO: This is my homework, -// it'll need to be handled in a special way I feel... -t_error build_sym_heredoc_redirect(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_simple_heredoc_body(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_heredoc_body(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_heredoc_content(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_heredoc_end(\ - t_parse_node self, t_const_str input, t_ast_node *out); -t_error build_sym_heredoc_start(\ - t_parse_node self, t_const_str input, t_ast_node *out); - -#endif diff --git a/ast/src/print_ast/ast_print_command.c b/ast/src/print_ast/ast_print_command.c index 37506cb3..74440433 100644 --- a/ast/src/print_ast/ast_print_command.c +++ b/ast/src/print_ast/ast_print_command.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "ast/_function_declaration.h" +#include "ast/_print_ast.h" void ast_print_node_command_substitution(t_ast_node self) { diff --git a/ast/src/print_ast/ast_print_global.c b/ast/src/print_ast/ast_print_global.c index c769b2fc..26945782 100644 --- a/ast/src/print_ast/ast_print_global.c +++ b/ast/src/print_ast/ast_print_global.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "ast/_function_declaration.h" +#include "ast/_print_ast.h" void ast_print_node_empty(t_ast_node self) { diff --git a/ast/src/print_ast/ast_print_node.c b/ast/src/print_ast/ast_print_node.c index 43514b76..49c3a487 100644 --- a/ast/src/print_ast/ast_print_node.c +++ b/ast/src/print_ast/ast_print_node.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "ast/_function_declaration.h" +#include "ast/_print_ast.h" void ast_print_node_variable_assignment(t_ast_node self) { diff --git a/ast/src/print_ast/ast_print_redirection.c b/ast/src/print_ast/ast_print_redirection.c index efa4008b..ac3d42a0 100644 --- a/ast/src/print_ast/ast_print_redirection.c +++ b/ast/src/print_ast/ast_print_redirection.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "ast/_function_declaration.h" +#include "ast/_print_ast.h" void ast_print_node_file_redirection_heredoc(t_ast_node self) { diff --git a/ast/src/print_ast/ast_print_subshell.c b/ast/src/print_ast/ast_print_subshell.c index 82b3731d..1a046ed2 100644 --- a/ast/src/print_ast/ast_print_subshell.c +++ b/ast/src/print_ast/ast_print_subshell.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "ast/_function_declaration.h" +#include "ast/_print_ast.h" void ast_print_node_subshell(t_ast_node self) { diff --git a/ast/src/print_ast/helper_function_print.c b/ast/src/print_ast/helper_function_print.c index 6c612cca..33f95a21 100644 --- a/ast/src/print_ast/helper_function_print.c +++ b/ast/src/print_ast/helper_function_print.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "ast/_function_declaration.h" +#include "ast/_print_ast.h" void _print_term(t_ast_terminator_kind term) { diff --git a/ast/src/print_ast/print_arithmetic.c b/ast/src/print_ast/print_arithmetic.c index 8c6ebf3d..1e0595f7 100644 --- a/ast/src/print_ast/print_arithmetic.c +++ b/ast/src/print_ast/print_arithmetic.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "ast/_function_declaration.h" +#include "ast/_print_ast.h" void ast_print_node_arithmetic_expansion(t_ast_node self) { diff --git a/ast/src/print_ast/print_ast.c b/ast/src/print_ast/print_ast.c index c7637845..ce44306d 100644 --- a/ast/src/print_ast/print_ast.c +++ b/ast/src/print_ast/print_ast.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "ast/_function_declaration.h" +#include "ast/_print_ast.h" /* t_ast_arithmetic_expansion arithmetic_expansion; diff --git a/input.toml b/input.toml index 92139bf6..634a2d7c 100644 --- a/input.toml +++ b/input.toml @@ -60,7 +60,7 @@ replace.C__PREFIXUP__ = "ENV" sources_output = "src/vec/C__PREFIX__/" headers_output = "include/me/vec/" replace.C__TYPENAME__ = "t_ast_node" -replace.C__TYPEHEADER__ = '#include "ast/ast_forward_def.h"' +replace.C__TYPEHEADER__ = '#include "ast/_forward_def.h"' replace.C__PREFIX__ = "ast" replace.C__PREFIXUP__ = "AST" diff --git a/output/include/me/vec/vec_ast.h b/output/include/me/vec/vec_ast.h index bf46ad02..a7c5f7bd 100644 --- a/output/include/me/vec/vec_ast.h +++ b/output/include/me/vec/vec_ast.h @@ -13,7 +13,7 @@ #ifndef VEC_AST_H #define VEC_AST_H -#include "ast/ast_forward_def.h" +#include "ast/_forward_def.h" #include "me/types.h" /// @brief A function that takes two t_ast_node and compare them