Stackowey: Difference between revisions

From Esolang
Jump to navigation Jump to search
Content deleted Content added
Lampe2020 (talk | contribs)
m →‎Interpreter: Correct wrong name of GNU GPLv3
Lampe2020 (talk | contribs)
→‎Turing-completeness: Add section about Turing-completeness of Stackowey
Tag: Reverted
Line 80: Line 80:
!
!
% </pre>
% </pre>

== Turing-completeness ==
Stackowey is probably not ''technically'' Turing-complete due to its hard-defined stack value size (and thus jumping coordinates size) of 64 bits.


== Interpreter ==
== Interpreter ==

Revision as of 18:30, 10 April 2025

Stackowey is the serious and actually functional spiritual successor of arrowey. It operates on a 2-dimensional grid of characters, called the "playfield", with each character either having a complete meaning in and of itself or no meaning at all. The source code of a Stackowey program is specified to be stored in a file with the .swy extension (which is case-insensitive but recommended to be lowercase), although this is not enforced in the official interpreter. The stack always starts out with a single 42(base 8) (or 34(base 10)) on it.

Commands

ASCII character Name Description
/ "bounce" Pops two values off the stack. Bounces the pointer off if the first one is greater than the second one
\ "backbounce" Pops two values off the stack. Bounces the pointer off if the first one is lower than the second one
? "huh" Gets UTF-8-encoded input from the user. Pushes each character to the stack as its Unicode code point, followed by a 0 up top
! "hah" Pops and outputs the UTF-8-encoded character according to its Unicode code point found on the stack
% "splot" Pops and takes the top two stack values as coordinates to jump to while not changing direction.
Note: the movement is done after the jump, so the command being jumped to is ignored!
0, 1, 2, 3, 4, 5, 6, 7 "oh", "itch", "nigh", "chan", "fire", "lamp", "glorp", "wa-ding" Pushes the corresponding number to the stack
+ "cross" Pops two stack values and pushes their sum onto the stack
_ "stumble" Inverts all bits of the top stack element
# "grille" Pops one value off the stack, calls it n and swaps the n:th and topmost stack element
@ "whirlpool" Pops one value off the stack, calls it n and pushes a copy of the n:th stack element to the top of the stack
8 "dubring" Pushes the current coordinates to the stack
9 "tailring" Halts the program
all other bytes "impostor" These are all no-ops

Syntax

The playfield must be rectangular (all lines must have the same length), with the exception of the shebang line, which is included as a convenience feature, so a Stackowey source code file can be marked executable in a *NIX environment and run directly, without needing to explicitly call the interpreter. When fetching the source code from stdin, another exception is made, that being the line --- (which separates the source code from its inputs) and all lines after it (which are the inputs). Also, a single newline character appended to the end of the source code will be ignored.

Examples

Note that most examples here include the shebang line, which is simply ignored by the interpreter.

Hello World

With code comments

Note: The code is also folded a bit and formatted in a way to make it a little easier to understand. The end result is the same as the minimal example below this one though.

#!/usr/bin/env -S ./stackowey -d
Output the string "Hello World" by calculating its unicode values: 777777777772++++++++++ (push fourty-eight to stack)1221\
/2112                  Move all the way to the left again to make the code a little easier to understand                  /
\0@ (duplicate the top stack value) ! (output the top stack value, thereby consuming it) 77771+++++0@! ("e")          1221\
/2112                                                                                                                     /
\7+0@0@!! ("ll") 3+0@! ("o") 77774++++! (" " not based on "o") 0@71++! ("w" and discard it from stack) 0@! ("o")      1221\
/2112                                                                                                                     /
\ 3+0@! ("r") Now we need to subtract, so let's do that: 5_+ (inverted(b minus one) plus a equals a minus b)          1221\
/2112                                                                                                                     /
\ 0@! ("l") 7_+! ("d" and discarded from stack) 7775++++! (exclamation point and discard it from stack)               1221\
/2112                                                                                                                     /
\ 73+! (newline) 9 (halt)                                                                                                  

Minimal

(Same method as the commented version above, but all on one line with no comments or shebang line)

77777777772++++++++++0@!77771+++++0@!7+0@0@!!3+0@!77774++++!0@71++!0@!3+0@!5_+0@!7_+!0_+!73+!9

Truth Machine

This is quite a lazy one, as it simply outputs 0 whenever zero or anything with a lower Unicode code point is last entered into it by the user and infinitely many 1s in all other cases.

#!/usr/bin/env -S ./stackowey -d
?0@7777776++++++++1@1@\!73+!9
                      0      
                      @      
                      8      
                      1      
                      #      
                      1      
                      _      
                      +      
                      1      
                      +      
                      3      
                      @      
                      1      
                      +      
                      !      
                      %      

Turing-completeness

Stackowey is probably not technically Turing-complete due to its hard-defined stack value size (and thus jumping coordinates size) of 64 bits.

Interpreter

The official interpreter's C++ source code is available under the GNU GPLv3 license on User:Lampe2020's GitHub.