norming: adding ast/from_node to norm

This commit is contained in:
Raphaël 2024-09-06 11:04:00 +02:00
parent 38fc882915
commit 7ed0c2288a
2 changed files with 11 additions and 8 deletions

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/02 16:37:28 by rparodi #+# #+# */
/* Updated: 2024/09/02 16:39:15 by rparodi ### ########.fr */
/* Updated: 2024/09/06 10:53:13 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
@ -26,19 +26,23 @@ t_error build_sym_heredoc_redirect(t_parse_node self, t_const_str input, \
t_ast_node ret;
t_usize i;
if (ts_node_symbol(self) != sym_heredoc_redirect || input == NULL || out == NULL)
if (ts_node_symbol(self) != sym_heredoc_redirect || \
input == NULL || out == NULL)
return (ERROR);
ret = ast_alloc(AST_HEREDOC_REDIRECTION);
i = 0;
while (i < ts_node_child_count(self))
{
if (ts_node_field_id_for_child(self, i) == field_op)
ret->data.heredoc_redirection.op = _get_redirection_op(ts_node_child(self, i));
ret->data.heredoc_redirection.op = \
_get_redirection_op(ts_node_child(self, i));
else if (ts_node_symbol(ts_node_child(self, i)) == sym_heredoc_start)
ret->data.heredoc_redirection.delimiter = _extract_str(ts_node_child(self, i), input);
ret->data.heredoc_redirection.delimiter = \
_extract_str(ts_node_child(self, i), input);
else if (ts_node_symbol(ts_node_child(self, i)) == sym_heredoc_body)
ret->data.heredoc_redirection.content = _extract_str(ts_node_child(self, i), input);
ret->data.heredoc_redirection.content = \
_extract_str(ts_node_child(self, i), input);
i++;
}
return (*out = ret, NO_ERROR);
}
}

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/26 10:55:52 by rparodi #+# #+# */
/* Updated: 2024/09/03 15:48:47 by maiboyer ### ########.fr */
/* Updated: 2024/09/06 11:02:57 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
@ -141,7 +141,6 @@ t_error build_sym_list(t_parse_node self, t_const_str input, t_ast_node *out)
return (*out = ret, NO_ERROR);
}
t_error ast_from_node(\
t_parse_node node, t_const_str input, t_ast_node *out)
{