Braintrust

From Esolang
Jump to: navigation, search

Braintrust is an esolang by User:Sgeo similar to Brainfuck. It is intended to be compiled, and the compiler, written in Braintrust, itself has no knowledge of the target platform directly. Rather, all such information is part of the primitive command !. The information itself is stored in the resulting target code.

Braintrust has all the usual Brainfuck commands, and 3 extra.

, on EOF results in -1.

\ sets the value of current memory cell to the value of the following character, as though it were read in via ,

: appends the value at the current memory cell to the current code block, which starts out empty. The code block contains values, representing Braintrust code.

! compiles the code in the code block as though with the compiler used to compile the currently running program. The result is output, and the code block is then cleared.

The following is a Braintrust compiler written in Braintrust:

,+[-:,+]!

Implementation: https://gist.github.com/Sgeo/fe54715fc61d1d98f4cc (needs more documentation and to be moved to a repository)

If L is a language, f is a function L->Braintrust, and g is the inverse of f (that is, a function Braintrustk->L), then g(",+[-:,+]!") is a compiler for L, not a compiler for Braintrust.