Dan

From Esolang
Jump to navigation Jump to search

Dan is an esoteric programming language designed by PSTF.

Overview

Dan is supposed to be Turing-complete but to be minimialized.

Original Command Table

Commands
Command Meaning
INC x Let x be x+1.
DEC x Let x be x-1.
VAR x y Open a new variable x with type y(INT, STR, ARRAY or BOOL). Once a variable is opened, it can not be opened for second time until it is closed.
DEL x Close variable x. The closed variable cannot be accessed until it is opened.
SET x y Assign y to x.
OUT x Print x.
INP The user input.
JMP l Jump to specified label.
JNZ x l Jump to specified label if x≠0.
JZR x l The reverse of JNZ.
HLT Halts.

All variable names consist of lowercase letters, underscores, or numbers (which cannot start with a number). The label names are similar to variable names, except they have a colon at the end.

Strings are quoted by double quotation mark, and uses same escape as C++'s.

There are now no libraries.

Example program

Hello, world!

VAR x STR
SET x "Hello, world!\r\n\0"
OUT x

Truth machine

VAR x BOOL
SET x INP
JZR x nope
yes:
OUT x
JMP yes
nope:
OUT x
HLT

Categories, References and Notes