update: started to norme a bit more parser.c
This commit is contained in:
parent
86695aad14
commit
b264fae51a
9 changed files with 372 additions and 521 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/28 14:40:38 by rparodi #+# #+# */
|
||||
/* Updated: 2024/09/06 16:33:58 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/09/11 16:41:52 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -24,12 +24,13 @@
|
|||
#include "me/string/string.h"
|
||||
#include "me/types.h"
|
||||
#include "parser/api.h"
|
||||
#include "parser/inner/parser_inner.h"
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
t_error ast_from_node(t_parse_node node, t_str input, t_ast_node *out);
|
||||
t_error get_user_input(t_state *state);
|
||||
t_first_parser *create_myparser(void);
|
||||
t_first_parser *create_myparser(void);
|
||||
void ast_print_node(t_ast_node self);
|
||||
void ft_exit(t_state *maiboyerlpb, t_u8 exit_status);
|
||||
void exec_shcat(t_state *state);
|
||||
|
|
@ -40,13 +41,12 @@ void ft_take_args(t_state *state);
|
|||
// cle avant le =
|
||||
// data apres le =
|
||||
|
||||
t_language *tree_sitter_sh(void);
|
||||
void ast_free(t_ast_node node);
|
||||
t_language *tree_sitter_sh(void);
|
||||
void ast_free(t_ast_node node);
|
||||
|
||||
t_error split_str_first(\
|
||||
t_const_str s, char splitter, t_str *before, t_str *after)
|
||||
t_error split_str_first(t_const_str s, char splitter, t_str *before, t_str *after)
|
||||
{
|
||||
t_usize i;
|
||||
t_usize i;
|
||||
|
||||
if (s == NULL || before == NULL || after == NULL || splitter == '\0')
|
||||
return (ERROR);
|
||||
|
|
@ -62,9 +62,9 @@ t_error split_str_first(\
|
|||
return (NO_ERROR);
|
||||
}
|
||||
|
||||
t_error populate_env(t_hashmap_env *env, t_str envp[])
|
||||
t_error populate_env(t_hashmap_env *env, t_str envp[])
|
||||
{
|
||||
t_usize i;
|
||||
t_usize i;
|
||||
t_str temp[2];
|
||||
|
||||
i = 0;
|
||||
|
|
@ -83,13 +83,13 @@ t_error populate_env(t_hashmap_env *env, t_str envp[])
|
|||
return (NO_ERROR);
|
||||
}
|
||||
|
||||
void print_node_data(t_node *t, t_usize depth)
|
||||
void print_node_data(t_node *t, t_usize depth)
|
||||
{
|
||||
t_usize idx;
|
||||
t_usize idx;
|
||||
|
||||
idx = 0;
|
||||
if (t->kind == 7)
|
||||
return ;
|
||||
return;
|
||||
printf("\x1b[%im[%-6s](%lu)\x1b[0m", t->field_str == NULL ? 90 : 32, t->field_str == NULL ? "nil" : t->field_str, t->field);
|
||||
while (idx++ < depth + 1)
|
||||
printf("\t");
|
||||
|
|
@ -99,15 +99,14 @@ void print_node_data(t_node *t, t_usize depth)
|
|||
print_node_data(&t->childs[idx++], depth + 1);
|
||||
}
|
||||
|
||||
t_node parse_str(t_state *state)
|
||||
t_node parse_str(t_state *state)
|
||||
{
|
||||
t_first_tree *tree;
|
||||
t_parse_node node;
|
||||
t_node ret;
|
||||
t_ast_node out;
|
||||
t_first_tree *tree;
|
||||
t_parse_node node;
|
||||
t_node ret;
|
||||
t_ast_node out;
|
||||
|
||||
tree = ts_parser_parse_string(\
|
||||
state->parser, state->str_input, str_len(state->str_input));
|
||||
tree = ts_parser_parse_string(state->parser, state->str_input, str_len(state->str_input));
|
||||
node = ts_tree_root_node(tree);
|
||||
if (ast_from_node(node, state->str_input, &out))
|
||||
{
|
||||
|
|
@ -121,9 +120,9 @@ t_node parse_str(t_state *state)
|
|||
return (ret);
|
||||
}
|
||||
|
||||
t_i32 main(t_i32 argc, t_str argv[], t_str envp[])
|
||||
t_i32 main(t_i32 argc, t_str argv[], t_str envp[])
|
||||
{
|
||||
t_state state;
|
||||
t_state state;
|
||||
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue