←  APIs and Utilities

ComputerCraft | Programmable Computers for Minecraft

»

Brainfuck Interpreter

greygraphics's Photo greygraphics 07 Dec 2016

Hello again,

I am back with a new program: An interpreter for the language Brainfuck.

What is Brainfuck?

Quote

Brainfuck is an esoteric programming language created in 1993 by Urban Müller, and notable for its extreme minimalism.
The language consists of only eight simple commands and an instruction pointer. While it is fully Turing-complete, it is not intended for practical use, but to challenge and amuse programmers.
The language's name is a reference to the slang term brainfuck, which refers to things so complicated or unusual that they exceed the limits of one's understanding.
- https://en.wikipedia.../wiki/Brainfuck (8th of December 2016)

Brainfuck has only eight commands:
  • < Decrease pointer value
  • > Increase pointer value
  • + Increase the value the pointer points at
  • - Decrease the value the pointer points at
  • [ Open a loop
  • ] close a loop
  • . Print out the ASCII character for the current cell
  • , Write an ASCII value to the current cell
You have an array of (in this case) 1024 bytes. The pointer and each byte is initialized to 1 (we use lua, not C) and 0.
Both values over- and underflow if you modify them.

How do I use this program?

The program is available on pastebin, you can either copy the code and paste it into a file or type in
pastebin get 1QGq7FZr bfq
to download it directly.

It comes with several commands:
Brainfuck - Help	  
		  
  :usage - How to use this program  
  :info  - Information about Brainfuck  
  :help  - This message	  
  :test  - Runs a small program	
  :learn - Explains how to use Brainfuck

To run Brainfuck code you simply type
Brainfuck - Usage	  
		  
  'bfq <filename>'	  
  'bfq :<usage|info|help|test|learn>'  
and the program opens and executes the file.

Included in the program is a small 'Hello, world!' code that is accessible via
bfq :test
You can see that code in action in the image attached.

Have fun with this program!

Please let me know if you find any bugs or have any complaints. :)

Attached Thumbnails

  • Attached Image
Quote