This commit is contained in:
Maieul BOYER 2024-05-29 16:41:40 +02:00
parent d16b39091a
commit ff1670e264
No known key found for this signature in database
15 changed files with 435 additions and 243 deletions

View file

@ -6,13 +6,12 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/28 18:36:40 by maiboyer #+# #+# */
/* Updated: 2024/05/18 16:14:55 by maiboyer ### ########.fr */
/* Updated: 2024/05/29 14:52:46 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "app/node.h"
#include "me/mem/mem.h"
#include "me/mem/mem.h"
#include "me/str/str.h"
#include "parser/api.h"
#include <stdio.h>
@ -24,6 +23,11 @@ t_const_str ts_node_type(t_parse_node self);
t_u32 ts_node_start_byte(t_parse_node self);
t_u32 ts_node_end_byte(t_parse_node self);
t_u32 ts_node_child_count(t_parse_node self);
t_const_str ts_node_field_name_for_child(t_parse_node self, t_u32 child_index);
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);
t_node *build_childs(t_parse_node parent, t_const_str input, t_usize count)
{
@ -39,6 +43,10 @@ t_node *build_childs(t_parse_node parent, t_const_str input, t_usize count)
{
child = ts_node_child(parent, idx);
ret[idx] = build_node(child, input);
ret[idx].field_str = ts_node_field_name_for_child(parent, idx);
ret[idx].field = ts_language_field_id_for_name(
tree_sitter_bash(), ret[idx].field_str,
str_len(ret[idx].field_str));
idx++;
}
return (ret);
@ -54,6 +62,7 @@ t_node build_node(t_parse_node curr, t_const_str input)
out.end = ts_node_end_byte(curr);
out.input = input;
out.single_str = NULL;
out.field_str = NULL;
out.childs_count = ts_node_child_count(curr);
if (out.childs_count == 0)
out.childs = NULL;