SquidScript
SquidScript is an esoteric programming language, where each keyword is a sound or noise from the Nintendo game series Splatoon.
Description
SquidScript was originally designed as a simplistic language with few keywords. However, the scope of the project kept increasing and it is now a fully featured programming language. Featuring loops, functions, variables, arrays, non-linear arrays, reading terminal input and arbitrary lua code execution. On systems with stty (predominantly Unix-based systems), it is even possible to read singe byte characters from the terminal. Allowing one to program small games in the terminal. The language was created in September 2023.
Syntax
If the first non-whitespace character is a hash (#), it that line will be ignored in the interpreter. Effectively creating a comment.
Values in SquidScript are defined as follows:
| Type | Description |
|---|---|
| @CURRENT_LINE | Returns the value of the program counter. |
| Any float convertable value | Returns the number |
| 'x | Returns the byte of the character x (in this example, x, but any other single character is valid too)
|
| A variable name | The value the variable contains |
The full instruction set available for SquidScript:
| Cmd | Description |
|---|---|
woomy name value
|
Creates a variable name with value.
|
woomy name operation value
|
Applies the operation to name, where the first operand is the value of name, and the 2nd operand is value.
|
veemo array
|
Creates an array named array.
|
veemo array from: string-sequence
|
Creates an array named array, and fills it automatically with the string-sequence.
|
veemo# array name
|
Returns the length of the array (assuming the array is linear, if it is not, it will return the longest linear sequence) and stores it in name.
|
veemo value -> array [index]
|
Stores the value into the indexof array.
|
veemo name <- array [index]
|
Retrieves the value in index of array and stores it in name.
|
booyah! value
|
Outputs the value to the terminal as a number. Aka booyah! 'A would display 65.
|
booyah? value
|
Outputs the value to the terminal as a character. Aka booyah? 66 would display B.
|
booyah!! array
|
Outputs the content of array as a string to the terminal. If the array is non-linear, it will print out the longest linear sequence.
|
thisway@ value
|
Sets the program counter to the value
|
thisway! operand-a operation operand-b
|
Performs an calculation with operand-a and operand-b, using operation. If the return value is anything ""BUT"" 0, it will execute the code until the matching ngyes or help! is encountered.
|
help!
|
Equal to else in any other language.
|
oomy operand-a operation operand-b
|
Performs an calculation with operand-a and operand-b, using operation. If the return value is anything ""BUT"" 0, it will execute the code until the matching ngyes is encountered, at which point it will loop until the calculation be 0.
|
ngyes
|
Ends the codeblock for oomy and thisway!.
|
ouch! name
|
Defines a function with name. Functions may not be defined within eachother.
|
ouch@ name
|
Invokes the function name.
|
ouch?
|
Ends the function codeblock. |
splat! name
|
Reads an entire line of input and stores it into the variable name, this function is blocking.
|
splat? name
|
Reads a single character of input and stores it into the variable name, this function is blocking and only works for systems with stty installed.
|
help!woomy name value
|
Same as woomy, but runs before the rest of the code is interpreted. Can be used together with @CURRENT_LINE to effectively create labels one can jump too with thisway!.
|
grizzco array
|
Executes lua code stored inside of array.
|
grizzco! input-array output-array
|
Executes lua code stored inside of code-array, and stores the return value into a different output-array. If output-array does not exist, it will create it.
|
Example
A basic example showing a fibonacci sequence calculator
ouch! fib
thisway! n == 0
woomy output 0
thisway@ end_of_fib
ngyes
thisway! n == 1
woomy output 1
thisway@ end_of_fib
ngyes
woomy grandparent 1
woomy parent 3
woomy iterator 2
oomy iterator < n
woomy current 3
woomy current * parent
woomy current - grandparent
woomy grandparent parent
woomy parent current
woomy iterator + 1
ngyes
woomy output current
help!woomy end_of_fib @CURRENT_LINE
ouch?
# Read input
splat! number
veemo# number input_length
booyah? 10
# Convert the character string into a value
woomy iterator 1
woomy sum 0
oomy iterator <= input_length
veemo current <- number [iterator]
woomy current - '0
woomy sum * 10
woomy sum + current
woomy iterator + 1
ngyes
# Iterate to sum times, printing each fibonacci number
woomy n 0
oomy n <= sum
ouch@ fib
booyah! n
booyah? ':
booyah? 32
booyah! output
booyah? 10
woomy n + 1
ngyes
Here is example code, where the user is able to play a game of singleplayer pong.
This currently only works on systems with stty enabled.
woomy res_x 30
woomy res_y 10
woomy field_x res_x
woomy field_x - 1
woomy field_y res_y
woomy field_y - 1
woomy player_x 2
woomy player_y 5
woomy player_score 0
woomy ball_x 15
woomy ball_y 5
woomy ball_dir_x -1
woomy ball_dir_y 1
ouch! clear_screen
veemo clear_screen_code from: [2J
booyah? 27
booyah!! clear_screen_code
ouch?
# This assumes variables CURSER_X and CURSER_Y are set
ouch! set_cursor_position
booyah? 27
booyah? '[
booyah! CURSER_Y
booyah? ';
booyah! CURSER_X
booyah? 'H
ouch?
ouch! reset_effects
veemo reset_effects_str
veemo 27 -> reset_effects_str [1]
veemo '[ -> reset_effects_str [2]
veemo '0 -> reset_effects_str [3]
veemo 'm -> reset_effects_str [4]
booyah!! reset_effects_str
veemo '4 -> reset_effects_str [3]
veemo '0 -> reset_effects_str [4]
veemo 'm -> reset_effects_str [5]
booyah!! reset_effects_str
ouch?
ouch! draw_ball
woomy CURSER_X ball_x
woomy CURSER_Y ball_y
ouch@ set_cursor_position
booyah? 'o
ouch?
ouch! draw_outline
veemo outline
veemo 27 -> outline [1]
veemo '[ -> outline [2]
veemo '4 -> outline [3]
veemo '7 -> outline [4]
veemo 'm -> outline [5]
veemo 32 -> outline [6]
woomy CURSER_X 1
woomy CURSER_Y 1
oomy CURSER_X <= res_x
ouch@ set_cursor_position
booyah!! outline
woomy CURSER_X + 1
ngyes
woomy CURSER_X 1
woomy CURSER_Y 1
oomy CURSER_Y <= res_y
ouch@ set_cursor_position
booyah!! outline
woomy CURSER_Y + 1
ngyes
woomy CURSER_X 1
woomy CURSER_Y res_y
oomy CURSER_X <= res_x
ouch@ set_cursor_position
booyah!! outline
woomy CURSER_X + 1
ngyes
woomy CURSER_X res_x
woomy CURSER_Y 1
oomy CURSER_Y <= res_y
ouch@ set_cursor_position
booyah!! outline
woomy CURSER_Y + 1
ngyes
ouch@ reset_effects
ouch?
ouch! draw_player
veemo player_cell_color
veemo 27 -> player_cell_color [1]
veemo '[ -> player_cell_color [2]
veemo '1 -> player_cell_color [3]
veemo '0 -> player_cell_color [4]
veemo '7 -> player_cell_color [5]
veemo 'm -> player_cell_color [6]
veemo 32 -> player_cell_color [7]
woomy CURSER_X player_x
woomy CURSER_Y player_y
ouch@ set_cursor_position
booyah!! player_cell_color
woomy CURSER_Y + 1
ouch@ set_cursor_position
booyah!! player_cell_color
ouch@ reset_effects
ouch?
ouch! draw_score
woomy CURSER_X 1
woomy CURSER_Y res_y
woomy CURSER_Y + 1
ouch@ set_cursor_position
veemo label from: Player Score:
booyah!! label
booyah? 32
booyah! player_score
ouch?
ouch! simulate_ball
woomy ball_x + ball_dir_x
woomy ball_y + ball_dir_y
thisway! ball_y = 1
woomy ball_dir_y * -1
woomy ball_y + ball_dir_y
woomy ball_y + ball_dir_y
ngyes
thisway! ball_y = res_y
woomy ball_dir_y * -1
woomy ball_y + ball_dir_y
woomy ball_y + ball_dir_y
ngyes
thisway! ball_x = 2
thisway! ball_y >= player_y
woomy expr player_y
woomy expr + 1
thisway! ball_y <= expr
woomy ball_dir_x * -1
woomy ball_x + ball_dir_x
woomy ball_x + ball_dir_x
woomy player_score + 1
ngyes
ngyes
ngyes
thisway! ball_x = 1
woomy ball_dir_x -1
woomy ball_x 15
woomy ball_y 5
woomy player_score 0
ngyes
thisway! ball_x = field_x
woomy ball_dir_x * -1
woomy ball_x + ball_dir_x
woomy ball_x + ball_dir_x
ngyes
ouch?
ouch! get_player_input
ouch@ reset_effects
splat? input
thisway! input = 's
woomy player_y + 1
thisway! player_y = 9
woomy player_y - 1
ngyes
ngyes
thisway! input = 'w
woomy player_y - 1
thisway! player_y = 1
woomy player_y + 1
ngyes
ngyes
ouch?
oomy 1 = 1
ouch@ clear_screen
ouch@ draw_outline
ouch@ draw_player
ouch@ draw_ball
ouch@ draw_score
woomy CURSER_X 1
woomy CURSER_Y 1
ouch@ set_cursor_position
ouch@ get_player_input
ouch@ simulate_ball
ngyes
Interpreters
Currently, one interpreter exists, it is written in Lua. The link to it can be found here.