esolang

Turing Complete DOM Programming Language

Every program is also an XML file.

Andriy, 2022 · Turing complete: yes · ●○○ easy · esolangs.org

Tested with 4 known programs · Test method

Run it

Expected: Hello, world!

The idea

Andriy made this language in 2022. A program is a document of <function> elements, each with a name and an id. A function holds <line> elements, and a line holds a <command> and up to four arguments, <arg1> to <arg4>. The run calls the function named main.

Read the story

There are no loops. A comparison runs one function or another, so a loop is a function that compares and calls itself. There are no number literals in arithmetic either. To add 1, a program first makes a variable called 1 that holds 1.

When several functions share a name, a call by that name runs a random one. The specification suggests this as a random number generator. In this implementation the choice comes from a sequence seeded by the program, so a run repeats.

The machine

CommandDoes
TYPE PRINTPrint arg1; PRINT adds a line feed
TYPE VAR PRINT VARPrint the variable arg1
SET STRING SET INT SET FLOATSet the variable arg1 to arg2
ADD SUBTRACT MULTIPLY DIVIDE POWERarg2 op arg3 into arg1, all variables
TO INT TO FLOAT TO STRINGConvert arg2 into arg1
EQUALS MORE LESSCompare arg1 with arg2, then run the function arg3 if true, arg4 if not
RUN FUNCTION BY NAME RUN FUNCTION BY IDRun a function
INPUTPrint the variable arg2, then read a line into arg1
SLEEP EXITWait; stop

That is 23 commands. Values behave as in Python, which the specification names as an influence. Whole numbers have no size limit, / always gives a decimal, and a decimal prints with its point, as 2.0.

Example

Numbers in arithmetic come from variables named after them.

Numbers in arithmetic come from variables named after them.

Expected: 42

The Fibonacci program, with less whitespace. fibo prints a number, steps the pair on, and calls itself through LESS until it has printed n numbers. nothing is an empty function for the other branch.

Expected: How many numbers from Fibonacci's sequence do you want to see? 0 1 1 2 3 5 8

Patterns it teaches

Further

Markup languages

Write your own in Run Convert a program from Turing Complete DOM Programming Language

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: turing-complete-dom-programming-language.

Command line

shib run turing-complete-dom-programming-language -e '<?xml version="1.0" ?>

<code>
	<function name="main" id="1">
		<line>
			<command>PRINT</command>
			<arg1>Hello, world!</arg1>
		</line>
	</function>
</code>'
shib manual turing-complete-dom-programming-language

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/turing-complete-dom-programming-language.js

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

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