#include "parser.h" #include #include #include #include #include #include "lexer/lexer.h" #include "utils/lists/lists.h" // === Static functions /* Returns true if c is a command terminator, false otherwise */ static bool isterminator(char c) { switch (c) { case '\n': case ';': case EOF: return true; default: return false; } } /* Parses a simple list of words (command and arguments) * and returns the resulting ast */ // === Functions struct ast *get_ast() { struct list *result_list = NULL; struct ast *current_node = NULL; char *token = peek_token(); if (token != NULL) { puts("Internal error: cannot get the following token"); return NULL; } while (token[0] != EOF) { struct ast *cmd = parse_simple_command(); result_list = list_append(result_list, cmd); } struct ast *result = ast_create_list(result_list); return result; } // TODO struct ast *get_ast_str(char *command) { (void)command; return NULL; }