#include "parser.h" #include #include #include #include #include #include "lexer/lexer.h" #include "utils/lists/lists.h" // === Static functions // ... // === Functions struct ast *get_ast() { struct list *result_list = NULL; struct ast *current_node = NULL; struct token *token = peek_token(); while (token != NULL && token->type != TOKEN_EOF) { switch (token->type) { case TOKEN_WORD: struct ast *cmd = parse_simple_command(); result_list = list_append(result_list, cmd); break; default: // Forward token = pop_token(); break; } } if (token == NULL) { puts("Internal error: cannot get the following token"); return NULL; } struct ast *result = ast_create_list(result_list); return result; } // TODO struct ast *get_ast_str(char *command) { (void)command; return NULL; }