george-interpreter/george_interpreter.c
2022-05-17 21:50:38 -06:00

62 lines
1.3 KiB
C

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
char s_toin[260];
char toin[260];
FILE *filein;
int unin[1024];
int inptr[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++) {
}
}
}
int main() {
openfile();
interpret();
exit(0);
}