summaryrefslogtreecommitdiff
path: root/lucky.c
blob: 75668950a831d36c55fe1618d030a7ee4df18c7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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:
	}
}