Spiral

Spiral, devised by User:Quintopia, is an esoteric programming language in two dimensions. Unlike other two-dimensional languages (exception: Wierd), the instruction pointer decides where to move based on where there is code to execute. In addition, the only data structure is a deque.

Flow Control
Instructions in spiral consist of single non-whitespace characters and the instruction pointer can be thought of as a robot that rolls along the code like railroad tracks always trying to turn. It can move in any of the four cardinal directions. If the pointer is in right-turning mode, then as soon as it steps onto an instruction it turns 90 degrees to the right. For instance, if it just made a step in an eastward direction, it will turn and face south. Likewise, if it is in left-turning mode, it will immediately turn 90 degrees left.

Next, it looks for a command (any non-whitespace character) in front of it. If there is one, it executes it and then tries to take a step forward. Otherwise, it turns 90 degrees left (or right, if in left-turning mode) and repeats this process. For instance, in right-turning mode it might first try executing a statement on the south, then the east, then the north, then the west, then the south again, etc. Note well that an instruction is always executed before the pointer moves onto it.

The program begins wherever the '0' character first occurs and it should occur only once. Behavior of the '0' label is unspecified if it occurs more than once.

Data Structures
There is a deque bounded only by memory limitations and a general purpose register, which will henceforth be referred to as villanova. All operations that modify the deque do so to the front of it, but which end is the front may be toggled. The only data type for all non-I/O operations is an 8-bit integer.

Errors
There are only two possibles errors in theory: Making the instruction pointer leave the program playing field, and trying to pop an empty stack.

In practice, there are also limits on the size of the program and the length of the deque.

Self-intersecting Code
Given multiple lines of code intersecting, it is possible to create an intersection such that if the instruction pointer begins at either end of any line in either right-turning or left-turning mode, it can be mapped to either end of any line so that it arrives in either right-turning or left-turning mode according to any bijection using only the bridge and spiral operators.

The simplest and most useful intersection is one in which two lines of code cross right over each other without changing states. The simplest intersection that accomplishes this is thus:

=   =   @=@ === ===   @=@    =    =

Although the following will also work:

=   =   =@ =@@@===   =@    =    =

If you wanted an intersection where the instruction pointer always turns right and arrives without changing states, the following is the current smallest and fastest method:

=         =     === ===     = =@@ @@=    @=@  =@= = ==== === =  ==@====    @=@ ===  = ==     =       =     ==@=====@          @          =          =

Making it smaller and faster is left as an exercise to the reader.

Notice the little bit on the right that looks like this:

==@====  ==

This object toggles the turning mode of the instruction pointer only if it is coming from the left.

Using that object, here is an object through which the instruction pointer can pass only if it is in right-turning mode; otherwise it goes back the way it came:

=  =  === == @= =@ ==  ===   =   =

The mirror image of this object allows the instruction pointer to pass only in left-turning mode.

Hello World
e0v ***  *eXlv**   *lX      *2X       **oXi v * * *  *     *   * 2      * o      **   v* * * * *   * *****   * v      * v      * *iX * * * * *  * *       * ^      v *      * * w * * *** *  * *****   * v      * *      * * v * *    *   *     ^   * ^      * *      * * * * * *** *   * ****v   * v      * *      v * * * * * * *  * *       * *      * *      ^ * * * * * * *   * *****   * *****  * *****  * *** * * * * *   *     *   *     *  *     *  **   ** *** ***   *******   *****v^  *******   ***** *wX ***   **3Xp    *rX4.. d5*     qd** * 3 * *  **   v^   *    .. * *     *  *** * v * ^   * #pX v   * .. . * *      *    ** * *** v   * # r #   * .. . * *      * !q* * * * * *  * # v #   * 54 .. * *     * * * * * * * *   * # * #   *   @X   * *      * * * * * * * *  * # * #   *   v    * *      * * * * * * * *  * # * #   * * **   * *      * * * * *  *  *   * # * #   * ** **  * *      * *** * *  *  *   * #v* ^   * *** *  * *****  *    ** ** * **  **   *v   * * * *  *     *  *  *** *****    *v^**    *** ***  *******  ****

Rot13
0@v*v^*v^*v^*v^*v^*v^*v^*v^*v^*v^*v^*v^*v^*v^*v^*v *^v*^v*^v*^v*^v*^v*^v*^v*^v*^v*^v*^v*^v*^v*^v*^v*^ v ^*v^*v^*v^*v^*v^*v^*v^*v^*v^*v^*v^*v^*v^*v^*v^*v= ***^v*^v*^v*^v*^v*^v*^v*^v*^v*^v*^v*^v*^v*^v*^v*^ * **********v^*v^*v^*v^*v^*v^*v^*v^*v^*v^*v^*v^*v^## *^v*^v*^v*^v*^v*^v*^v*^v*^v####################### v ^*v^*v^*v^**************v^*v^*v^*v^*v^*v^********** #                         v*^v*^v*^v**************^v ====              X    @ i:vX==:====    u@vX=@v i!  ==XX  ===v^== X vs.vuv    @===        s=vv=X=$v=  v                              =X     X =  # ===@v@X
 * 1) ^v*^v*^v*^v*^v*^v*^v*^v*^v*^v*^v*^v*^v****
 * 1) v^*v^*v^*v^*v^*v^*v^*v^*v^*v^*v^*v^*

99 bottles
With JSpI 1.2 comments

