Crapsemmbly is a programming language brainfart inspired by assembly and sleep deprivation. It minimizes readability while maximizing the use of emoji. Use at your own risk.
This "simple" code calculates as many fibonacci numbers as the user chooses. Or as many as the interpreter can handle before wetting the bed with StackOverflowExceptions.
π¨ How many fibonacci numbers do you need?
π π
π¨ π
π΅ π 1
π΅ π π
π΅ π π
β π
π π π π€ π₯
β π€
π¦ π
β π π π
π΅ π π
π΅ π π
β 1 π π
πΆ π
β π₯
Every line consists of an instruction followed by parameters, all separated by spaces. Parameters may be variable names or floating point numbers. Variable names may be any UTF-8 string but must not contain whitespace chracters. There are two special instructions, π¬ and π¨, that are followed by strings which may contain whitespaces.
Arithmetic instructions (β, β, β and βοΈ) take the two arguments of their calculation as the first two parameters; the third parameter is the variable to which the result will be written, e.g. β A 5 foo takes the value stored as A, adds 5 and saves the result as foo.
The keywords π΅ and π set variables either programatically or by reading user input. To output data to the user, use the commands π¨ (print string parameter) and π¦ (print variable).
The program execution can be controlled with the keywords β (define anchor point), πΆ (goto anchor point) or with comparison instructions. Comparison instructions take the left and right side of the comparing operator in the first two params, the next two parameters are the names of the program anchors to which the execution will jump according to the result of the comparision. For example the line π foo 4 foo bar means that if the value stored as foo is less than four, the program will jump to the anchor foo, otherwise to bar.
Comments can be added using the keyword π¬.
This example might cast some light on the instruction syntax:
π¬ Print this question to the user
π¨ What's the temperature (in Fahrenheit)?
π¬ Read the user's input and save it in the variable π‘οΈ
π π‘οΈ
π¬ Subract 32 from π‘ and saveοΈ the result in π‘
β π‘οΈ 32 π‘οΈ
π¬ Now divide π‘ by 1.8 and saveοΈ the result in π‘
β π‘οΈ 1.8 π‘οΈ
π¬ Again, print static text
π¨ Converted to Celsius:
π¬ Print what we've just calculated
π¦ π‘οΈ
More examples can be found in this repo under /examples.
| Key | Instruction | Param 1 | Param 2 | Param 3 | Param 4 |
|---|---|---|---|---|---|
| β | addition | 1st addend | 2nd addend | target variable | |
| β | subtraction | minuend | subtracted | target variable | |
| β | division | dividend | divisor | target variable | |
| βοΈ | multiplication | 1st factor | 2nd factor | target variable | |
| π | less than | left side | right side | anchor if true | anchor if false |
| π | less or equal | left side | right side | anchor if true | anchor if false |
| π | greater than | left side | right side | anchor if true | anchor if false |
| π | greater or equal | left side | right side | anchor if true | anchor if false |
| π | equal | left side | right side | anchor if true | anchor if false |
| π | not equal | left side | right side | anchor if true | anchor if false |
| π¨ | οΈ print text | text to print (1) | |||
| π¦ | print variable | variable to print | |||
| π΅ | set variable | variable name | |||
| π | read input | variable name | value | ||
| β | define anchor | anchor name | |||
| πΆ | goto anchor | anchor to go to | |||
| π¬ | comment | comment text (1) |
(1) Whitespaces allowed
Why the heck would you?!
- Java 13
- Gradle
To build the interpreter, run
gradle clean buildin the project directory. This creates a runnable jar in build/libs/crapssembly-1.0-SNAPSHOT.jar
Run the interpreter jar with java. The first - and only - argument must be the path to your crapsemmbly code file.
java -jar crapssembly-1.0-SNAPSHOT.jar path/to/your/code.file