Shove

From Esolang
Jump to: navigation, search

Shove is an esoteric programming language created by User:ais523 in 2008, but ais523 forgot to tell anyone about it until 2013. It is based on the idea of shoving strings into a self-modifying, two-dimensional program, pushing other content out of the way.

Specification

A Shove program is the initial state of a two-dimensional playfield of cells containing characters, in which execution may pass in any of the four cardinal directions.

At the start of execution the instruction pointer begins on the leftmost cell of the topmost line of the program, moving rightwards until some instruction causes its direction to change. Execution halts when the instruction pointer passes beyond the boundary of the current playfield, so that no further instructions to execute can be reached.

Shove has a stack, to which strings may be pushed from the playfield, or from which they may be popped, shoving them into the playfield.

Shoving

When a string is shoved into the playfield, its first character is put into a specific neighboring cell of the currently running instruction. Further characters of the string are placed relative to the first, in the current execution direction. This does not overwrite any characters, instead an entire ray of characters, from the starting cell and onwards in the current execution direction, is shoved out of the way to make room for the new characters.

In the case where the currently executing character is one of those shoved, so is the instruction pointer, so that execution continues from after the new position of that character.

The process of shoving may enlarge the boundaries of the playfield in any direction.

Instructions

Commands Description
' " Push a string from the playfield onto the stack. The string is read in the current execution direction and ends before the matching ' or ", respectively, after which execution continues. ' quoted strings may be nested inside " quoted strings and vice versa, to unlimited depth.
< v > ^ Change direction of execution to the one pointed to.
A V ( ) Pop a string from the stack and shove it onto the playfield, starting at the neighboring cell in the direction pointed to.
  (space)
Do nothing.
! Do nothing. This also signals to the implementation that any characters behind the instruction pointer (the entire half-plane in the direction it is coming from) will never again be used.
S In implementations with output, print the string at the top of the stack, without popping it. Otherwise do nothing.
n In implementations with output, print a newline. Otherwise do nothing.

Example

Hello, World!

" ,olleH"V       v
 S"!dlroW"<

External resources