Esolang spec
Esolang spec is an esolang invented by User:None1. Programs in this esolang are like specifications of esolangs.
Program structure
A program must be like this:
(header) ==Memory== (variable definition) ==Commands== (command 1) (command 2) ...
This esolang is case-insensitive. All whitespaces are mandatory.
Section 1: header
It must be like this:
esolang name is an esolang invented by name.
For example:
ABCD is an esolang invented by EFG.
This section has no effect, but it is mandatory.
Section 2: memory
This section defines variables, which are unbounded signed integers. Only these variables can be defined: stack, queue, accumulator and tape.
This section must be like this:
This esolang has a/an variable 1, a/an variable 2,... and a/an variable n.
and is not needed when there's only one variable. You must define at least one variable.
For example:
This esolang has a stack.
Or:
This esolang has a stack, a queue, an accumulator and a tape.
There's also a temporary variable t, but you can't access it directly.
Section 3: commands
This is the main part of the program. Each line is an instruction, which must be like this:
* command name: behavior.
The command name has no effect except for being a label. It's case-insensitive and must be at least 1 character. The behavior decides what this command does. The period at the end is not mandatory.
The following table shows all valid behaviors.
| Meaning\Operating variable | Stack/Queue | Accumulator | Tape |
|---|---|---|---|
| t=ov | Pop stack/queue | Get value of accumulator | Get value of current cell |
| ov+=t | Push into stack/queue | Store in the accumulator | Store in current cell |
| Read integer input and store in t | Read an integer | Read an integer | Read an integer |
| Print the value of t as integer | Print as an integer | Print as an integer | Print as an integer |
| Read ASCII character input and store in t | Read a character | Read a character | Read a character |
| Print the value of t as an ASCII character | Print as an ASCII character | Print as an ASCII character | Print as an ASCII character |
| ov*=t | Add stack top/queue front by it | Add accumulator top/queue front by it | Add current cell by it |
| Print "string" | Print "string" | Print "string" | Print "string" |
| If ov is nonzero, | If stack/queue is nonempty, | If accumulator is nonzero, | If current cell is nonzero, |
| If ov is zero, | If stack/queue is empty, | If accumulator is zero, | If current cell is zero, |
| Jump to label | Jump to matching label | Jump to matching label | Jump to matching label |
You can use , or and to concatenate multiple behaviors, e.g.:
* a: Read an integer, store in the accumulator.
Or:
* a: Read an integer and store in the accumulator.
Both will read an integer and then store it in the variable "accumulator".
Examples
Hello, world!
h is an esolang invented by w. ==Memory== This esolang has a stack. ==Commands== * h: Print "Hello, world!"
Truth machine
t is an esolang invented by m. ==Memory== This esolang has an accumulator. ==Commands== * a: Read an integer and store in the accumulator. * b: Get value of accumulator, print as an integer. * c: If accumulator is nonzero, jump to matching b.