Dark

Dark is an Esoteric programming language by David Catt (user:David.werecat) which is designed to be inherently evil.

Introduction
Dark is a language based on manipulating entire worlds and dimensions to achieve goals and to build the best torturous reality possible. Each program is read as a series of commands to objects with the goal to twist each world as much as possible. Due to its poorly designed documentation, it's likely that even the descriptions of the language are inherently evil.

Language Basics
note: In all code examples, whenever {} brackets are used, they provide information about part of a command (eg.  would denote a line containing an object name followed by a colon, followed by a function name; an example of such a line could be  )

The language is based entirely on objects. At the start of every program, an object of type HELL must be declared (syntax: ). This object allows the creation and manipulation of other objects, and is the basis for the program. An object is used by specifying the object name and the function to run on that object (syntax: ). All lines of the program with exception to the first line should be in this format, unless the line is either a blank line or a comment. Commented lines must start with a pipe symbol (|) and end with another pipe symbol. All object names are case sensitive.

Whenever a syntax error occurs, the program's sanity decreases by 1. The program's sanity starts at 100. If the program's sanity reaches zero, the interpreter goes insane. Whenever a general error occurs, the interpreter prints out the line "Murphy's Law is working correctly.".

When the program ends, any active objects will be dealt with and appropriate error messages will be output to the console detailing the cleanup process. As such it is recommended to destroy all objects before the program ends. Variables are also dealt with similarly.

Specifics
All objects are stored in a memory area known as the CONTROL_SPACE, separate from all variables. Variables are local to each manipulator and are stored in a memory location known as the WORLD_BLOCK. There is a global queue of strings known as the VOICELIST, which stores the values of signs.

Reference Interpreter
The reference interpreter is fully compliant with the Dark programming language. It accepts multiple source files are command line arguments. Each input file is interpreted separately and sequentially. Options may also be tweaked using the command line. Command line arguments only affect the source files after the argument. Possible arguments are: The reference interpreter also complies to undocumented parts of the Dark standard.

HELL
The hell object is the base object of the program, declared in the first line of code. There may only be one HELL object per program. A HELL object accepts the following commands:

MANIPULATOR
A manipulator is an object that allows the management of variables. A manipulator can hold a maximum of 1024 variables. When a variable is freed, it leaves decay behind. This decay must be cleared using the VOID function to reopen the variable spot to new variables. There are several variable mechanics. Variables with the same name as another variable in another manipulator can be defined, although when used can cause problems. A manipulator can only manipulate its own variables, therefore variable operations across manipulators must use a SIGN object as temporary storage. All variables are unsigned integers that can be either 8,16,32 or 64 bits long. When variables are not used for over 65536 cycles, they start to accumulate corruption. Corruption flips a single bit in the variable when it occurs. Each variable must have a disposition. If a variables with dispositions that are more than one apart are used in a function, they conflict and the variables are killed. Variables must also be defined as either a SERVANT or a MASTER. A servant must select a master variable. When the master dies, all servant variables attached to that master also die. This is useful for grouping and mass killing variables. A manipulator object accepts the following functions:

ENTROPY
An entropy object allows program flow control. Labels may be nested, and will not be redefined inside other labels unless they are undefined. Choices may be nested, but each nested choice must be from a different entropy object. Accepted functions are:

STALKER
A stalker object controls all basic IO functions. A stalker starts uninitialized, it must be initialized using the stalk function. If a stalker is not initialized, any attempts to perform IO will result in depressing error messages to be written to the console. A stalker has two modes, DISTANT (default) and PERSONAL. While in distant mode, all output is written to a buffer and must be flushed to the console using the paracusia function. Switching modes will not cause the buffer to be flushed. When a stalker is in personal mode, all output is written to the console instantly.

SIGN
Sign objects are containers for strings. A sign is a representation of a queue of character codes. Signs accept the following functions:

CAT Program
+deadcat hell deadcat$twist stalker killer deadcat$twist manipulator person deadcat$twist entropy fate killer$stalk killer$personal person$manufacture weapon 0 8 master fate$corpse violence killer$control weapon killer$action weapon fate$stumble violence fate$illusion violence person$kill weapon deadcat$consume person deadcat$consume killer deadcat$consume fate deadcat$apocalypse

Hello, world!
+hello hell hello$twist sign hws hello$twist stalker io io$stalk io$personal hws$scrawl " Hello, world! hws$read io$echo hello$empty hello$apocalypse

