SoT

SoT is short for "Stack of Tapes". (Note: I am still not finished! It takes a long time to do it!)

Comments,labels
Comments are indicated by /* and ending with */ or you can use// is comment until end of line (but you can't put comments inside of strings, because it is interpreted as a string if you do it anyways). You must have a white-space before and after a comment, otherwise it isn't treated as a comment.

Labels defined in a code-block are : followed by label name followed by : again.

Kinds of values

 * Null: A null value is nothing and it is indicated in the program by a ^ sign.
 * Code-block: Function code-blocks are start with { and end with } and in between you put the commands.
 * Built-in-function: Built-in functions start with, or . or * or & or + and it is followed by one more character.
 * Number: A number of any size can be indicated by putting the number between two # signs. Negative, hex, octal, are also supported, as well as positive, and decimal numbers. You can use non-integers for decimal number but in other bases it has to be a positive integers. Hexadecimal start with 0x and octal start with 0.
 * Label-name: Label-names are also between two # signs but cannot start with a digit.
 * Variable-pointer: Variable names must be put between two ' signs to indicate a pointer to the variable with that name in the current scope.
 * String: A string is a text between " signs.
 * Quantum-pointer: It is a pointer to a qubit. There is no form for representing it.
 * Brainfuck: A brainfuck is a code between [ and ] and it can be any brainfuck codes in between. If used as a function and argument is a variable with non-empty stack, it will operate on that top tape of variable.
 * List: Put the list between ( and ) signs and each value (no separators are needed) will be a part of that list.
 * Regular-expression: A regular expression between slashes, but with # added before the beginning slash. It works similar to the preg functions in PHP but no pattern modifiers can be used outside of the slashes. The regular expression represents a set of strings. It is automatically anchored to the begin and end, so anchors doesn't do anything special.
 * Continuation: There is no form for representing a continuation. Qubits are not stored in continuations, but the quantum-pointers are.
 * Object: It is something that has any number of properties that are named by any value and can have any type of values as well. It has no representation. If a property name is exactly the same as a function that it is a argument for then it will execute the function that the property value is instead, unless the property value is null, in which case it uses the normal function instead. When object is used as a function, it uses the property named by a null as the function to call, and the argument to it is this object.
 * Boolean: Can be true or false. True is indicated by 1 and false by 0

Variables
A variable consists of a stack of tapes, the tapes are infinite in both directions and start all null, and the stack is also allowed to act as a queue in some cases. Variables must be declared before used, and variables defined locally to a subroutine override ones in a higher level.

Commands

 * Expression: It can be a expression represent a value and the result value is ignored.
 * Push to stack: Start with % and a expression, the result goes to the main stack.
 * Goto label: Start with ; and a expression and if it represents a label name that is in this code-block then it goto label. If the expression is a code-block instead, then it will execute that code-block (without arguments).
 * Exit from the function: Use ;; command to exit from function.
 * Declaration: To declare a variable you have to put = followed by variable name and then = again.
 * Maybe: ?M followed by any command acts like the MAYBE in backtracking INTERCAL. It puts to a state stack (except qubits).
 * Maybe not: ?m followed by any command is like MAYBE NOT (like ?M but is by default not executing).
 * Go back/ahead: ?B followed by a expression to do GO BACK if false, GO AHEAD if true, like it does in backtracking INTERCAL.
 * Quit: ?. to quit execution of entire program.

Operators

 * Apply operator: Apply one value (function) to the next value (argument), and returns its result value. The symbol is ` followed by first value, and then second value. If the function is a built-in function, you can abbreviate it `, to < and `. to > and `* to / and `+ to - and `& to \
 * Stack operator: If a % is used part of a expression then it pops from the main stack and uses that value. If there isn't any then it returns null. It does not need apply operator, it works automatically, before anything is applied in the current expression. If multiple percent signs then it pops from right to left.

Substitutions
Substitutions can be included in a code-block in place of a value by using a number with _ instead of # around it. Some functions can substitute them with proper values instead. It is an error to do a calculation with a substitution that hasn't been substituted yet.

