Interpreterion
Interpreterion is an esolang by User:TBPO.
Designed by | User:TenBillionPlusOne |
---|---|
Appeared in | Category:2025 |
Computational class | Unknown |
Reference implementation | Unimplemented |
Influenced by | Snowflake, Emmental, Mascarpone |
In Emmental the code can modify the way it is interpreted. In Mascarpone interpreter is data type that can be manipulated like any other value. Interpreterion goes step further - the program consists of interpreters.
Yes, you heard correctly.
THE. PROGRAM. CONSISTS. OF. INTERPRETERS.
Syntax
The program is a sequence of interpreters.
Basic syntax for interpreters is: {a:b,c:d,...}
Each pair of x:y is called definition, where x is pattern and y is operation. While x is a single interpreter, y can be any number of interpreters, including zero.
There is also interpreter template: [a:b,c:d,...]
It can occur only in definition. When it occurs as pattern, it defines that only the included definitions are checked and all other are ignored. If it's in operation, it's replaced with the pattern, but with definitions listed.
@ (Interpreter default) can occur only in the pattern. It matches all interpreters that are not matched by anything else.
Execution
Execution proceeds in steps. In each step, the interpreter does the following:
- Takes the current instruction/interpreter,
- Interprets it with previous interpreter,
- Sets the result as current interpreter.
The instruction is interpreted by checking if it matches one of the patterns in current interpreter (in order basic->template->default). If it does, then corresponding operation is executed in the previous interpreter.
Initial interpreter is {}.
When the end of the program is reached, it jumps to the start of the program. The program halts in two cases:
- If the program is empty,
- When null interpreter {@:} is set as current interpreter.
Implementation notes
It can be implemented by storing the executed interpreters in history, which consists of entries. Each entry consists of:
- interpreter,
- subprogram, initially empty.
History has initially only {} with empty subprogram.
When an interpreter is executed, subprogram of the newest entry is set to it. Then, the initial interpreter does the following until all subprograms are empty:
- Take the oldest entry whose subprogram is not empty,
- Pop one interpreter from the beggining of the subprogram,
- If the entry is the oldest, add the interpreter to history and move the subprogram of the formerly newest entry to it. Else, interpret the interpreter with the older entry and add the result to the end of older entry's subprogram.