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
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
| Command | Does |
|---|---|
TYPE PRINT | Print arg1; PRINT adds a line feed |
TYPE VAR PRINT VAR | Print the variable arg1 |
SET STRING SET INT SET FLOAT | Set the variable arg1 to arg2 |
ADD SUBTRACT MULTIPLY DIVIDE POWER | arg2 op arg3 into arg1, all variables |
TO INT TO FLOAT TO STRING | Convert arg2 into arg1 |
EQUALS MORE LESS | Compare arg1 with arg2, then run the function arg3 if true, arg4 if not |
RUN FUNCTION BY NAME RUN FUNCTION BY ID | Run a function |
INPUT | Print the variable arg2, then read a line into arg1 |
SLEEP EXIT | Wait; 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.
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.
Patterns it teaches
- Camouflage: the program passes for a data file.
See also
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-languageSource
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org