fix: now compiles and works for simple commands + clang format

This commit is contained in:
matteo 2026-01-17 19:11:55 +01:00 committed by william.valenduc
parent e9b6d39760
commit c299882586
23 changed files with 168 additions and 150 deletions

View file

@ -1,9 +1,11 @@
#define _POSIX_C_SOURCE 200809L
// === Includes
#include "parsing_utils.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include "lexer/lexer.h"
#include "utils/ast/ast.h"
@ -58,7 +60,8 @@ struct ast *parse_simple_command(void)
while (!isterminator(token))
{
token = POP_TOKEN();
command_elements = list_append(command_elements, token->data);
char *word = strdup(token->data);
command_elements = list_append(command_elements, word);
token = PEEK_TOKEN();
}
@ -86,6 +89,7 @@ struct ast *parse_list(void)
}
token = PEEK_TOKEN();
}
result_list = list_append(result_list, current_node);
return ast_create_list(result_list);
}
@ -163,7 +167,9 @@ struct ast *parse_compound_list(void)
return NULL;
}
command_elements = list_append(command_elements, token->data);
char *word = strdup(token->data);
command_elements = list_append(command_elements, word);
token = POP_TOKEN();
}