esolang

EHTML

HTML is not a programming language. This one looks just like it, and is.

CadenC, 2024 · Turing complete: unknown · ●●○ moderate · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: Hello, World!

The idea

CadenC made EHTML in 2024, because HTML is not a programming language, whatever people who do not program may think. Every statement is a tag. A tag with its closing tag calls a function, with the values between the two as its arguments. A tag on its own names a variable. So <print> <i> </print> prints the variable i, and a program is a <set> of the variable main to a <function>.

Read the story

There are strings, numbers, booleans, lists, functions and types, and 50 functions for them, from <to-uppercase> to <enum-for-each>. Even <if> and <while> are functions, which take other functions as their branches and bodies.

The machine

TagsDo
<set> <x> value </set>Set a variable
<function> ... </function>Make a function; <params> names its values, <return> leaves it
<print> <input>Print a value and a line feed, or read a line
<add> <subtract> <multiply> <divide> <remainder>Arithmetic; <add> also joins strings and lists
<add-to> and the likeDo the same to a variable in place
<less> <greater> <equal> <and> <or> <not>Comparisons and logic
<if> <while> <for-each>Call function arguments by a test, in a loop or per item
<list> <push> <pop> <length> <value-at> <slice>Lists and strings

The specification leaves much to a website this implementation cannot reach. A variable lives where it was first set, a function sees the variables around the place it was made, and there are no true and false words, so a boolean comes from a comparison or from <boolean>.

Example

A Hello, world! program.

A Hello, world! program.

A loop over the letters of a string. The function <for-each> calls takes one value, named by <params>, and the second string given to <print> replaces its line feed.

Expected: ABC

Input is a line of text, and <add> joins two strings.

Expected: Hello, Ada

The FizzBuzz counts i from 1 while <less> <i> 101 </less> holds, builds Fizz and Buzz with <add-to> and prints the 100 lines it should.

Patterns it teaches

  • Camouflage: a real language dressed as markup that is not one.

Further

Also in Camouflage

Write your own in Run Convert a program from EHTML

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run ehtml -e '<set>
    <main>
    <function>
        <print>"Hello, World!"</print>
    </function>
</set>'
shib manual ehtml

Source

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

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

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