esolang
Learn · LessonsLesson 18 of 18

Lesson 18

Write your own esolang

In these lessons an esolang is a dictionary. A header line, reading rules from patterns to kernel tokens, and words make up the whole definition.

The lesson

The kernel does the rest, with the same step limits and the same debugger for every language.

The example is a small accumulator language. The exercises describe two more; their test programs are fixed.

The Studio's Make a language tab writes these files with a form, and the .shib format in the Docs lists every header setting.

Example

Change the language file or the program, then run it.

Output


Exercise 1

Write an accumulator language. ^ adds one, v takes one away, . prints the accumulator as a byte and , reads a byte into it.

Write the rules in the language file. Check runs every test program with your language.

The tests they must pass
ProgramInputExpected output
,^.ab
,.v.bba
,.,.,.xyzxyz

Output


A hint

0 LOAD reads cell 0, 0 STORE writes it, READ pushes the next input byte.

One answer

Answer: Write an accumulator language. ^ adds one, v takes one away, . prints the accumulator as a byte and , reads a byte into it.

Expected output

b
The tests they must pass
ProgramInputExpected output
,^.ab
,.v.bba
,.,.,.xyzxyz

Output


Exercise 2

Write a stack calculator. The digits 0 to 9 push themselves, + adds, * multiplies and p prints the top as a byte.

Write the rules in the language file. Check runs every test program with your language.

The tests they must pass
ProgramInputExpected output
88*1+p(empty)A
99*9+9+p(empty)c
76*p(empty)*
5 5 * 8+ p 2 p(empty)!\x02

Output


A hint

Ten rules like "7" => 7, then "+" => ADD and "*" => MUL.

One answer

Answer: Write a stack calculator. The digits 0 to 9 push themselves, + adds, * multiplies and p prints the top as a byte.

Expected output

A
The tests they must pass
ProgramInputExpected output
88*1+p(empty)A
99*9+9+p(empty)c
76*p(empty)*
5 5 * 8+ p 2 p(empty)!\x02

Output


Read more