This commit is contained in:
Loic Deridder
2025-01-31 13:45:16 +01:00
parent 304eeb73eb
commit 17361832c1
8 changed files with 83 additions and 59 deletions

View File

@@ -3,10 +3,10 @@
/* ::: :::::::: */
/* linked_list.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/15 13:38:49 by nalebrun #+# #+# */
/* Updated: 2025/01/20 13:15:03 by nalebrun ### ########.fr */
/* Created: 2025/01/15 13:38:49 by lderidde #+# #+# */
/* Updated: 2025/01/31 13:20:13 by lderidde ### ########.fr */
/* */
/* ************************************************************************** */
@@ -30,19 +30,22 @@ t_node *create_node(char *val, t_token token)
int add_node_back(t_node **head, char *val, t_token token, t_pres pres)
{
t_node *tmp;
tmp = *head;
if (!val)
return (0);
if (!(*head))
if (!head || !(*head))
{
(*head) = create_node(val, token);
(*head)->pressision = pres;
return (1);
}
while ((*head)->next != NULL)
(*head) = (*head)->next;
(*head)->next = create_node(val, token);
(*head)->next->pressision = pres;
if ((*head)->next == NULL)
while (tmp->next != NULL)
tmp = tmp->next;
tmp->next = create_node(val, token);
tmp->next->pressision = pres;
if (tmp->next == NULL)
return (0);
return (1);
}

View File

@@ -3,10 +3,10 @@
/* ::: :::::::: */
/* tokenizer.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/15 13:27:57 by nalebrun #+# #+# */
/* Updated: 2025/01/20 13:15:25 by nalebrun ### ########.fr */
/* Created: 2025/01/15 13:27:57 by lderidde #+# #+# */
/* Updated: 2025/01/31 13:24:28 by lderidde ### ########.fr */
/* */
/* ************************************************************************** */
@@ -21,10 +21,8 @@ static t_node *tokenize_base(char *str)
tab = ft_split_keep(str, " \t\n");
if (!tab)
return (NULL);
head = create_node(tab[0], 0);
if (!head)
return (free(tab), NULL);
i = 1;
head = NULL;
i = 0;
while (tab[i])
{
if (!add_node_back(&head, tab[i], 0, 0))