From 1fec66236f1811a3eeac673d0002fe8d9d3d8835 Mon Sep 17 00:00:00 2001 From: Dominik Kaiser Date: Tue, 17 Sep 2024 19:25:13 +0200 Subject: Fix error message printing --- src/parser.c | 40 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) (limited to 'src/parser.c') diff --git a/src/parser.c b/src/parser.c index 6993a1f..06c1df7 100644 --- a/src/parser.c +++ b/src/parser.c @@ -6,43 +6,29 @@ /* By: dkaiser next = ft_lstnew(parse_statement(current_tokens)); - current = current->next; - } - if (current == NULL) - return (ft_lstclear(&result, free_node_wrapper), NULL); - current_tokens = split_at_first(&tokens, NEWLINE_TOKEN); - } - return (result); + if ((*tokens).type == PIPE_TOKEN) + result = NULL; + else + result = parse_statement(tokens); + if (result == NULL) + printf("Parsing error.\n"); + return (ft_lstnew(result)); } static t_node *parse_statement(t_token *tokens) @@ -53,7 +39,6 @@ static t_node *parse_statement(t_token *tokens) if (left_side_tokens == NULL) { free_tokens(tokens); - printf("Parsing error.\n"); return (NULL); } else if (tokens != NULL) @@ -97,8 +82,3 @@ static t_token *find_token_by_type(t_token *tokens, int type) } return (NULL); } - -static void free_node_wrapper(void *node) -{ - free_node((t_node *)node); -} -- cgit v1.2.3