Stu

From Esolang
Jump to navigation Jump to search

Stu is an esoteric programming language created by User:PythonshellDebugwindow.

Syntax

Stu is designed to look like the desires of a young boy named Stu. Each command starts with "Stu wants to". Commands are separated by newlines, and there must be at most one command per line. Invalid commands do nothing. Variable names must match the regex [A-Za-z0-9]+. Strings are sequences of non-newline characters delimited by double quotes.

Commands

I/O

Input
Stu wants to know something and put it in <var>!

reads a string into the variable <var> from STDIN. The word "know" can be replaced with "ask you", and a comma is optional after "something", so the following two lines:

Stu wants to ask you something and put it in text!
Stu wants to know something, and put it in text!

are equivalent.

Optionally, the text " unless he already knows it." can replace the exclamation mark:

Stu wants to know something and put it in text unless he already knows it.

If this check is used, input will only be read if the variable to read into has not yet been read into. A comma is optional after the variable name ("text" in the above program) when using this check. Therefore, the program:

Stu wants to know something and put it in text!
Stu wants to know something and put it in text unless he already knows it.

will read just one input.

Output
Stu wants to tell you something: <expr>

prints out the result of <expr>, which must be a series of variable names and strings separated by exactly one space (ASCII/Unicode 0x20). When printing the values of variables and strings will be concatenated together with no delimiter.

Control flow

Quitting

The command

Stu wants to leave now.

halts the program immediately; it is not required at the end of programs.

Jumping
Stu wants to go home now.

jumps back to the start of the program.

Conditional

The text

if <x> and <y> are similar.

can be appended to any line to evoke a conditional: the line will be executed iff <x> and <y> are the same. <x> and <y> can both be either variable names or strings. The word "not" can be written before "similar" to negate the conditional.

Examples

Hello, World!

Stu wants to tell you something: "Hello, World!"

Infinite loop

Stu wants to go home now.

Cat program

Stu wants to know something and put it in input!
Stu wants to tell you something: input
Stu wants to go home now if input and "" are not similar.

Truth-machine

Stu wants to know something and put in input unless he already knows it.
Stu wants to tell you something: input
Stu wants to go home now if input and "0" are not similar.