Built-in functions
Remember that some functions might take multiple arguments by currying.

Quantum computer

 * ,1 x = Ignores x and return a new quantum-pointer to a new qubit with value 1.
 * ,0 x = Ignores x and return a new quantum-pointer to a new qubit with value 0.
 * ,% x = Hadamard transform on qubit pointed by x.
 * ,! x y = Controlled V on the x and y qubits.
 * ,O x = Observe the qubit x and returns false if 0 or or true if 1.
 * ,N x y = Controlled NOT on x as the control, and y as the target, return y.
 * +P x y = Phase shifter gate on qubit x with angle y. Returns x.

Variables

 * ,d x = Duplicate top of stack of variable x. Return x.
 * ,a</tt> x = Push blank tape to variable x. Return x.
 * ,z</tt> x = Discard top of stack of variable x. Return x.
 * ,Q</tt> x = Move bottom tape of stack of variable x to the top. Return x.
 * ,=</tt> x y = Set value of x at tape pointer to y. Return y.
 * .=</tt> x = Get value of variable x at tape pointer.
 * .<</tt> x = Move tape pointer of x one space backward. Return x.
 * .></tt> x = Move tape pointer of x one space forward. Return x.
 * ,P</tt> x y = Set pointer of tape of x to position y (start position when variable is created is 0). Return y.
 * ,p</tt> x = Get pointer position of tape of x.
 * +Z</tt> x = Makes variable x so it cannot be changed. Return x.
 * +I</tt> x = Makes variable x so it can be changed. Return x.
 * ,_</tt> x y = Get value at position y of tape of variable x.
 * ._</tt> x y z = Set value at position y of tape of variable x to value z. Return z.
 * .u</tt> x y = Set values at all positions of tape of variable x to value y. Return x.
 * .y</tt> x = Renumber positions in tape of variable x so that where it points to is now position 0. Return number of what position 0 used to be numbered.
 * .Y</tt> x y = Add a position with value y in between every 2 positions of the tape of variable x. Position number of current position is retained.
 * <tt>,Y</tt> x = Does the reverse function of .Y command.

Combinator function

 * <tt>.s</tt> x y z = S combinator function.
 * <tt>.k</tt> x y = K combinator function.
 * <tt>.i</tt> x = Identity function.
 * <tt>.v</tt> x = Returns .v function regardless of x.

Numbers

 * <tt>.+</tt> x y = Adds numbers x and y.
 * <tt>.-</tt> x y = Subtracts numbers x and y.
 * <tt>.*</tt> x y = Multiplies numbers x and y.
 * <tt>./</tt> x y = Divides numbers x and y. (if dividing by zero, result is null)
 * <tt>.\</tt> x y = Integer division.
 * <tt>.%</tt> x y = Modulo.
 * <tt>.&</tt> x y = Bitwise AND.
 * <tt>.|</tt> x y = Bitwise OR.
 * <tt>.^</tt> x y = Bitwise XOR.
 * <tt>.!</tt> x = Bitwise NOT.
 * <tt>.$</tt> x y = INTERCAL interleave operator.
 * <tt>.~</tt> x y = INTERCAL select operator.
 * <tt>,i</tt> x = Convert to integer.
 * <tt>,A</tt> x = Absolute value of x.
 * <tt>++</tt> x = Sum of everything in the list x.

Continuations

 * <tt>.c</tt> x = Call x with current continuation.
 * <tt>.C</tt> x y = Push y to main stack of continuation x. Return x.
 * <tt>,C</tt> x = Pop a value from main stack of continuation x.

Objects

 * <tt>.@</tt> x = Create a new object with the null property set to x.
 * <tt>.o</tt> x y = Get value of property named y of object x.
 * <tt>.O</tt> x y z = Set value of property named y of object x to value z.

