Brain

An esoteric programming language based on Brainfuck.

About
Brain wants to improve the performance of the Brainfuck programming language and extend it as well, as Brainfuck itself has a lack of flexibility and does not perform great control over complex computations. Brain is open to new model represetantion and allows programmers to extend its capability by attaching LLVM IR to its code.

One of the main ideas of Brain is saving some operations in machine language, creating an instruction optmizer due to the excess of instructions that Brainfuck would generate. Brain aims to implement it by using current technology (LLVM).

In spite of implementing new commands and features, Brain is completely compatible with Brainfuck (but the opposite is not true).

Tools

 * Brain Visualizer - an Online Javascript Interpreter for the Brain Language.
 * Brainduino - a Brain interpreter for Arduino.
 * BrainStation - A small video game console for Arduino using the Brainduino interpreter.

Arch Linux via AUR
 yaourt -S brain

Docker
 docker pull luizperes/brain:1.0 docker run -it luizperes/brain:1.0

How it has been built
Brain is based on previous work https://github.com/luizperes/BrainfuckInterpreter and https://github.com/Lisapple/BF-Compiler-Tutorial-with-LLVM, now trying to make something more serious: Turing Complete, faster, more features/commands.

Technical Information
Brain is now a Turing Complete language. You can now extend the tape size by using the flag --size=.

Examples

 * if-then: ? +++ ; // if (*ptr) { *ptr += 3; }
 * if-else: ? +++ : --- ; // if (*ptr) { *ptr += 3; } else { *ptr -= 3; }
 * for-loop: ++++ { commands } // makes four iterations 4 through 0 (excluded)
 * floating numbers: ++>+********$ cell 0[2] cell 1[256] // '$' prints out 256 / 100
 * break loop: +[+++++!] // ptr = 1; while(ptr) { *ptr += 5; break; }

Compiler Options

 * Shows the current version of Brain
 * Sets the number of cells used by the interpreter
 * Emits LLVM IR code for the given input
 * Emits the AST for the given input
 * Emits an optimized code for the given input
 * Uses verbose mode for the output
 * Generates output code with no optmizations
 * Optimizes Brain generated output code (Default)

Real-life Applications

 * Artificial Intelligence/ Machine Learning
 * Send commands to Arduino
 * Easy support to primitive processors

External Resources

 * https://github.com/brain-labs
 * https://github.com/brain-labs/brain
 * https://github.com/brain-labs/brain-visualizer
 * https://github.com/brain-labs/brainduino
 * https://github.com/brain-labs/brainstation