| Crates.io | simply |
| lib.rs | simply |
| version | 0.4.0 |
| created_at | 2022-09-07 09:27:38.625941+00 |
| updated_at | 2023-07-06 15:58:46.488858+00 |
| description | Simply Script Interpreter |
| homepage | |
| repository | https://github.com/ericwburden/simply |
| max_upload_size | |
| id | 660246 |
| size | 30,499 |
This project provides an interpreter for "simply script", a super-simple scripting language (inspired by Assembly) that is mostly used for coding puzzles.
"simply script" supports the following commands:
set |register| |value|
Sets the value (32-bit integer) of the indicated register. Register names can be any combination of letters, numbers, and underscore characters, but must start with a letter. This command essentially serves the purpose of assigning a value to a variable.
cpy |register 1| |register 2|
Copies the value from |register 1| to |register 2|.
add |register 1| |register 2|
Adds the value stored in |register 1| to the value stored in |register 2|. Stores the final value in |register 2|.
sub |register 1| |register 2|
Subtracts the value stored in |register 1| from the value stored in |register 2|. Stores the final value in |register 2|.
jmp |register|
The next line to execute will be the line whose value is stored in |register|. Attempting
to jump to a line number less than 1 will result in a NegativeExecutionPointer error.
jwz |register 1| |register 2|
Check the value in |register 1|. If that value is 0, continue execution at the line
number stored in |register 2|. Otherwise, continue execution with the next line.
jwz |register 1| |register 2|
Check the value in |register 1|. If that value is less than 0, continue execution
at the line number stored in |register 2|. Otherwise, continue execution with the next
line.
jwz |register 1| |register 2|
Check the value in |register 1|. If that value is greater than 0, continue execution at
the line number stored in |register 2|. Otherwise, continue execution with the next line.
jnz |register 1| |register 2|
Check the value in |register 1|. If that value is not 0, continue execution at the
line number stored in |register 2|. Otherwise, continue execution with the next line.
gth |register 1| |register 2|
If the value stored in |register 1| is greater than |register 2|, store 1 in
|register 2|, otherwise, store -1 in |register 2|.
lth |register 1| |register 2|
If the value stored in |register 1| is less than |register 2|, store 1 in
|register 2|, otherwise, store -1 in |register 2|.
out |register|
Print the value stored in |register| to standard out.
chr |register|
Print the value stored in |register| to standard out as an ASCII character if the value is a valid ASCII character code. If the character does not represent a valid ASCII character code, prints a 'ยท' character instead.
Just write your "simply script" into a text file (like "do_calculation.ok") and run the
script with simply do_calculation.ok.
Sets input value to num, then prints all values counting down from num to zero. If
num is negative, then nothing is printed.
set num 25
set one 1
set A 9
set B 5
jwn num A
out num
sub one num
jmp B
Sets input values to num1 and num2, then identifies and returns the greater number.
Just returns one of the numbers if they are equal. By convention, registers holding
line numbers for jumps are named "Excel-style" using capital letters (A-Z, AA-ZZ, etc.).
set num1 18
set num2 15
set A 10
set B 11
cpy num2 compare
gth num1 compare
jwp compare A
out num2
jmp B
out num1