george-interpreter/george_interpreter.c

62 lines
1.3 KiB
C

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
char s_toin[260];
char toin[260];
FILE *filein;
int unin[1024];
int in[1024];
char verbs[10][9] = {
{"forward"}, //1
{"backward"},
{"left"},
{"right"},
{"north"},
{"east"},
{"south"},
{"west"}, //8
{"turn"},
{"comment"}
};
//char nouns[][];
void openfile() {
printf("file to open...\n"); //open the file
scanf("%260s", s_toin);
printf("opening %s...\n",s_toin);
snprintf(toin, sizeof(toin), "%s", s_toin); //put filename in string that fopen likes
if (access(toin, F_OK) == 0) { //does file exsist?
filein = fopen(toin, "r"); //file exsists, open it
} else {
printf("error opening %s, press enter to exit...", &toin); //file doesnt exsist, exit
scanf("", NULL);
exit(1);
}
for (int i = 0; i < 1024; i++) {
unin[i] = fgetc(filein);
}
for (int i = 0; i < 1024; i++) {
if (unin[i] != -1) {
printf("%c",unin[i]);
}
}
}
void interpret() {
for (int i = 0; i < 1024; i++) {
for (int j = 0; j < 10; j++) { //verbs[this][not this]
for (int k = 0; k < 10; k++) { //verbs[not this][this]
}
}
}
}
int main() {
openfile();
interpret();
exit(0);
}