LstackG
- The title of this article is not correct because of technical limitations. The correct title is actually <stack>.
Paradigm(s) | imperative |
---|---|
Designed by | None1 |
Appeared in | 2023 |
Memory system | Stack-based |
Dimensions | one-dimensional |
Computational class | Push-down automata |
Reference implementation | C++, JavaScript |
Influenced by | Brainfuck |
File extension(s) | .lsg |
<stack> is an esolang created by User:None1. It's very brainfuck-like. However, it's not Turing complete.
Opcodes
There are only 7 valid opcodes in <stack>, which are <,s,t,a,c,k,and >, other characters are ignored. <stack> is case sensitive.
Execution
Just like its name, <stack> is stack-based, and the stack contains only 8-bit integers (bytes).
In the beginning, there is an initial 0 in the stack, and each opcode does something to the stack:
<
If the the top of the stack is zero, move to the matching >, otherwise just move to the next character.
s
Pushes a 0 into the stack.
t
Reads a character from the standard input, and pushes its ASCII value into the stack.
a
Adds 1 to the top of the stack, when the result is 256, it becomes 0 to fit in a byte.
c
Print the top of the stack to standard output as a character, then pop it, does nothing if the stack contains less then 2 elements.
k
Pops from the stack once, does nothing if the stack contains less then 2 elements.
>
If the top of the stack is not zero, move to the matching <, otherwise just move to the next character.
It's obvious that the stack NEVER becomes empty.
Translate to Brainfuck
Any <stack> code can be translated to Brainfuck using the table below, but the opposite is not true.
<stack> Brainfuck (begin) >+> < <<[>> s >> t ,>> a <<+>> c >+<-<-[>+<<.[-]->>]-[+>-]+<<+>>[->+] k <[>>]< > <<]>>
Example Programs
Hello World program (very long!):
saaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaacsaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaacsaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaacsaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaa<taaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa>k<aaaaaaaaaac>
Reads text, prints <stack> code that prints it:
a<saaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaact<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac>aaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaac>
The name of this language is also considered an example program, which does nothing.
Existence of a quine
Does <stack> have a non-empty quine? The answer is probably no, but I (User:None1) can't prove it.
The content here should be changed if someone proves that a <stack> quine exists or not.
External Resources
Webpages
- GitHub repository of <stack>
- The webpage of <stack>
Offline Interpreters
- An interpreter in C++, written by the creator of this language (User:None1). as Windows executable (64 bit)
- An interpreter in JavaScript which uses non-interactive I/O, also written by User:None1.
Online Interpreters
- <stack> playground, where you can run <stack> code directly online.