Norming the ast/from_node

This commit is contained in:
Raphaël 2024-09-02 11:35:48 +02:00
parent 00546417ff
commit 4f66a053a3

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */ /* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/09 15:07:10 by rparodi #+# #+# */ /* Created: 2024/08/09 15:07:10 by rparodi #+# #+# */
/* Updated: 2024/08/14 17:28:46 by maiboyer ### ########.fr */ /* Updated: 2024/09/02 11:35:32 by rparodi ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -20,7 +20,8 @@
#include "parser/api.h" #include "parser/api.h"
#include <stdio.h> #include <stdio.h>
t_error build_sym_negated_command(t_parse_node self, t_const_str input, t_ast_node *out) t_error build_sym_negated_command(\
t_parse_node self, t_const_str input, t_ast_node *out)
{ {
t_ast_node ret; t_ast_node ret;
@ -39,7 +40,8 @@ t_error build_sym_negated_command(t_parse_node self, t_const_str input, t_ast_no
return (*out = ret, NO_ERROR); return (*out = ret, NO_ERROR);
} }
t_error build_sym_pipeline(t_parse_node self, t_const_str input, t_ast_node *out) t_error build_sym_pipeline(\
t_parse_node self, t_const_str input, t_ast_node *out)
{ {
t_ast_node ret; t_ast_node ret;
t_ast_node tmp; t_ast_node tmp;
@ -58,7 +60,7 @@ t_error build_sym_pipeline(t_parse_node self, t_const_str input, t_ast_node *out
while (i < ts_node_child_count(self)) while (i < ts_node_child_count(self))
{ {
if (!ts_node_is_named(ts_node_child(self, i)) && (i++, true)) if (!ts_node_is_named(ts_node_child(self, i)) && (i++, true))
continue; continue ;
if (ast_from_node(ts_node_child(self, i), input, &tmp)) if (ast_from_node(ts_node_child(self, i), input, &tmp))
return (ast_free(ret), ERROR); return (ast_free(ret), ERROR);
if (tmp->kind == AST_PIPELINE) if (tmp->kind == AST_PIPELINE)
@ -87,7 +89,8 @@ t_error build_sym_comment(t_parse_node self, t_const_str input, t_ast_node *out)
return (NO_ERROR); return (NO_ERROR);
} }
t_error build_sym_variable_assignment(t_parse_node self, t_const_str input, t_ast_node *out) t_error build_sym_variable_assignment(\
t_parse_node self, t_const_str input, t_ast_node *out)
{ {
t_ast_node ret; t_ast_node ret;
t_parse_node temp_ast; t_parse_node temp_ast;
@ -109,7 +112,8 @@ t_error build_sym_variable_assignment(t_parse_node self, t_const_str input, t_as
} }
if (ts_node_child_count(self) > 2) if (ts_node_child_count(self) > 2)
{ {
if (ast_from_node(ts_node_child(self, 2), input, &ret->data.variable_assignment.value)) if (ast_from_node(ts_node_child(\
self, 2), input, &ret->data.variable_assignment.value))
return (ast_free(ret), ERROR); return (ast_free(ret), ERROR);
} }
return (*out = ret, NO_ERROR); return (*out = ret, NO_ERROR);