Brainflub

From Esolang
Jump to navigation Jump to search

Brainflub is an esoteric programming language created by Snorepion. While its documentation is written jokingly, it isn't as much of a joke as some other languages and can be made functional. While the compiler accepts any file extension, the official extension is ".fl".

In the compiler written by Snorepion, the code will be iterated through and a private output string will be set and added to based on the commands instead of writing to the console in real time, then when a | or : command is received, the string will be written to the console. This method of parsing is required for some of the commands. The C and Python compilers, written by aryantech123, have an additional command.

Commands

Command Description
+ Increments the accumulator by one.
- Decrements the accumulator by one.
= Adds the value of the accumulator represented as an ASCII character to the private output.
| Informs the parser that it is the end of the program. Required for all programs except those that end as a quine.
: Makes the program a quine, stops moving through the code, and removes all previous text that would be given as an output through =.
. Immediately writes the contents of the private output to the console. This can be used to output something before using : to make the program a quine.
, Clears the private output.
~ Resets the accumulator.
space Pauses iteration and takes user input from the console.
* Writes the user input to the private output string.
d Doubles the value in the accumulator, only in the Python and C implementaions.

Examples

Hello, world

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=+++++++++++++++++++++++++++++=+++++++==+++=~++++++++++++++++++++++++++++++++++++++++++++=------------=+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=--------=+++=------=--------=-------------------------------------------------------------------=|

This program prints "Hello, world!" to the console.

Quine

++--:|

This program prints its source code ("++--:|") to the console. Only the : is actually needed.

Cat

 *|

Copies input to output.

Double cat

 **|

Copies input to output twice (ex. if input is "fe" output will be "fefe")

Join two inputs

 * *|

Takes two inputs and joins them together.

Hello world + quine

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=+++++++++++++++++++++++++++++=+++++++==+++=~++++++++++++++++++++++++++++++++++++++++++++=------------=+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=--------=+++=------=--------=-------------------------------------------------------------------=.:

Prints "Hello, world!" followed by the source code.

External links