brain........ interpreter
Ok, so i think there is something wrong with this because it was way too simple to write. I know it's a simple language, but still.
I actually have no clue about the language, so could anyone with any background in brain........ help me out here?
Also, I think I got the general idea of brain........ loops wrong.
and, no functions, I know. Give me a break, I'm 14.
Code:
#include <stdio.h>
int main(int argc, char *argv[]){
int array[30000];
long int currentByte = 0;
char currentInput;
if(argc > 2){
printf("You sent too many arguments!\n");
return 0;
}else if(argc < 2){
printf("You didn't send any arguments!\n");
return 0;
}
FILE *fp;
if( (fp = fopen(argv[1], "r")) == NULL){
printf("File doesn't exist!");
return 0;
}
whileloop:
while((currentInput = fgetc(fp))!=EOF && currentInput != '['){
if(currentInput == '>'){
currentByte++;
}
if(currentInput == '<'){
currentByte--;
}
if(currentInput == '+'){
array[currentByte]++;
}
if(currentInput == '-'){
array[currentByte]++;
}
if(currentInput == '.'){
printf("%d\n",array[currentByte]);
}
if(currentInput == ','){
array[currentByte] = fgetc(stdin);
}
}
if(currentInput == '['){
goto whileloop;
}
return 0;
}