#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 */ static struct ast *parse_simple_command(void) { struct list *cmd_elements = NULL; char *token = get_token(); if (token == NULL) // just in case ? return NULL; while (token != NULL && !isterminator(token[0])) { cmd_elements = list_append(cmd_elements, token); token = get_token(); } if (token == NULL) return NULL; // TODO handle error struct ast *result = ast_create_cmd(cmd_elements); return result; } // === Functions struct ast *get_ast() { struct ast *result = NULL; struct ast *current_node = NULL; // char *token = get_token(); return result; } // TODO struct ast *get_ast_str(char *command) { (void)command; return NULL; }