lil shit
This commit is contained in:
parent
1d069092a2
commit
c6e426f235
9 changed files with 511 additions and 294 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/28 14:40:38 by rparodi #+# #+# */
|
||||
/* Updated: 2024/06/17 13:27:16 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/06/19 13:45:53 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -30,23 +30,14 @@
|
|||
|
||||
#include "ast/ast.h"
|
||||
|
||||
t_error from_node();
|
||||
|
||||
t_first_parser *ts_parser_new();
|
||||
void ts_tree_delete(t_first_tree *);
|
||||
t_parse_node ts_tree_root_node(t_first_tree *);
|
||||
t_first_tree *ts_parser_parse_string(t_first_parser *, t_first_tree *oldtree,
|
||||
t_const_str input, t_usize len);
|
||||
void ts_parser_delete(t_first_parser *self);
|
||||
void ts_parser_set_language(t_first_parser *self, t_language *lang);
|
||||
t_error from_node(t_parse_node *node, t_ast_node *out);
|
||||
|
||||
// Foutre envp dans env
|
||||
// Chaque elemenet d'envp split au premier =
|
||||
// cle avant le =
|
||||
// data apres le =
|
||||
|
||||
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;
|
||||
|
||||
|
|
@ -106,8 +97,7 @@ void print_node_data(t_node *t, t_usize depth)
|
|||
idx = 0;
|
||||
if (t->kind == 7)
|
||||
return;
|
||||
printf("\x1b[%im[%s](%lu)\x1b[0m", t->field_str == NULL ? 90 : 32,
|
||||
t->field_str == NULL ? "nil" : t->field_str, t->field);
|
||||
printf("\x1b[%im[%s](%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");
|
||||
idx = 0;
|
||||
|
|
@ -121,9 +111,13 @@ t_node parse_to_nodes(t_first_parser *parser, t_const_str input)
|
|||
t_first_tree *tree;
|
||||
t_parse_node node;
|
||||
t_node ret;
|
||||
t_ast_node out;
|
||||
|
||||
tree = ts_parser_parse_string(parser, NULL, input, str_len(input));
|
||||
node = ts_tree_root_node(tree);
|
||||
if (from_node(&node, &out))
|
||||
printf("Error when building node\n");
|
||||
(void)(out);
|
||||
ret = build_node(node, input);
|
||||
ts_tree_delete(tree);
|
||||
return (ret);
|
||||
|
|
@ -156,11 +150,9 @@ void print_node_concat(t_node *self)
|
|||
|
||||
void exec_shcat(t_utils *shcat)
|
||||
{
|
||||
t_i32 ret;
|
||||
t_ast_node out;
|
||||
t_i32 ret;
|
||||
|
||||
print_node_data(&shcat->current_node, 0);
|
||||
from_node(&shcat->current_node, &out);
|
||||
handle_program(&shcat->current_node, shcat, &ret);
|
||||
free_node(shcat->current_node);
|
||||
(void)ret;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/28 18:36:40 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/06/09 20:53:16 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/06/19 13:38:50 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -16,15 +16,7 @@
|
|||
#include "parser/api.h"
|
||||
#include <stdio.h>
|
||||
|
||||
t_const_str ts_node_field_name_for_child(t_parse_node self, t_u32 child_index);
|
||||
t_const_str ts_node_type(t_parse_node self);
|
||||
t_node build_node(t_parse_node current, t_const_str input);
|
||||
t_parse_node ts_node_named_child(t_parse_node parent, t_usize idx);
|
||||
t_symbol ts_node_symbol(t_parse_node self);
|
||||
t_u32 ts_node_end_byte(t_parse_node self);
|
||||
t_u32 ts_node_named_child_count(t_parse_node self);
|
||||
t_u32 ts_node_start_byte(t_parse_node self);
|
||||
t_u64 ts_language_field_id_for_name(t_language *lang, t_const_str name, t_u64 name_len);
|
||||
|
||||
t_language *tree_sitter_bash(void);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue