diff options
Diffstat (limited to 'lucky.c')
-rw-r--r-- | lucky.c | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -0,0 +1,32 @@ +#include <stdio.h> +#include <stdlib.h> +#include <stdbool.h> +#include <string.h> +#include "parser.h" +#include "eval.h" + +void strip(char *s, char c){ + for (int i = 0; i < strlen(s); i++){ + if (s[i] == c) { + s[i] = 0; + return; + } + } + return; + +} + +int main(int argc, char **argv){ + FILE *f = fopen(argv[1], "r"); + char *line = malloc(256); + while (fgets(line, 256, f) != NULL){ + strip(line, '\n'); + if (strlen(line) == 0) goto skip; + + luckytree *tree = parse(line); + luckyval *ret = eval(tree); + free(tree); + free(ret); +skip: + } +} |