Fibonacci Sequence
+fib hell fib$twist stalker creep fib$twist entropy cruelty fib$twist manipulator darkone creep$stalk creep$personal darkone$manufacture new 0 64 master darkone$manufacture this 0 64 servant new darkone$manufacture last 0 64 servant new darkone$manufacture ltr 0 8 master darkone$set this 1 cruelty$corpse fate darkone$add new last this darkone$set last this darkone$set this new creep$action # this cruelty$choice this <= 9223372036854775807 darkone$set ltr 44 creep$action ltr darkone$set ltr 32 creep$action ltr cruelty$stumble fate cruelty$reprogram darkone$omnicide darkone$void fib$empty fib$apocalypse

General Language/Interpreter Test
+test hell |Initialize objects| test$twist manipulator overseer test$twist manipulator leader test$twist entropy fate test$twist entropy path test$twist stalker spy test$twist sign bbs test$twist sign keep_out |Define a few variables| overseer$manufacture politician 0 64 master overseer$manufacture person1 0 32 servant politician overseer$manufacture person2 0 16 servant politician overseer$manufacture person3 0 8 servant none leader$manufacture person1 0 16 master leader$manufacture test1 0 32 servant politician leader$manufacture test2 0 32 servant test3 leader$manufacture test3 0 32 servant test2 leader$manufacture hater 5 8 master leader$manufacture hated 9 8 master |Check that stalker is not initialized| |Should give depressing errors| spy$action politician spy$control politician |Initialize stalker| spy$stalk |Test io modes with fibonacci series| |Should print Press any key to continue..., then will display the fibonacci series| spy$distant overseer$set person1 10 leader$set test1 0 leader$set test2 1 bbs$scrawl ", fate$corpse fibonacci_1 leader$add test3 test1 test2 leader$set test1 test2 leader$set test2 test3 spy$action # test1 bbs$read ~ spy$echo fate$choice test1 < 1000000 	fate$stumble fibonacci_1 fate$reprogram fate$illusion fibonacci_1 bbs$tear * bbs$scrawl " Press any key to continue... bbs$read spy$personal spy$echo spy$action person1 spy$distant spy$control test1 spy$action person1 spy$paracusia |Test that choices work and nested choices are allowed| |Should display True,True,False,True,True,True,False| spy$personal bbs$scrawl " True bbs$scrawl person1 keep_out$scrawl " False keep_out$scrawl person1 fate$choice 0 = 0 bbs$read ~ spy$echo fate$reprogram fate$choice 0 = 0 bbs$read ~ spy$echo fate$balance keep_out$read ~ spy$echo fate$reprogram fate$choice 0 <> 0 bbs$read ~ spy$echo fate$balance keep_out$read ~ spy$echo fate$reprogram fate$choice person2 = person3 path$choice person2 = 0 bbs$read ~ bbs$read ~ spy$echo spy$echo path$balance bbs$read ~ keep_out$read ~ spy$echo spy$echo path$reprogram fate$balance path$choice person2 = 0 keep_out$read ~ bbs$read ~ spy$echo spy$echo path$balance keep_out$read ~ keep_out$read ~ spy$echo spy$echo path$reprogram fate$reprogram fate$choice person2 = person3 path$choice person2 = 1 bbs$read ~ bbs$read ~ spy$echo spy$echo path$balance bbs$read ~ keep_out$read ~ spy$echo spy$echo path$reprogram fate$balance path$choice person2 = 1 keep_out$read ~ bbs$read ~ spy$echo spy$echo path$balance keep_out$read ~ keep_out$read ~ spy$echo spy$echo path$reprogram fate$reprogram bbs$tear * keep_out$tear * |Test Randomization| overseer$chaos person2 spy$action # person2 spy$action person1 |Test getting rid of master variable| overseer$suicide politician |Test garbage collect| overseer$void |Test sign functionality| |Shoud output ello, world!,world!,w,orld!,orld!,| leader$set person1 10 bbs$tear * bbs$scrawl " Hello, world! bbs$scrawl person1 bbs$tear bbs$read ~ spy$echo bbs$tear 6 bbs$read ~ spy$echo bbs$observe test1 spy$action test1 spy$action person1 bbs$steal test1 bbs$read ~ spy$echo bbs$read spy$echo bbs$read spy$echo |Test disposition conflict| leader$set hater hated |Test murphy's law| spy$action /THIS/IS/NOT/A/VALID/VARIABLE/NAME |Cleanup| test$twist manipulator final final$manufacture temporary 0 8 master final$empty test$consume final test$consume spy test$consume fate test$consume keep_out leader$suicide test3 |Should show overseer melting person3, overseer dying, leader melting person1 test1 test2, leader dying, path, bbs|

External resources
Visual Basic.NET interpreter and sample programs