Simply Script

This project provides an interpreter for "simply script", a super-simple scripting language (inspired by Assembly) that is mostly used for coding puzzles.

Syntax

"simply script" supports the following commands:

Set Command

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.

Copy Command

cpy |register 1| |register 2|

Copies the value from |register 1| to |register 2|.

Add Command

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 Command

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|.

Jump Command

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.

Jump When Zero Command

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.

Jump Not Zero Command

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.

Greater Than Command

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|.

Less Than Command

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|.

Output Command

out |register|

Print the value stored in |register| to standard out.

Usage

Just write your "simply script" into a text file (like "file.simply") and run the script with simply file.simply.