Brainfuck2

From Esolang
Jump to navigation Jump to search
This article is not detailed enough and needs to be expanded. Please help us by adding some more information.

Brainfuck2 is a language that is a result of creating an interpreter(1) for it's parent language, and adding more features to it.

Overview

This language is mostly the same as brainfuck, so:

Operation Meaning
+ Increments the currently selected cell
- Decrements the currently selected cell
< Selects the cell to the left of the currently selected cell
> Selects the cell to the right of the currently selected cell
. Outputs the value at the selected cell as an ASCII/Unicode character
, Input an ASCII/Unicode character, and put its code in the selected cell
[ Jump to the matching ] if the selected cell is 0
] If the selected cell is not 0, jump to the matching [

However, this language at current (the standard is still being worked on) has three extra features.

Additions

Below is a list of functions added by this version...

Functions

Functions are the first addition to this language. Define a function using:

{{1}} ; Define a function with index 1,
<[>++++++++++<-]>.[-] ; as this,
;;; ; And end the definition. Don't confuse this for single-semicolon explicit comment syntax.

A function can then be called using the following:

++++++>+++++||1|| ; Call function 1 to print "A"

Print statements

p ``Hello world`` prints "Hello world" and will transpile to a brainfuck code that would print "Hello world," aka

Print "Hello world"
+++++++[>++++++++++<-]>++.[-]<
++++++++++[>++++++++++<-]>+.[-]<
+++++++++++[>++++++++++<-]>--.[-]<
+++++++++++[>++++++++++<-]>--.[-]<
+++++++++++[>++++++++++<-]>+.[-]<
+++[>++++++++++<-]>++.[-]<
++++++++++++[>++++++++++<-]>-.[-]<
+++++++++++[>++++++++++<-]>+.[-]<
+++++++++++[>++++++++++<-]>++++.[-]<
+++++++++++[>++++++++++<-]>--.[-]<
++++++++++[>++++++++++<-]>.[-]<
++++++++++..[-]

Explicit comments

Regular, "implicit" comments are anything that isn't a brainfuck command, like hello world.
Explicit commands have a semicolon to begin them, like ; Comment, the comma isn't a worry!.
In an explicit comment, everything following it until the end of the line is completely ignored (and removed in the transpilation process.)
This means commands (like a comma) can be put in an explicit comment without issues, as it's ignored anyway.

External resources