Adding norm to that fils

This commit is contained in:
Raphaël 2024-07-26 12:16:27 +02:00
parent e507d7fbf7
commit 1ca0aeb072
9 changed files with 437 additions and 396 deletions

View file

@ -9,11 +9,11 @@ me_alloc/merge_blocks \
me_alloc/pages \ me_alloc/pages \
me_alloc/realloc \ me_alloc/realloc \
vg/dummy_block \ vg/dummy_block \
vg/dummy_mem_status \
vg/dummy_mempool \ vg/dummy_mempool \
vg/dummy_mempool_bis \ vg/dummy_mempool_bis \
vg/dummy_mem_status \
vg/valgrind_block \ vg/valgrind_block \
vg/valgrind_mem_status \
vg/valgrind_mempool \ vg/valgrind_mempool \
vg/valgrind_mempool_bis \ vg/valgrind_mempool_bis \
vg/valgrind_mem_status \

View file

@ -1,5 +1,6 @@
SRC_FILES = \ SRC_FILES = \
from_node \ from_node \
not_done_function \ not_done_function \
not_done_print \
print_ast \ print_ast \

View file

@ -0,0 +1,67 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* function_declaration.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/26 11:30:24 by rparodi #+# #+# */
/* Updated: 2024/07/26 11:38:39 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FUNCTION_DECLARATION_H
# define FUNCTION_DECLARATION_H
#include "ast/ast.h"
#include "me/types.h"
#include <stdio.h>
#define NOT_DONE \
{ \
printf("function `%s` isn't done !\n", __func__); \
(void)(self); \
}
void ast_print_node(t_ast_node self);
void ast_print_node_command(t_ast_node self);
void ast_print_node_command_substitution(t_ast_node self);
void ast_print_node_compound_statement(t_ast_node self);
void ast_print_node_expansion(t_ast_node self);
void ast_print_node_extglob(t_ast_node self);
void ast_print_node_file_redirection(t_ast_node self);
void ast_print_node_list(t_ast_node self);
void ast_print_node_pipeline(t_ast_node self);
void ast_print_node_program(t_ast_node self);
void ast_print_node_raw_string(t_ast_node self);
void ast_print_node_regex(t_ast_node self);
void ast_print_node_subshell(t_ast_node self);
void ast_print_node_variable_assignment(t_ast_node self);
void ast_print_node_word(t_ast_node self);
void ast_print_node_function_definition(t_ast_node self);
void ast_print_node_arithmetic_expansion(t_ast_node self);
void ast_print_node_function_definition(t_ast_node self);
void ast_print_node_variable_assignment(t_ast_node self);
void ast_print_node_pipeline(t_ast_node self);
void ast_print_node_list(t_ast_node self);
/*^^^ DONE ^^^*/
/*vvv NOT DONE vvv*/
void ast_print_node_if(t_ast_node self) NOT_DONE;
void ast_print_node_case(t_ast_node self) NOT_DONE;
void ast_print_node_case_item(t_ast_node self) NOT_DONE;
void ast_print_node_elif(t_ast_node self) NOT_DONE;
void ast_print_node_else(t_ast_node self) NOT_DONE;
void ast_print_node_for(t_ast_node self) NOT_DONE;
void ast_print_node_until(t_ast_node self) NOT_DONE;
void ast_print_node_while(t_ast_node self) NOT_DONE;
void ast_print_node_heredoc_redirection(t_ast_node self) NOT_DONE;
/// HELPER_FUNCS
void _print_term(t_ast_terminator_kind term);
#endif

File diff suppressed because it is too large Load diff

13
ast/src/not_done_print.c Normal file
View file

