Dashes

From Esolang
Jump to navigation Jump to search

Dashes is an esoteric programming language created by User:DigitalDetective47 where all instructions are comprised of dashes. It canonically uses the extension .dash for scripts.

Memory

There are two main memory locations that programs can access. One of these areas is the stack, which can contain an arbitrary number of integers of arbitrary size. If the program attempts to pop from the stack when it is empty, the program crashes. The stack starts empty. The other is the tape, which is infinite in both directions and can contain integers of arbitrary size. It starts filled with 0s. The tape head is a location on the tape, and the current cell is the cell that the tape head points to.

Commands

Commands are executed in order, except for the horizontal bar and horizontal line extensions, which exhibit the same flow behavior as a while loop in most typical languages.

All commands
Character Name Code point Description
- Hyphen‐minus U+002D Push 1 to the stack.
Hyphen U+2010 Get a character of input from the user and push its Unicode value to the stack. Push −1 if the input stream is exhausted.
Non‐breaking hyphen U+2011 Pop the top value from the stack and print its Unicode character. If the value is less than 0 or greater than 1114111, crashes the program.
Figure dash U+2012 Pop the top value from the stack and discard it.
En dash U+2013 Move the tape head one cell left.
Em dash U+2014 Move the tape head one cell right.
Horizontal bar U+2015 Pop the top value from the stack. If it is 0, jump forward past the matching horizontal line extension.
Hyphen bullet U+2043 Pop the top value from the stack, add the value of the current cell, and push the sum to the stack.
Minus sign U+2212 Negate the top value of the stack. If the stack is empty, the program crashes.
Horizontal line extension U+23AF Jump backward to the matching horizontal bar.
Two‐em dash U+2E3A Pop the top value from the stack and write it to the current cell.
Three‐em dash U+2E3B Push the value of the current cell to the stack.

All other characters are treated as comments. The program terminates without error once the end of the source code is reached.

Examples

Infinite loop

-―-⎯

Cat program

‐⸺-⁃—⸻–-⁃―⸻‑‒-—⸻–⎯―‐⸺-⁃—⸻–-⁃―⸻‑‒-—⸻–⎯⎯

Computational class

It is possible to convert any brainfuck program into a Dashes program, making Dashes Turing-complete.

brainfuck to Dashes
brainfuck command Dashes equivalent expression
<
>
+ -⁃⸺
- -−⁃⸺
. ⸻‑
, ‐⸺
[ ⸻―
] ⸻⎯

Implementations