diff options
author | Danny van Kooten <dannyvankooten@users.noreply.github.com> | 2020-03-18 19:21:48 +0100 |
---|---|---|
committer | Danny van Kooten <dannyvankooten@users.noreply.github.com> | 2020-03-18 19:21:48 +0100 |
commit | 8d74fd5b0e5fc9f319a5b7d2e0716afcc312fd75 (patch) | |
tree | a6c195d183694304fbe238a68486aceea01d404a /src/parser.c | |
parent | 82de777afb99aa4129abcb01da76bf62e7b45263 (diff) | |
download | unja-8d74fd5b0e5fc9f319a5b7d2e0716afcc312fd75.tar.gz unja-8d74fd5b0e5fc9f319a5b7d2e0716afcc312fd75.zip |
clean-up environment in env_free(). add hashmap_walk function for visiting all values in a hashmap.
Diffstat (limited to 'src/parser.c')
-rw-r--r-- | src/parser.c | 94 |
1 files changed, 0 insertions, 94 deletions
diff --git a/src/parser.c b/src/parser.c deleted file mode 100644 index e61b1e5..0000000 --- a/src/parser.c +++ /dev/null @@ -1,94 +0,0 @@ - -#include <stdlib.h> -#include <string.h> - -struct text { - char *str; -}; - -struct symbol { - char *value; -}; - -struct expression { - struct symbol symbol; -}; - -struct statement { - -}; - -/* discard during parsing phase */ -struct comment {}; - - -enum node_type { - NODE_EXPR, - NODE_COMMENT, - NODE_TEXT, -}; - -struct node { - enum node_type type; - union content { - struct expression expr; - struct comment comment; - struct text text; - } content; -}; - -struct ast { - int size; - int cap; - struct node **nodes; -}; - -enum token_type { - TOK_EOF, - TOK_EXPR_OPEN, - TOK_EXPR_CLOSE, - TOK_COMMENT_OPEN, - TOK_COMMENT_CLOSE, - TOK_STMT_OPEN, - TOK_STMT_CLOSE, - TOK_MINUS, - TOK_SYMBOL, - TOK_TEXT, -}; - -struct token { - enum token_type type; - char *literal; -}; - -struct token gettoken(char *str) { - struct token t; - switch (str[0]) { - case '{': - - break; - - case '}': - - break; - - case '\0': - t.type = TOK_EOF; - break; - } - - return t; -}; - -struct ast* parse(char *str) { - struct ast* ast = malloc(sizeof *ast); - ast->size = 0; - ast->cap = 64; - ast->nodes = malloc(ast->cap * sizeof *ast->nodes); - - for (struct token t = gettoken(str); t.type != TOK_EOF; t= gettoken(str)) { - - } - - return ast; -}
\ No newline at end of file |