Whereismystack
Overview
Whereismystack is a stack-based esoteric programming language that challenges the programmer to manipulate a string-array memory. Unlike traditional stack languages, its output is determined by a unique "Last-Two-Digits" consolidation rule, where only the final part of a concatenated memory string is preserved.
Architecture
- Memory (Stack): A dynamic array of strings, initialized as
["1", "1"]at the start of each line. - Output Buffer: A separate integer array that stores values processed by the
=operator. - Execution: The interpreter processes each line independently, resetting the memory to its initial state for every new line.
Instructions
| Command | Name | Description |
|---|---|---|
+ |
Add | Adds the last two elements and pushes the memory |
- |
Sub | Subtracts the last element (top) from the second-to-last element. If the result is negative, its absolute value is pushed. |
* |
Mul | Multiplies the last two elements and pushes the memory. |
/ |
Div | Divides the last element by the second-to-last element. Division by zero terminates the program. |
= |
Consolidate |
1. Concatenates all strings in memory into one large string. 2. For lengths ≥ 2, push the last two characters as an integer to the output buffer, applying modulo 128 to the result. 3. Core Logic: Takes the last two strings in memory, concatenates them, and pushes the resulting integer to the Output Buffer. (See Formal Definition). Resets memory to ["1", "1"].
4. Memory is reset to |
?MN |
Range Combine & Push | Accesses the sequence from index M to N-1, sum them into the current memory state, and pushes the result of the combined value modulo 128 to the memory.
(The difference between two numbers cannot be less than 2) |
r |
Reverse | Reverse last one and second-to-last element.
|
^ |
Iterates through the Output Buffer, converting each integer to its corresponding ASCII character and printing it. |
Implementation Details
- Initial State: Every line starts with
memory = {"1", "1"}. - Numeric Conversion: Strings are converted to integers for calculation and back to strings for storage.
- The last Two values This is the core mechanic.
example
input : ++--?15r=^
result : H
link
here is my interpreter :
https://github.com/realgitman1/whereismystack_interpreter.git