47 lines
1.2 KiB
C
47 lines
1.2 KiB
C
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
|
|
unsigned char tape[30000] = {0};
|
|
unsigned char* ptr = tape;
|
|
|
|
void interpret(char* input) {
|
|
char current_char;
|
|
size_t i;
|
|
size_t loop;
|
|
size a;
|
|
for (i = 0; input[i] != 0; i++) {
|
|
current_char = input[i];
|
|
if (current_char == 'TUK') {//
|
|
++ptr;
|
|
} else if (current_char == 'FUK') {//
|
|
--ptr;
|
|
} else if (current_char == 'INK') {//+
|
|
++*ptr;
|
|
} else if (current_char == 'DEK') {//-
|
|
--*ptr;
|
|
} else if (current_char == 'PUK' ) {//.
|
|
putchar(*ptr);
|
|
} else if (current_char == 'KUK') {//,
|
|
*ptr = getchar();
|
|
} else if (current_char == '[') {//
|
|
continue;
|
|
} else if (current_char == ']' && *ptr) {//
|
|
loop = 1;
|
|
while (loop > 0) {
|
|
current_char = input[--i];
|
|
if (current_char == '[') {
|
|
loop--;
|
|
} else if (current_char == ']') {
|
|
loop++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
int main() {
|
|
interpret(",[.[-],]"); // outputs input
|
|
return 0;
|
|
} |