esolang

^!

Push a zero, add one. Everything else is moving bytes between two stacks.

Ninesquared81, 2022 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 7 known programs · Test method

Run it

Expected: Hello, World!

The idea

Ninesquared81 made ^!, said caret-bang, in 2022. It began as an easier way to write programs for Motorway and then grew a second stack of its own. The only constant is 0, pushed with ^, and ! adds one to the top. Every value is a byte that wraps, so 128 doubled is 0. The Hello World uses exactly that to end its loop of powers of two.

Read the story

Any character that is not an instruction is a comment, so programs carry their notes in the margin. Text in parentheses is a comment as well, even when it holds instructions, and parentheses nest.

The machine

InstructionDoes
^ !Push 0; add one to the top
* :Drop the top; duplicate it
, .Read a byte, 0 at the end of input; pop and print one
+ -Pop the top and add it to, or subtract it from, the next
% @Swap; turn c b a into b a c
> <Move the top of main onto aux; move it back
? ;Push 1 if main, or aux, holds anything, else 0
$Pop and exit with that status
[ ... ]Pop, and run the inside while the popped byte is not 0
( ... )A comment

Taking from an empty stack is an error.

Example

The Hello World builds the powers of two from 2 to 128 on aux, then takes them back and adds them up into…

The Hello World builds the powers of two from 2 to 128 on aux, then takes them back and adds them up into letters.

The cat, with its notes in place. The words are comments because none of their letters is an instruction.

Expected: meow

The truth machine without its comments. It subtracts 48 from the input and exits on anything but 0 or 1. On 1 it prints 1 forever, and on 0 it prints 0 once.

Expected: 0

^! is Turing complete because brainfuck translates into it one instruction at a time. Main holds the current cell with the cells to its right under it, and aux holds the cells to its left. This is ++++++++[>++++++++<-]>+. put through the specification's table.

Expected: A

The specification also has Clean, a ^! program that strips the comments out of a ^! program. Run on its own source it prints itself on one line, as the specification shows, and it does the same.

Patterns it teaches

Further

Stack-based

Write your own in Run Convert a program from ^!

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: u5e-21.

Command line

shib run u5e-21 -e '^!!:[:>:+:]<<:<<@<::>@+.%>%:>@:>+!!!!:!.:@+:::..!!!:.<<:<<@:@:@+<:@+.%>%.+%>+!!!.:.!!!...<!.<<+.'
shib manual u5e-21

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/u5e-21.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org