Silberjoder

From Esolang
Jump to: navigation, search
Silberjoder
Paradigm(s) imperative
Designed by User:Quintopia
Appeared in 2016
Computational class Turing complete
Reference implementation See below
Influenced by Aubergine, Self-modifying Brainfuck
File extension(s) .sbj


Silberjoder is a language created by User:Quintopia for the CALESYTA 2016 contest. The design metagoals were to simultaneously satisfying User:Boily's desires for another Aubergine derivative while outraging everyone else (including, possibly, the contest prize selection committee) with another Brainfuck derivative. The design goals were to mesh, as seamlessly as possible, the feature set, syntax, and semantics of Self-modifying Brainfuck with those of Aubergine. Most importantly, all extant programs in either language should also be valid Silberjoder programs with the same behavior.

Syntax

A Silberjoder program contains a mix of two types of instructions:

* Brainfuck instructions, which consist of a single character, which must be one of the 8 standard Brainfuck instructions.
* Aubergine instructions, which consist of three characters, which form a valid Aubergine instruction, except that c and C are also valid in the second and third positions.

Semantics

Silberjoder has four registers, named "a", "b", "c", and "i" which are doubly-unbounded integers. In addition, there is an doubly-infinite tape whose elements are doubly-unbounded integers. At initialization time, the tape contains an ASCII-encoded copy of the Silberjoder program, whose first character is at position 0 on the tape, registers a, b and i are set to zero, and c is set to the length of the program.

Aubergine instructions behave exactly like the Aubergine spec describes, although it is legal to jump to or set the instruction pointer "i" to any value, even beyond the bounds of the program. Furthermore, the additional register "c" can be used and dereferenced just like "a" and "b". The instruction pointer is incremented by 3 after every Aubergine instruction.

Brainfuck instructions behave exactly as in SMBF, and use register c as the data pointer. Thus ">" is equivalent to "+c1", "+" is equivalent to the Aubergine "+C1", and "," is equivalent to "=Co". One exception is that "+" and "-" are interpreted as the first character of Aubergine instructions if and only if the following two characters would form a valid Aubergine instruction. "[" and "]" modify the instruction pointer "i" as expected. There is no requirement that "[" and "]" be matching, as in mbomb007's Python SMBF interpreter: matches to brackets are sought out dynamically as the program may change over time. The instruction pointer is incremented by 1 after every SMBF instruction.

All characters which don't form valid instructions of either type are treated as NOPs, and increment the instruction pointer by 1.

A program ends when the instruction pointer lands somewhere on the tape that is a zero and has nothing but zeros to the right of it, or when a search for a matching bracket fails.

Examples

Quine:

-cc[.>]

Truth-machine:

0,.-CA[<.>]1

Counting up in Unary:

1+=bc[>=CB[=oA-]<<.>+]

Printing a number in decimal:

0>,[[-[-[-[-[-[-[-[-[-[-[>+<=ib]<+>]<+>]<+>]<+>]<+>]<+>]<+>]<+>]<+>]<+>]>]<<[+CA.<] 

Note that the last character of the last example is a NUL byte. (This could be avoided, but it would make the example longer.)

Implementation

Python 2: https://github.com/quintopia/Silberjoder/blob/master/silberjoder.py