Got bored again this afternoon, so I made a Brainf**k interpreter for you to enjoy!
For those who don't know, Brainf**k is a really simple language with only 8 different symbols, yet can be used to do a whole range of things. The idea of the language is that you have a chunk of memory to yourself, and are standing at a location in that memory. You can increment and decrement the number at that location in memory by 1 using + and -, and also move to the next or previous location in memory using < and >. You can print out the char produced from the number at the spot using . (so basically, string.char the number at that location), and read a single letter input from the using using , which is returned as a number from string.byte. You also have a really simple while loop using [ and ], which will loop over all the code in between it until the current spot in memory at the end of it is 0.
For those of you who know C, C++, or some similar variant, here is a simple table detailing the operators (from Wikipedia):
(Program Start) char array[30000];
char *ptr = array;
> ++ptr;
< --ptr;
+ ++*ptr;
- --*ptr;
. putchar(*ptr);
, *ptr = getchar();
while (*ptr) {
] }
I hope I got most of it right. Please point out any errors you find :)/>Usage
Just download the interpreter from below, and run it with your Brainf**k program as the first argument, like:
brainf**k test_program
Download
Pastebin: 0AXaibqV
Or type into your computer:
pastebin get 0AXaibqV brainf
Please note: I asterisked out the u and k because this is a family friendly forum, but the actual language name has no asterisks.