DMS

YOU DON'T MAKE SENSE

Load example 1
Load example 2
Load example 3
View on GitHub

This is an esoteric programming language that was built for Advent of Code puzzles


See command reference

A command consists of an expression, with any number of operators applied to it, for example _<@!-'A


Commands are executed in sequence, looping to the top after the last command has run.

The resulting value from each command is added to the current cell.

Outputting 0 as a char terminates the program.


You can use # to comment out the rest of a line.


There is also a more exact specification here

Expressions

SymbolNameReturns
Any sequence of digits 0-9 NUMBER The base-10 interpretation of those digits as an integer i.e. 123 returns 123
' followed by any character C CHAR The UTF-16 value of the character C as an int, i.e 'a returns 97
. CELL Value stored in the current cell
% COMMAND_POINTER The command pointer
[ CELL_POSITION_X The X coordinate of the cell pointer
] CELL_POSITION_Y The Y coordinate of the cell pointer

Operators

Let I denote the input to each operator for the descriptions of effects and return values.


SymbolNameEffectReturnsNotes
- NEGATE No effect on state -I -123 is - applied to 123, returning -123
+ SIGN No effect on state The sign of I -- 1 if I is positive, -1 if I is negative, 0 otherwise
! COMPLEMENT No effect on state 1 - I !1 returns 0, !0 returns 1, !6 returns -5
? CONDITION No effect on state I if the current cell value is positive. 0 otherwise
_ DISCARD No effect on state Always returns 0, ignoring its input Useful for creating a command that updates the state of the machine but doesn't write anything to the current cell.
@ CHAR_OUTPUT Writes I, interpreted as a UTF-8 character, to standard output. If I is 0, terminates the program instead I (unchanged) Outputting the NUL char (0) is the only way to terminate a DMS program
* INT_OUTPUT Writes I, formatted as a base-10 integer, to standard output. I (unchanged)
: JUMP Increases the command pointer by I I (unchanged) Jumping past the last command or before the first causes the command pointer to wrap around. Jumping by -1 (:-1) will result in the same command being executed in a loop.
< LEFT Decreases cell pointer's X value by I I (unchanged) Cell positions wrap at the edges of the tape
> RIGHT Increases cell pointer's X value by I I (unchanged) Cell positions wrap at the edges of the tape
^ UP Decreases cell pointer's Y value by I I (unchanged) Cell positions wrap at the edges of the tape
v DOWN Increases cell pointer's Y value by I I (unchanged) Cell positions wrap at the edges of the tape
/ PUSH Pushes I to the top of the stack The new stack size
| READ No effect on state The value on the stack I positions deep. If the stack is empty, returns the current cell value instead |0 returns the topmost stack element. Stack positions wrap around, so |-1 returns the bottom element of the stack.
\ POP Removes the value on the stack I positions deep. If the stack is empty, there is no effect. The removed value. If the stack is empty, returns the current cell value instead \0 removes and returns the topmost stack element. Stack positions wrap around, so \-1 removes and returns the bottom element of the stack.
; DEBUG Writes debug information about the current state to standard output. No other effect on state I (unchanged)