b****v^v+^v+^v+.******v^v+^v+^*v+^v+.******v^*v+^* =                                               v = *^+v*^v******..v^+v^+v^+v*^+v^v*******.+v*^+v*^+ = v+^v+^v+.******v^v+^*v+^v+^*v+.*******v^v+^v+^*v =                                               + = +v*^+v*^+v*^+v*^v******.+v^+v^+v^v****Xv# *@+v*^ = .                                   =  . v . *                                    $X @=~ = *                                   v   XX = *                                    @=====X = * = **v^v+^*v+^*v+^v+.****v^v+^v+^v+.******v^v+^v+^* +                                               v v^+v*^+v^+v^v*******..v^+v*^+v^+v*^+v^v******.+v^+ w****v^v+^v+^v+.******v^*v+^*v+^*v+^*v+.******v^*v .                                               + . +v^+v^+v*^+v^v*******.+v^+v^+v^v****.+v^+v*^+v*^ v .******v^*v+^v+^v+^v+.******v^v+^*v+^v+^*v+.**** ^                                               v + ^+v^+v^v******.+v*^+v*^+v*^+v^v*******.+v^+v^+v^ v v+^*v+.**** ^          * +v^+v*^+v*^v* n****v^*v+^*v+^*v+^v+.******v^*v+^*v+^*v+^*v+.**** .                                               v + +v*^+v*^v******.+v*^+v^+v*^+v*^v******.+v^+v^+v^ v ^*v+^*v+.*******v^v+^v+ *                      ^ ^+v^+v*^+v^v******.+v^+v* s****v^v+^*v+^*v+^*v+.******v^*v+^*v+^*v+^*v+.**** .                                               v + ^+v*^+v*^v******.+v^+v^+v*^+v^v*******.+v^+v^+v^ v *v+^*v+.****v^v+^v+^v+.*******v^v+^*v+^v+^v+.*** ^                                               * v ^+v^v****.+v*^+v^+v*^+v^v******.+v^+v^+v^+v*^v** * v+^v+.*******v^v+^v+^*v+^*v+.*******v^v+^*v+^v+^ *                                               v * .+v^+v*^+v^+v^v*******.+v*^+v*^+v*^+v*^v******.+ * ******v^v+^*v+^v+^*v+.****v^v+^v+^v+.******v^v+^ *                                               v . v^+v*^+v^v******.+v^+v*^+v*^+v*^v******.+v*^+v^+ + +^v+.****v^v+^v+^v+.******v^v+^v+^*v+^v+.******* v                                               v ^ v^+v^v****.+v*^+v^+v^+v*^v*******.+v*^+v^+v*^+v^ + +^v+.*******v^v+^v+^*v+^*v+.******v^*v+^*v+^*v+^ v                                               * * .+v*^+v^+v*^+v^v******.+v*^+v^+v*^+v*^v******.+v ^ ****v^v+^v+^v+.******v^*v+^*v+^v+^*v+.******v^*v +                                               + v v*^+v^v******.+v^+v*^+v^+v^v*******.+v*^+v*^+v*^ * +^v+^* ^     v v*****.+ t*****v^v+^*v+^v+^v+.******v^v+^v+^v+^*v+.******v^ .                                               * + ^+v^+v^v****.+v*^+v^+v*^+v^v******.+v*^+v*^+v^+v v v+.******v^*v+^*v+^*v+^*v+.******v^*v+^*v+^*v+^v ^                                               + v +v^v******.+v^+v^+v^v****.+v*^+v^+v*^+v^v******. * ^*v+^v+^v+.******v^*v+^*v+^*v+^*v+.*******v^v+^* *                                               v * ^+v*^+v*^v*****.+v^+v*^+v*^+v*^v******.+v*^+v*^+ * v+.****v^v+^v+^v+.****v^v+^v+^v+.*****v^v+^v+^v+ *                                               ^ . v^+v*^+v*^+v^+v^v*******.+v*^+v^+v^+v^v******.+v + ..****v^v+^v+^v+.******v^*v+^v+^v+^*v+.*******v^ v                                               v ^ .+v*^+v^+v^+v^v******.+v^+v^+v^v****.+v^+v^+v*^+ + *******v^v+^v+^*v+^v+.******v^*v+^*v+^*v+^*v+.** v                                               * * *****.+v^+v*^+v*^+v*^v******.+v*^+v^+v*^+v^v**** ^ *v^v+^*v+^v p*****v^*v+^*v r**** +          + .            = =   * v*^v*****.+v^ +v^v*****.+v^+ .+v^v f      09*vq $=@==*==vvv* v$   v    v +v*^+v X qvX***v** 9**+^* !  *v       ========= *^     ==       ==Xv *+     = ====@=  v w   *v  p   = =    ===bX= v^ ===== n v^v   = *==    vX= ,@*v=Xv@,v^ v        @           + ==fX***v~=#v~==X =====  *v r v    XX   X    =   =  ^ ==X    =    =vv*== X @  + ======== v@=t=##v@=#v  v             X  X         * @=@=        ^           s=== # **v^v+^v+ X=v v * ## *** \\\\\ 649\Prints " on the wall". 998\Prints "No more" 1230\Prints "Go to the store and buy some more.\n" 2329\Prints "Take one down. Pass it around.\n" 3261\Prints ".\n". 3276\Prints \n. 3373\This program prints the lyrics to (one version of) the song "99 bottles of beer on the wall." 3420\The main loop. Sets up state for each verse, then calls the printing function until 0 is reached. 3430\Puts 99 on the stack. 3614\Prints one verse.