-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
49 lines (36 loc) · 846 Bytes
/
main.c
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* File: main.c
* Author: brian
*
* Created on September 22, 2011, 7:13 PM
*/
#include "BrainMain.h"
#include "interpreter.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Brain BrainMachine;
int j, k, i = 0;
/*
*
*/
int main(int argc, char** argv) {
char filepath[100];
FILE * BRAIN;
// get the filepath from the user
fgets (filepath, sizeof(filepath), stdin);
filepath[strlen(filepath) - 1] = '\0';
BRAIN = fopen(filepath, "r");
// If the BRAIN file exists
if( BRAIN ) {
initializeBrain();
storeInstr( BRAIN );
for(i = 0 ; i < BrainMachine.IC ; i++) {
interpret(i, BRAIN);
}
fclose( BRAIN );
} else {
perror(filepath);
}
return (EXIT_SUCCESS);
}