SpaghettiScript

From Esolang
Jump to navigation Jump to search

SpaghettiScript is a joke language created by User:UltimateProGrammer in 2020. It is similar to bf, however it uses the idea of functions. All code in SpaghettiScript is called spaghetti code. It is tape based, and Turing-complete. Each number on the tape starts at zero, and is called a cell. The fork points to cells. The syntax is as follows:

Command Explanation
[ Start a function. Must be followed by a positive integer representing the function's number, then valid spaghetti code.
] End a function.
- Subtract 1 from the value on the current cell.
~ Add 1 to the value on the current cell.
or The fork position is moved right one. The second option can be chosen for better Unicode support.
or The fork position is moved left one. The second option can be chosen for better Unicode support.
:O Output the current cell's value.
:o Set the current cell's value to input.
{o=(digit)} Only run the following fork function call if the stomach (current cell, represented by o) is equal to the digit following the equals sign.
---≡ or ~~~≡ Call the function with the number immediately following the fork.

Optional Commands

Commands that are not part of the spec, though can/should be used in an implementation.

Command Explanation
O Hold the current cell's value in memory
≡O Set the current cell's value to what is in memory
:OA Outputs the current value in memory as ascii.

Notes:

  • Some commands in SpaghettiScript are Unicode, so it may not look correct on devices without Unicode support.
  • If the fork function call starts with dashes (-), the position on the tape will be set to 0 when the function is called. If it starts with tildes (~), the tape will stay where it was when the function was called.
  • Functions cannot be made inside other functions

Examples

Hello World (newlines for readability):

[1~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:OA
⇢~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:OA
⇢~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:OA
⇢~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:OA
⇢~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:OA
⇢~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:OA
⇢~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:OA
⇢~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:OA
⇢~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:OA
⇢~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:OA
⇢~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:OA
⇢~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:OA] ---≡1

Cat:

[1:o:O] ---≡1

FizzBuzz (WIP-Does not print original number if neither are true):

---≡1 [1:oO⇢≡O⇢≡O---≡2]
[2--- {o=0}---≡3 {0=-1}---≡4 {o=-2}---≡4 ---≡2]
[3~~~:O---≡4]
[4⇢----- {o=0}---≡5 {o=-1}---≡6 {o=-2}---≡6 {o=-3}---≡6 {o=-4}---≡6 ---≡4]
[5⇢~~~~~:O] [6]

Implementation

The implementation is available here. It is hosted on GitHub Pages. It was created by UltimateProGrammer (talk).