started to make ast functions
This commit is contained in:
parent
1fae8e40be
commit
93f734f5e9
7 changed files with 413 additions and 136 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 19:30:30 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/05/26 17:55:39 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/05/28 14:49:05 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "ast/forward.h"
|
||||
#include "me/types.h"
|
||||
#include <iso646.h>
|
||||
|
||||
/// @brief Node types enumeration
|
||||
/// @details This enumeration is used to identify the type of a node
|
||||
|
|
@ -520,7 +521,7 @@ struct s_command_backticks
|
|||
};
|
||||
|
||||
union u_ast_node {
|
||||
t_ast_type ast_type;
|
||||
t_ast_type type;
|
||||
t_and_list and_list;
|
||||
t_and_or_list and_or_list;
|
||||
t_arithmetic_expansion arithmetic_expansion;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,27 @@
|
|||
typedef enum e_assignement_modifier t_assignement_modifier;
|
||||
typedef enum e_ast_type t_ast_type;
|
||||
typedef enum e_op_in t_op_in;
|
||||
typedef enum e_op_pre t_op_pre;
|
||||
typedef enum e_redirect_file_op t_redirect_file_op;
|
||||
typedef enum e_redirect_heredoc_op t_redirect_heredoc_op;
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* forward.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/28 13:24:34 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/05/28 13:51:40 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef FORWARD_H
|
||||
#define FORWARD_H
|
||||
|
||||
typedef union u_ast_node t_ast_node;
|
||||
|
||||
typedef enum e_assignement_modifier t_assignement_modifier;
|
||||
typedef enum e_ast_type t_ast_type;
|
||||
typedef enum e_op_in t_op_in;
|
||||
typedef enum e_op_pre t_op_pre;
|
||||
typedef enum e_redirect_file_op t_redirect_file_op;
|
||||
typedef enum e_redirect_heredoc_op t_redirect_heredoc_op;
|
||||
|
||||
typedef struct s_and_list t_and_list;
|
||||
typedef struct s_and_or_list t_and_or_list;
|
||||
typedef struct s_arithmetic_expansion t_arithmetic_expansion;
|
||||
|
|
@ -37,21 +55,23 @@ typedef struct s_simple_command t_simple_command;
|
|||
typedef struct s_subshell_command t_subshell_command;
|
||||
typedef struct s_until_command t_until_command;
|
||||
typedef struct s_while_command t_while_command;
|
||||
typedef struct s_word t_word;
|
||||
typedef union u_and_list_body t_and_list_body;
|
||||
typedef union u_and_or_list_body t_and_or_list_body;
|
||||
typedef union u_ast_node t_ast_node;
|
||||
typedef union u_async_command_body t_async_command_body;
|
||||
typedef union u_command_inner t_command_inner;
|
||||
typedef union u_compound_command t_compound_command;
|
||||
typedef union u_compound_list_body t_compound_list_body;
|
||||
typedef union u_expension_or_string t_expension_or_string;
|
||||
typedef union u_expension t_expension;
|
||||
typedef union u_if_clauses t_if_clauses;
|
||||
typedef union u_not_body t_not_body;
|
||||
typedef union u_or_list_body t_or_list_body;
|
||||
typedef union u_program_body t_program_body;
|
||||
typedef union u_redirect_or_assign t_redirect_or_assign;
|
||||
typedef union u_redirect_or_word t_redirect_or_word;
|
||||
typedef union u_redirect t_redirect;
|
||||
typedef union u_sequential_list_body t_sequential_list_body;
|
||||
typedef struct s_word t_word;
|
||||
|
||||
typedef union u_and_list_body t_and_list_body;
|
||||
typedef union u_and_or_list_body t_and_or_list_body;
|
||||
typedef union u_async_command_body t_async_command_body;
|
||||
typedef union u_command_inner t_command_inner;
|
||||
typedef union u_compound_command t_compound_command;
|
||||
typedef union u_compound_list_body t_compound_list_body;
|
||||
typedef union u_expension_or_string t_expension_or_string;
|
||||
typedef union u_expension t_expension;
|
||||
typedef union u_if_clauses t_if_clauses;
|
||||
typedef union u_not_body t_not_body;
|
||||
typedef union u_or_list_body t_or_list_body;
|
||||
typedef union u_program_body t_program_body;
|
||||
typedef union u_redirect_or_assign t_redirect_or_assign;
|
||||
typedef union u_redirect_or_word t_redirect_or_word;
|
||||
typedef union u_redirect t_redirect;
|
||||
typedef union u_sequential_list_body t_sequential_list_body;
|
||||
|
||||
#endif /* FORWARD_H */
|
||||
|
|
|
|||
199
ast/include/ast/from_node.h
Normal file
199
ast/include/ast/from_node.h
Normal file
|
|
@ -0,0 +1,199 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* from_node.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/28 13:14:10 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/05/29 00:54:00 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef FROM_PROGRAM_C
|
||||
#define FROM_PROGRAM_C
|
||||
|
||||
#include "me/types.h"
|
||||
|
||||
#include "app/node.h"
|
||||
#include "ast/ast.h"
|
||||
|
||||
t_ast_node *from_node(t_node *node);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_and_list *build_and_list(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_and_or_list *build_and_or_list(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_arithmetic_expansion *build_arithmetic_expansion(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_assignment_list *build_assignment_list(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_assignment *build_assignment(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_ast_string *build_ast_string(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_async_command *build_async_command(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_brace_command *build_brace_command(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_case_command *build_case_command(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_case_item *build_case_item(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_command_backticks *build_command_backticks(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_command_substitution *build_command_substitution(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_command *build_command(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_compound_list *build_compound_list(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_for_command *build_for_command(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_function_definition *build_function_definition(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_if_command *build_if_command(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_if_clause *build_if_clause(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_elif_clause *build_elif_clause(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_else_clause *build_else_clause(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_name *build_name(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_not *build_not(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_or_list *build_or_list(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_parameter_expansion *build_parameter_expansion(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_pipe_list *build_pipe_list(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_program *build_program(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_redirect_file *build_redirect_file(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_redirect_heredoc *build_redirect_heredoc(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_sequential_list *build_sequential_list(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_simple_command *build_simple_command(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_subshell_command *build_subshell_command(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_until_command *build_until_command(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_while_command *build_while_command(t_node *node, t_usize size);
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_word *build_word(t_node *node, t_usize size);
|
||||
|
||||
|
||||
/// @param node a pointer to an array of `t_node` of size `size`
|
||||
/// @param size the size of the nodes
|
||||
/// @note can be null in case of error
|
||||
t_ast_node *build_comment(t_node *node, t_usize size);
|
||||
|
||||
#endif /* FROM_NODE_C */
|
||||
Loading…
Add table
Add a link
Reference in a new issue