Cubestate

Cubestate is an esoteric programming language made by User:Raumaankidwai. Cubestate (or cubestate) programs are based on sequences of moves on Rubik's Cubes using common cubing notation.

Notation
A base move is defined as either "U", "x", or "y". "U" moves the top face of the cube 90 degrees clockwise. "x" rotates the cube 90 degrees clockwise around the right face. "y" rotates the cube 90 degrees clockwise around the top face.

An inverse move is the inverse of a move, i.e. the inverse of a move performed directly after or before that move will have no affect on the cube's state. Inverse moves are denoted with an apostrophe after the move to be inverted.

A double move is a move performed twice, denoted with a "2" directly after the move to be performed twice. Ex: "U2 R2 F2".

"z" is the third rotation, defined as " x y x' ", which rotates the cube 90 degrees around the front face.

A face move is defined as one of "U", "R", "F", "B", "L", and "D", where "R", "F", "B", "L", and "D" are to the right, front, back, left, and bottom faces respectively as "U" is to the top face. In cubestate, each face move is defined as a combination of rotations, then U, then the inverse of the combination of those rotations.

A wide move is defined as one of "u", "r", "f", "b", "l", and "d", where a wide move corresponding to a face move is the equivalent of performing the face move with two layers instead of one.

A slice move is defined as one of "M", "E", and "S", where "M" is defined as " l L' ", "E" is defined as " d D' ", and "S" is defined as " f F' ". These moves move a middle slice of the cube instead of a full layer.

Syntax
A cubestate program is made of "algorithms" delimited by newlines in the file. When compiling a cubestate program, the compiler generates a simulated cube, and performs each algorithm in order on the same cube. An algorithm is simply a sequence of moves delimited by non-newline whitespace.

Every time an algorithm is completed, the stickers of the top face are read as Brainfuck code from top left to bottom right using this mapping:

It is important to note that the cube is not reset before executing an algorithm, though it begins the program in a solved state.

For  and , the Brainfuck character is placed after a space at the end of the algorithm, along with an optional number to describe how many stickers of the top face to read before executing the   or   and moving on to the next algorithm.

Another optional number may be placed at the last line of the program to denote how many stickers of the top face should be read after the last algorithm.

For example, the simple program  has one algorithm,. After being executed, the Brainfuck code read is. However, since after the algorithm is, only 4 Brainfuck characters are read before a   is added and the program exits. This results in, which can then be executed.

Note that as of September 5th, 2017, the cubestate repository does not include a built-in Brainfuck interpreter.

Comments are not supported.

Cat program
,0 B' .1 ,0 B2 1 This code is a direct translation of the Brainfuck program, and compiles to it.

Printing a newline
.1

Note the fact that there must be a leading newline in the program (not displayed here) which denotes an algorithm of 0 moves. This program is a direct translation of the Brainfuck program, which puts 10 into the current cell and outputs a newline, and compiles to it. Since  corresponds to the top face, and there are 9 stickers on the top face with the top face's color at the beginning, no algorithm is needed to increment the current cell by 9. The next algorithm is also 0 moves, however you do need a  to tell the compiler to only read 1 sticker before appending a   and exiting.

Hello, World!
R' D R R' S U2 D S' L2 F2 U2 D' F' L2 M' B' R' L U' B R' D S2 R U S2 U2 R2 D F' F' R2 B L .6 R' U B L' .4 R L2 F' M E' R .7 .0 .3 R U2 .2 B2 M .2 .1 B2 U' .3 R L2 M B' R' .6 F' U' .8 R L' M2 .3 F' M2 .3

This program is a computer-generated non-trivial translation of the Brainfuck program, and compiles to it.