summaryrefslogtreecommitdiff
path: root/lucky.c
diff options
context:
space:
mode:
Diffstat (limited to 'lucky.c')
-rw-r--r--lucky.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/lucky.c b/lucky.c
new file mode 100644
index 0000000..7566895
--- /dev/null
+++ b/lucky.c
@@ -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:
+ }
+}