Input/Output

 * <tt>.,</tt> x = Ignores x, inputs one byte. Null if no more to read.
 * <tt>..</tt> x = Output a byte x or a string x. Returns x.
 * <tt>.S</tt> x = Return a system calling object, ignores x.

Main stack operations

 * <tt>*D</tt> x = Duplicate top value of main stack and returns x.
 * <tt>*S</tt> x = Swap top 2 values of main stack and returns x.
 * <tt>*Z</tt> x = Discard top value of main stack and returns x.
 * <tt>*></tt> x = Push x to main stack and return x.
 * <tt>*<</tt> x = Pop a value from main stack and return that value, or return x if is no more left on main stack.

Miscellaneous

 * <tt>,?</tt> x = Check type of x. 0=null, 1=code-block, 2=number, 3=label-name, 4=variable-pointer, 5=string, 6=brainfuck, 7=list, 8=quantum-pointer, 9=regular-expression, 10=object, 11=continuation, 12=boolean, -1=other.
 * <tt>,&</tt> x y = Concatenation of x and y. They can be code-blocks or strings or lists or brainfucks (but they have to be both the same type).
 * <tt>,|</tt> x = Count items in a list, characters in a string, or entries (number of tapes) in a stack of tapes in a variable.
 * <tt>+S</tt> x y z = Change all of the substitution numbered y (y is a number) in the code-block x (including sub-blocks) to the value z.
 * <tt>,S</tt> x y z = Change all of the substitution numbered y (y is a number) in the code-block x (including sub-blocks) to the substitution with number z.
 * <tt>,:</tt> x = Ignores x, returns a copy of the code-block that is currently executing.
 * <tt>.:</tt> x = Pop a value from main stack, and returns a code-block that is same as x but the value that was popped is pushed to the main stack at the start of the code (after an argument to that function has been pushed).
 * <tt>*:</tt> x = Converts x to a boolean value. Booleans remain unchanged, zero is false, null is false, empty code-blocks/lists/strings/variables/brainfucks are false, non-empty variables use the value at the tape pointer to determine true/false, label names that don't exist in the current context are false, regular expressions representing an empty set are false, quantum values are observed and 0=false and 1=true, objects with all properties set to null are false, and everything else is true.
 * <tt>*?</tt> x y z = Convert x to boolean (using *: function) until is boolean, and then returns y if is true, z if is false.
 * <tt>*=</tt> x y = True if x equals y exactly, otherwise false.

Conversion of other programs to SoT
You can convert other programs to SoT, depending on what programming language it was written in.

Unlambda

 * The program starts with <tt>=C=<a'C'</tt> to initialize the varible to store the current character.
 * s k i v c converts to .s .k .i .v .c so you just need to put a dot before it.
 * Output is <tt>{>."x"}</tt> where x is character to output.
 * d function: You have to use {% before the first argument and %} after the first argument in order to create it.
 * e function: It is <tt>{?.}</tt>
 * @ function: In Unlambda it reads a character and makes it the current character. In SoT it is <tt>{%`%``/?<?`<='C'>,^.i.v}</tt>
 * ?x to compate a character read is <tt>{%`%``/?`/="x">='C'.i.v}</tt> with "x" replaced with the character you want to check.
 * | to reprint character read is: <tt>{%`%``/?<?>='C'``+S{>._0_}#0#>='C'.v}</tt>

Underload

 * <tt>~</tt> in Underload is <tt>/S^</tt> in SoT.
 * <tt>:</tt> in Underload is <tt>/D^</tt> in SoT.
 * <tt>!</tt> in Underload is <tt>/Z^</tt> in SoT.
 * <tt>*</tt> in Underload is <tt>%`<&%%</tt> in SoT.
 * <tt>(</tt> in Underload is <tt>%{</tt> in SoT.
 * <tt>)</tt> in Underload is <tt>}</tt> in SoT.
 * <tt>a</tt> in Underload is <tt>%``-S{%{_0_}}#0#%</tt> in SoT.
 * <tt>^</tt> in Underload is <tt>;%</tt> in SoT.