parser V[chepa combien]
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* tokenizer_utils.c :+: :+: :+: */
|
||||
/* linked_list.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
||||
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/01/15 13:38:49 by nalebrun #+# #+# */
|
||||
/* Updated: 2025/01/15 13:38:49 by nalebrun ### ########.fr */
|
||||
/* Created: 2025/01/15 13:38:49 by nalebrun #+# #+# */
|
||||
/* Updated: 2025/01/20 13:15:03 by nalebrun ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -41,20 +41,20 @@ int add_node_back(t_node *head, char *val, t_token token)
|
||||
|
||||
void free_linked_list(t_node *head)
|
||||
{
|
||||
t_node *tmp;
|
||||
t_node *tmp;
|
||||
|
||||
while (head)
|
||||
{
|
||||
tmp = head;
|
||||
head = head->next;
|
||||
free(tmp->val);
|
||||
free(tmp);
|
||||
}
|
||||
while (head)
|
||||
{
|
||||
tmp = head;
|
||||
head = head->next;
|
||||
free(tmp->val);
|
||||
free(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
int create_node_after(t_node *elem, char *val)
|
||||
{
|
||||
t_node *tmp_next;
|
||||
t_node *tmp_next;
|
||||
|
||||
tmp_next = elem->next;
|
||||
elem->next = create_node(val, 0);
|
||||
@@ -64,25 +64,45 @@ int create_node_after(t_node *elem, char *val)
|
||||
return (1);
|
||||
}
|
||||
|
||||
// have to be deleted after
|
||||
void debug_linked_list(t_node *head, char *msg)
|
||||
int merge_with_next_node(t_node *node)
|
||||
{
|
||||
t_node *current = head;
|
||||
char *token;
|
||||
char *tmp_val;
|
||||
t_node *tmp_next;
|
||||
|
||||
printf("----------------------------------------{%s} \n", msg);
|
||||
while (current != NULL) {
|
||||
tmp_val = ft_strjoin(node->val, node->next->val);
|
||||
if (!tmp_val)
|
||||
return (0);
|
||||
ft_free(&node->val);
|
||||
node->val = tmp_val;
|
||||
ft_free(&node->next->val);
|
||||
tmp_next = node->next->next;
|
||||
free(node->next);
|
||||
node->next = tmp_next;
|
||||
return (1);
|
||||
}
|
||||
|
||||
// have to be deleted after
|
||||
void debug_linked_list(t_node *head, char *msg)
|
||||
{
|
||||
t_node *current;
|
||||
char *token;
|
||||
|
||||
current = head;
|
||||
printf("----------------------------------------------------------{%s} \n",
|
||||
msg);
|
||||
while (current != NULL)
|
||||
{
|
||||
if (current->token == OPERATOR)
|
||||
token = ft_strdup("OPERATOR");
|
||||
else if (current->token == WORD)
|
||||
token = ft_strdup("WORD");
|
||||
token = ft_strdup("WORD ");
|
||||
else if (current->token == UNSET)
|
||||
token = ft_strdup("UNSET");
|
||||
token = ft_strdup("UNSET ");
|
||||
else
|
||||
token = ft_strdup("???");
|
||||
printf("| Node - TOKEN: %s -> val: |%s|\n", token, current->val);
|
||||
token = ft_strdup("??? ");
|
||||
printf("| Node - TOKEN: %s -> val: |%s|\n", token, current->val);
|
||||
free(token);
|
||||
current = current->next;
|
||||
}
|
||||
printf("----------------------------------------\n\n");
|
||||
current = current->next;
|
||||
}
|
||||
printf("----------------------------------------------------------\n\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user