esolang

Daoyu

A bit tape is a tree. You never point at a bit; you halve your view of it and merge it back.

Kaynato, 2016 · Turing complete: unknown · ●●● hard · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: H

The idea

Kaynato made Dàoyǔ (道语) in 2016, modeled on a couple of tenets of Daoist philosophy. Every tape of bits has a length that is a power of two, and a reader sees it as a tree. A reader does not walk the tape bit by bit. It halves its selection, takes the other half, or merges back up to the parent node.

Read the story

The sixteen operations are the sixteen hex digits, so every stream of bytes is a program. The program is a bit tape too, and data readers can climb into it, read it and rewrite it. Tapes nest. The program tape has a child tape for data, a reader can climb from a child into its parent, and # runs a selection as a new program.

The machine

SymbolHexNameDoes
.0IDLESNothing
!1SWAPSSwap the two halves of the selection
/2LATERGo from a left half to the right half, else merge
) ]3MERGESelect the parent node, or the parent tape's first bit
%4SIFTSMove zero hexes to the end of the tape
#5EXECSRun the selection as a program on the child tape
>6DELEVLower the level
=7EQUALSkip the next hex unless the first and last bits are equal
(8HALVESelect the left half, or go down to the child tape
<9UPLEVRaise the level and restart the program
:AREADSPrint the selection
SBDEALCHalve the tape, or destroy a tape of one bit
[CSPLITSet the left half to 1s and the right to 0s, then halve
*DPOLARSkip the next hex unless the first bit is greater than the last
$EDOALCDouble the tape with 0s, then merge
;FINPUTRead bytes into the selection

Each executor has a level, and most operations work only at low levels. At level 1 $ does nothing and [ only halves, so a program can restart with < and skip its own setup. The specification's table of levels is an image; an operation does nothing above the levels the text gives it.

Example

$$$ doubles the one data bit three times into a byte of 0s.

$$$ doubles the one data bit three times into a byte of 0s. (( selects its first two bits and []! makes them

  1. )/( moves to the first two bits of the second nibble, [] makes them 10, and )) climbs back to the byte.

That is 0100 1000, which is 72.

The Hello World edits that one byte line by line, printing it with : after each.

Expected: Hello world!

The cat reads a byte, prints it and restarts with <. Back at level 1 the three $ do nothing, and > lowers the level again for the next byte. The end of the input ends the run.

Expected: cat

The shorter Hello World climbs out of its data into the program itself and prints its own second line, whose symbols spell Hello world!, a line feed and three NUL bytes. Then S cuts that half off the program. The truth machine prints 0 and ends on 0, and prints 1 for ever on 1.

Patterns it teaches

Further

Self-modifying

Cell-based

Write your own in Run Convert a program from Daoyu

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: daoyu.

Command line

shib run daoyu -e '))))))))/:((((((S...............
%(>#>[>[>;/.==>;=/>[>%/!.:......'
shib manual daoyu

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/daoyu.js

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

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