DSL

From Esolang
Jump to navigation Jump to search

Work in Progress!

DSL, or Damn Small Language, (Pronounced like Diesel) is a programming language created to be as small as possible, and to be usable for as many code golf challenges as possible.

Data Structures

DSL has a tape big 100000 cells and a stack, big 256 cells.

A cell can hold a single data type (i.e. Integer/Character/Float), an array of such, or a structure.

Structures

In DSL structures can be created to contain multiple values, even of different types.

Commands

DSL's commands are stored as 8-bit or 16-bit words in a file; because of the sheer quantity, they are grouped into classes.

Class A Commands

These command do something with the stack and/or its values.

They are:

Bits Mnemonic Description
010tttvv PUSH t, v Pushes new value of type T with default value V.
011tttvv OVERWRITE t, v Overwrites the value on the top of the stack with a new value; see PUSH.
1000tttt PUSHZ t Pushes new value of type T with an empty array, 0, or an empty string, depending on the type.
000tttvv INSERT t, v Acts like PUSH, but instead inserts the new element into the element currently on top of the stack if it is an an array.
001nnnnn INDEX n If the element on top of the stack is an array, it pushes its nth element.
10010000 INDEXW Pops an integer from the stack, indexes an array in the top of the stack with the popped integer, and pushes the resulting value.
100101nn SWAP n Swaps the element on top of the stack with the nth element.

Types

A 3-bit type value can be translated into a type using this table:

x00 x01 x10 x11
0x Int String Float Structure
1x Int Array String Array Float Array Structure Array

Default Values

Depending on the type, there is a different table of default values:

00 01 10 11
Int 1 256 100 -1
String "A" "a" " " "\x80"
Float 0.1 3.14 2.71 6.28