1#include "cotton.h"
2#include "interpreter.h"
3#include <stdio.h>
4
5int main
6(int argc, char **argv)
7{
8 if (argc < 2) {
9 fprintf(stderr, "cotton: cotton couldn't find any .cot files to run :P\n");
10 return 1;
11 }
12
13 FILE *f = fopen(argv[1], "r");
14
15 if (!f) {
16 fprintf(stderr, "cotton: couldn't open \"%s\", is this even a file.,.? :<\n", argv[1]);
17 return 1;
18 }
19
20 Cotton c;
21 cotton_init(&c);
22
23 char line[256];
24 while (fgets(line, sizeof(line), f)) {
25 cotton_compile(&c, line);
26 }
27
28 fclose(f);
29
30 c.mem[c.mem_len++] = OP_KILL;
31
32 cotton_run(&c);
33
34 return 0;
35}