@ -0,0 +1,13 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* not_done_print.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/26 11:00:25 by rparodi #+# #+# */
/* Updated: 2024/07/26 11:33:01 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */ /* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/03 20:38:29 by maiboyer #+# #+# */ /* Created: 2024/07/03 20:38:29 by maiboyer #+# #+# */
/* Updated: 2024/07/25 11:05:38 by rparodi ### ########.fr */ /* Updated: 2024/07/26 11:36:30 by rparodi ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,13 +14,7 @@
#include "me/types.h" #include "me/types.h"
#include <stdio.h> #include <stdio.h>
void ast_print_node(t_ast_node self); #include "../include/function_declaration.h"
#define NOT_DONE \
{ \
printf("function `%s` isn't done !\n", __func__); \
(void)(self); \
}
/* /*
t_ast_arithmetic_expansion arithmetic_expansion; t_ast_arithmetic_expansion arithmetic_expansion;
@ -51,42 +45,15 @@ t_ast_while while_;
t_ast_word word; t_ast_word word;
*/ */
void ast_print_node_command(t_ast_node self);
void ast_print_node_command_substitution(t_ast_node self);
void ast_print_node_compound_statement(t_ast_node self);
void ast_print_node_expansion(t_ast_node self);
void ast_print_node_extglob(t_ast_node self);
void ast_print_node_file_redirection(t_ast_node self);
void ast_print_node_list(t_ast_node self);
void ast_print_node_pipeline(t_ast_node self);
void ast_print_node_program(t_ast_node self);
void ast_print_node_raw_string(t_ast_node self);
void ast_print_node_regex(t_ast_node self);
void ast_print_node_subshell(t_ast_node self);
void ast_print_node_variable_assignment(t_ast_node self);
void ast_print_node_word(t_ast_node self);
void ast_print_node_function_definition(t_ast_node self);
/*^^^ DONE ^^^*/ /*^^^ DONE ^^^*/
/*vvv NOT DONE vvv*/
void ast_print_node_if(t_ast_node self) NOT_DONE;
void ast_print_node_case(t_ast_node self) NOT_DONE;
void ast_print_node_case_item(t_ast_node self) NOT_DONE;
void ast_print_node_elif(t_ast_node self) NOT_DONE;
void ast_print_node_else(t_ast_node self) NOT_DONE;
void ast_print_node_for(t_ast_node self) NOT_DONE;
void ast_print_node_until(t_ast_node self) NOT_DONE;
void ast_print_node_while(t_ast_node self) NOT_DONE;
void ast_print_node_heredoc_redirection(t_ast_node self) NOT_DONE;
/// HELPER_FUNCS /// HELPER_FUNCS
void _print_term(t_ast_terminator_kind term) void _print_term(t_ast_terminator_kind term)
{ {
if (term == AST_TERM_NONE) if (term == AST_TERM_NONE)
return; return ;
if (term == AST_TERM_SEMI) if (term == AST_TERM_SEMI)
printf(";"); printf(";");
if (term == AST_TERM_DOUBLE_SEMI) if (term == AST_TERM_DOUBLE_SEMI)
@ -97,12 +64,12 @@ void _print_term(t_ast_terminator_kind term)
/// IMPL /// IMPL
// void ast_print_node_if(t_ast_node self) // void ast_print_node_if(t_ast_node self)
// { // {
// //
// } // }
void ast_print_node_arithmetic_expansion(t_ast_node self) void ast_print_node_arithmetic_expansion(t_ast_node self)
{ {
if (self == NULL) if (self == NULL)
return ; return ;
@ -113,13 +80,14 @@ void ast_print_node_arithmetic_expansion(t_ast_node self)
printf("))"); printf("))");
} }
void ast_print_node_function_definition(t_ast_node self) void ast_print_node_function_definition(t_ast_node self)
{ {
t_usize i; t_usize i;
if (self == NULL) if (self == NULL)
return ; return ;
if (self->kind != AST_FUNCTION_DEFINITION) if (self->kind != AST_FUNCTION_DEFINITION)
return; return ;
printf("%s()", self->data.function_definition.name); printf("%s()", self->data.function_definition.name);
i = 0; i = 0;
while (i < self->data.function_definition.body.len) while (i < self->data.function_definition.body.len)
@ -129,12 +97,12 @@ void ast_print_node_function_definition(t_ast_node self)
} }
} }
void ast_print_node_variable_assignment(t_ast_node self) void ast_print_node_variable_assignment(t_ast_node self)
{ {
if (self == NULL) if (self == NULL)
return; return ;
if (self->kind != AST_VARIABLE_ASSIGNMENT) if (self->kind != AST_VARIABLE_ASSIGNMENT)
return; return ;
if (self->data.variable_assignment.bang) if (self->data.variable_assignment.bang)
printf("! "); printf("! ");
printf("%s=", self->data.variable_assignment.name); printf("%s=", self->data.variable_assignment.name);
@ -143,14 +111,14 @@ void ast_print_node_variable_assignment(t_ast_node self)
printf(" "); printf(" ");
} }
void ast_print_node_pipeline(t_ast_node self) void ast_print_node_pipeline(t_ast_node self)
{ {
t_usize i; t_usize i;
if (self == NULL) if (self == NULL)
return; return ;
if (self->kind != AST_PIPELINE) if (self->kind != AST_PIPELINE)
return; return ;
if (self->data.pipeline.bang) if (self->data.pipeline.bang)
printf("! "); printf("! ");
if (self->data.pipeline.statements.len != 0) if (self->data.pipeline.statements.len != 0)
@ -167,17 +135,19 @@ void ast_print_node_pipeline(t_ast_node self)
while (i < self->data.pipeline.suffixes_redirections.len) while (i < self->data.pipeline.suffixes_redirections.len)
{ {
printf(" "); printf(" ");
ast_print_node(self->data.pipeline.suffixes_redirections.buffer[i++]); } _print_term(self->data.pipeline.term); ast_print_node(self->data.pipeline.suffixes_redirections.buffer[i++]);
}
_print_term(self->data.pipeline.term);
} }
void ast_print_node_list(t_ast_node self) void ast_print_node_list(t_ast_node self)
{ {
t_usize i; t_usize i;
if (self == NULL) if (self == NULL)
return; return ;
if (self->kind != AST_LIST) if (self->kind != AST_LIST)
return; return ;
ast_print_node(self->data.list.left); ast_print_node(self->data.list.left);
if (self->data.list.op == AST_LIST_OR) if (self->data.list.op == AST_LIST_OR)
printf(" || "); printf(" || ");
@ -193,24 +163,23 @@ void ast_print_node_list(t_ast_node self)
_print_term(self->data.list.term); _print_term(self->data.list.term);
} }
void ast_print_node_extglob(t_ast_node self) void ast_print_node_extglob(t_ast_node self)
{ {
if (self == NULL) if (self == NULL)
return; return ;
if (self->kind != AST_EXTGLOB) if (self->kind != AST_EXTGLOB)
return; return ;
printf("%s", self->data.extglob.pattern); printf("%s", self->data.extglob.pattern);
} }
void ast_print_node_file_redirection(t_ast_node self) void ast_print_node_file_redirection(t_ast_node self)
{ {
if (self == NULL) if (self == NULL)
return; return ;
if (self->kind != AST_FILE_REDIRECTION) if (self->kind != AST_FILE_REDIRECTION)
return; return ;
if (self->data.file_redirection.input != NULL) if (self->data.file_redirection.input != NULL)
ast_print_node(self->data.file_redirection.input); ast_print_node(self->data.file_redirection.input);
if (self->data.file_redirection.op == AST_REDIR_INPUT) if (self->data.file_redirection.op == AST_REDIR_INPUT)
printf("<"); printf("<");
if (self->data.file_redirection.op == AST_REDIR_OUTPUT) if (self->data.file_redirection.op == AST_REDIR_OUTPUT)
@ -229,19 +198,18 @@ void ast_print_node_file_redirection(t_ast_node self)
// printf("<<"); // printf("<<");
// if (self->data.file_redirection.op == AST_REDIR_HEREDOC_INDENT) // if (self->data.file_redirection.op == AST_REDIR_HEREDOC_INDENT)
// printf("<<-"); // printf("<<-");
if (self->data.file_redirection.output != NULL) if (self->data.file_redirection.output != NULL)
ast_print_node(self->data.file_redirection.output); ast_print_node(self->data.file_redirection.output);
} }
void ast_print_node_expansion(t_ast_node self) void ast_print_node_expansion(t_ast_node self)
{ {
t_usize i; t_usize i;
if (self == NULL) if (self == NULL)
return; return ;
if (self->kind != AST_EXPANSION) if (self->kind != AST_EXPANSION)
return; return ;
printf("${"); printf("${");
if (self->data.expansion.len_operator) if (self->data.expansion.len_operator)
printf("#"); printf("#");
@ -272,14 +240,14 @@ void ast_print_node_expansion(t_ast_node self)
printf("}"); printf("}");
} }
void ast_print_node_command_substitution(t_ast_node self) void ast_print_node_command_substitution(t_ast_node self)
{ {
t_usize i; t_usize i;
if (self == NULL) if (self == NULL)
return; return ;
if (self->kind != AST_COMMAND_SUBSTITUTION) if (self->kind != AST_COMMAND_SUBSTITUTION)
return; return ;
printf("$("); printf("$(");
i = 0; i = 0;
while (i < self->data.command_substitution.body.len) while (i < self->data.command_substitution.body.len)
@ -289,14 +257,14 @@ void ast_print_node_command_substitution(t_ast_node self)
printf(")"); printf(")");
} }
void ast_print_node_command(t_ast_node self) void ast_print_node_command(t_ast_node self)
{ {
t_usize i; t_usize i;
if (self == NULL) if (self == NULL)
return; return ;
if (self->kind != AST_COMMAND) if (self->kind != AST_COMMAND)
return; return ;
if (self->data.command.bang) if (self->data.command.bang)
printf("! "); printf("! ");
i = 0; i = 0;
@ -320,22 +288,22 @@ void ast_print_node_command(t_ast_node self)
_print_term(self->data.command.term); _print_term(self->data.command.term);
} }
void ast_print_node_empty(t_ast_node self) void ast_print_node_empty(t_ast_node self)
{ {
if (self == NULL) if (self == NULL)
return; return ;
if (self->kind != AST_EMPTY) if (self->kind != AST_EMPTY)
return; return ;
} }
void ast_print_node_compound_statement(t_ast_node self) void ast_print_node_compound_statement(t_ast_node self)
{ {
t_usize i; t_usize i;
if (self == NULL) if (self == NULL)
return; return ;
if (self->kind != AST_COMPOUND_STATEMENT) if (self->kind != AST_COMPOUND_STATEMENT)
return; return ;
i = 0; i = 0;
if (self->data.compound_statement.bang) if (self->data.compound_statement.bang)
printf("! "); printf("! ");
@ -356,14 +324,14 @@ void ast_print_node_compound_statement(t_ast_node self)
_print_term(self->data.compound_statement.term); _print_term(self->data.compound_statement.term);
} }
void ast_print_node_subshell(t_ast_node self) void ast_print_node_subshell(t_ast_node self)
{ {
t_usize i; t_usize i;
if (self == NULL) if (self == NULL)
return; return ;
if (self->kind != AST_SUBSHELL) if (self->kind != AST_SUBSHELL)
return; return ;
i = 0; i = 0;
if (self->data.subshell.bang) if (self->data.subshell.bang)
printf("! "); printf("! ");
@ -384,14 +352,14 @@ void ast_print_node_subshell(t_ast_node self)
_print_term(self->data.subshell.term); _print_term(self->data.subshell.term);
} }
void ast_print_node_program(t_ast_node self) void ast_print_node_program(t_ast_node self)
{ {
t_usize i; t_usize i;
if (self == NULL) if (self == NULL)
return; return ;
if (self->kind != AST_PROGRAM) if (self->kind != AST_PROGRAM)
return; return ;
i = 0; i = 0;
while (i < self->data.program.body.len) while (i < self->data.program.body.len)
{ {
@ -400,15 +368,15 @@ void ast_print_node_program(t_ast_node self)
} }
} }
void ast_print_node_word(t_ast_node self) void ast_print_node_word(t_ast_node self)
{ {
t_usize i; t_usize i;
t_str quote_type; t_str quote_type;
if (self == NULL) if (self == NULL)
return; return ;
if (self->kind != AST_WORD) if (self->kind != AST_WORD)
return; return ;
quote_type = ""; quote_type = "";
if (self->data.word.kind == AST_WORD_SINGLE_QUOTE) if (self->data.word.kind == AST_WORD_SINGLE_QUOTE)
quote_type = "\'"; quote_type = "\'";
@ -421,25 +389,25 @@ void ast_print_node_word(t_ast_node self)
printf("%s", quote_type); printf("%s", quote_type);
} }
void ast_print_node_regex(t_ast_node self) void ast_print_node_regex(t_ast_node self)
{ {
if (self == NULL) if (self == NULL)
return; return ;
if (self->kind != AST_REGEX) if (self->kind != AST_REGEX)
return; return ;
printf("%s", self->data.regex.pattern); printf("%s", self->data.regex.pattern);
} }
void ast_print_node_raw_string(t_ast_node self) void ast_print_node_raw_string(t_ast_node self)
{ {
if (self == NULL) if (self == NULL)
return; return ;
if (self->kind != AST_RAW_STRING) if (self->kind != AST_RAW_STRING)
return; return ;
printf("%s", self->data.raw_string.str); printf("%s", self->data.raw_string.str);
} }
void ast_print_node(t_ast_node self) void ast_print_node(t_ast_node self)
{ {
if (self == NULL) if (self == NULL)
return ((void)printf("ast == NULL\n")); return ((void)printf("ast == NULL\n"));

View file

@ -2,9 +2,9 @@ SRC_FILES = \
line \ line \
line_edit_actions \ line_edit_actions \
line_edit_actions2 \ line_edit_actions2 \
line_edit_mode \
line_editing \ line_editing \
line_editing2 \ line_editing2 \
line_edit_mode \
line_globals \ line_globals \
line_history \ line_history \
line_internals \ line_internals \

View file

@ -114,6 +114,28 @@ primary_state_ids/primary_state_ids_18 \
primary_state_ids/primary_state_ids_19 \ primary_state_ids/primary_state_ids_19 \
primary_state_ids/primary_state_ids_20 \ primary_state_ids/primary_state_ids_20 \
primary_state_ids/primary_state_ids_21 \ primary_state_ids/primary_state_ids_21 \
small_parse_table_map/small_parse_table_map_0 \
small_parse_table_map/small_parse_table_map_1 \
small_parse_table_map/small_parse_table_map_2 \
small_parse_table_map/small_parse_table_map_3 \
small_parse_table_map/small_parse_table_map_4 \
small_parse_table_map/small_parse_table_map_5 \
small_parse_table_map/small_parse_table_map_6 \
small_parse_table_map/small_parse_table_map_7 \
small_parse_table_map/small_parse_table_map_8 \
small_parse_table_map/small_parse_table_map_9 \
small_parse_table_map/small_parse_table_map_10 \
small_parse_table_map/small_parse_table_map_11 \
small_parse_table_map/small_parse_table_map_12 \
small_parse_table_map/small_parse_table_map_13 \
small_parse_table_map/small_parse_table_map_14 \
small_parse_table_map/small_parse_table_map_15 \
small_parse_table_map/small_parse_table_map_16 \
small_parse_table_map/small_parse_table_map_17 \
small_parse_table_map/small_parse_table_map_18 \
small_parse_table_map/small_parse_table_map_19 \
small_parse_table_map/small_parse_table_map_20 \
small_parse_table_map/small_parse_table_map_21 \
small_parse_table/small_parse_table_0 \ small_parse_table/small_parse_table_0 \
small_parse_table/small_parse_table_1 \ small_parse_table/small_parse_table_1 \
small_parse_table/small_parse_table_2 \ small_parse_table/small_parse_table_2 \
@ -946,28 +968,6 @@ small_parse_table/small_parse_table_828 \
small_parse_table/small_parse_table_829 \ small_parse_table/small_parse_table_829 \
small_parse_table/small_parse_table_830 \ small_parse_table/small_parse_table_830 \
small_parse_table/small_parse_table_831 \ small_parse_table/small_parse_table_831 \
small_parse_table_map/small_parse_table_map_0 \
small_parse_table_map/small_parse_table_map_1 \
small_parse_table_map/small_parse_table_map_2 \
small_parse_table_map/small_parse_table_map_3 \
small_parse_table_map/small_parse_table_map_4 \
small_parse_table_map/small_parse_table_map_5 \
small_parse_table_map/small_parse_table_map_6 \
small_parse_table_map/small_parse_table_map_7 \
small_parse_table_map/small_parse_table_map_8 \
small_parse_table_map/small_parse_table_map_9 \
small_parse_table_map/small_parse_table_map_10 \
small_parse_table_map/small_parse_table_map_11 \
small_parse_table_map/small_parse_table_map_12 \
small_parse_table_map/small_parse_table_map_13 \
small_parse_table_map/small_parse_table_map_14 \
small_parse_table_map/small_parse_table_map_15 \
small_parse_table_map/small_parse_table_map_16 \
small_parse_table_map/small_parse_table_map_17 \
small_parse_table_map/small_parse_table_map_18 \
small_parse_table_map/small_parse_table_map_19 \
small_parse_table_map/small_parse_table_map_20 \
small_parse_table_map/small_parse_table_map_21 \
symbols_metadata/symbols_metadata_0 \ symbols_metadata/symbols_metadata_0 \
symbols_metadata/symbols_metadata_1 \ symbols_metadata/symbols_metadata_1 \
symbols_names/symbols_names_0 \ symbols_names/symbols_names_0 \

View file

@ -38,10 +38,10 @@ fs/read \
fs/read_to_vec \ fs/read_to_vec \
fs/write \ fs/write \
gnl/get_next_line \ gnl/get_next_line \
hash/hasher \
hash/hash_signed \ hash/hash_signed \
hash/hash_str \ hash/hash_str \
hash/hash_unsigned \ hash/hash_unsigned \
hash/hasher \
hash/sip/sip13 \ hash/sip/sip13 \
hash/sip/sip_utils \ hash/sip/sip_utils \
hash/sip/sip_utils2 \ hash/sip/sip_utils2 \
@ -89,6 +89,10 @@ printf/printf \
printf/printf_fd \ printf/printf_fd \
printf/printf_str \ printf/printf_str \
printf/vprintf \ printf/vprintf \
string/mod \
string/string_insert \
string/string_remove \
string/string_reserve \
str/str_clone \ str/str_clone \
str/str_compare \ str/str_compare \
str/str_find_chr \ str/str_find_chr \
@ -105,10 +109,6 @@ str/str_n_find_str \
str/str_split \ str/str_split \
str/str_substring \ str/str_substring \
str/str_trim \ str/str_trim \
string/mod \
string/string_insert \
string/string_remove \
string/string_reserve \
GEN_FILES = \ GEN_FILES = \
convert/i16_to_str \ convert/i16_to_str \