From Esolang
Jump to navigation Jump to search


!brainfuck (Pronounced "Macro Brainfuck") is a tape-based Brainfuck derivative made by user Nick-1666 that closely follows brainfuck syntax. Except with macros!



All valid Brainfuck is valid !Brainfuck and is interpreted as one would expect. Due to macros having names that are also text, is that it is no longer possible to add comments by writing pure text as you would in Brainfuck. This limitation was considered and thus gave birth to line and multi-line comment syntax in !Brainfuck. Here are examples of both:

## This is a line comment!

# This is a multi-line comment!
  This is a multi-line comment! #

Anything between a pair of hashes is a multi-line comment. If a hash is immediately followed by another, the comment becomes a multi-line comment from the second character until a newline.


Macro Definitions

A macro definition is composed as such !name <code>;

!0 [-];

The above example shows a macro definition. It assigns the name '0' to [-]. Valid macro names in !Brainfuck are strict to improve readability. It is conventional to use lower camel-case (lowerCamelCase) although underscores are allowed for snake casing. Macro names can only contain alphanumeric digits with the exception of underscores.

Note that the <name> and <code> must always separated by a space or a newline.

!Add Two Cells
    ## subtract from the current cell and add to the next
    ## repeat until there is nothing else to decrement

The above code is valid and is an example of a useful addition macro.

Macro Calls

Now that we have defined macros, we can call them in code:

 +>+Add Two Cells!
# ^ ^             ^
  | |             | We are left with the sum in the first cell
  | | Call the macro by adding a ! after the name
  | Set the first two cells equal to 1

Future Improvements

In order of importance:

Optimisation of interpreter
  • remove useless pairs such as -+,
  • stack commands and manipulate memory once (+++ -> +3)
Implement reassignment of macros
  • ?x -; redefine x to be equal to -
  • ?!x -; define or redefine x to be equal to -
Importing macros from macro files
  • ![macros.mbf]; import all macros in macros.mbf
Transpiring to normal Brainfuck
  • Replace all symbols with their definitions
  • Replace all imported symbols with their definitions
Bootstrap Interpreter


  • x86_64
  • wasm

Turing Completeness proof

Since Brainfuck is Turing Complete, and all Brainfuck is valid in !Brainfuck, it is of equivalent computational class.