2.5 KiB
Ground Syntax Guide
General syntax
Ground uses simple instructions and arguments to run code.
instruction arg1 arg2 arg3
As an example:
stdout "Hello, World!"
Reference a variable's value (a value reference) with a dollar sign:
stdout $myVar
Reference a variable itself (a direct reference) with an and sign:
stdin &myVar
Reference a line (a line reference) with a percent symbol before a line number:
jump %10
Keywords
Note: &var can be replaced with any direct reference. $value can be replaced with a literal value or a value reference. %1 can be replaced with a line reference.
Note: In most of these functions, if a direct reference is used, the value outputted by that function will be avaliable at that variable. Any existing value inside that variable will be overwritten.
if
Make a decision based on a boolean. If the boolean is true, jumps to the line referenced.
Usage: if $value %1
jump
Jumps to the line referenced.
Usage: jump %1
end
Ends the program. Requires an integer for a status code.
Usage: end $value
stdin
Allows input from the console.
Usage: stdin &var
stdout
Allows output to the console.
Usage: stdout $value
stdlnout
Allows output to the console, appending a new line at the end.
Usage: stdlnout $value
set
Allows you to set a variable to a value.
Usage: set &var $value
add
Adds two numbers. Numbers mean an integer or a double. Outputs to a direct reference.
Usage: add $value $value &var
subtract
Subtracts two numbers. Numbers mean an integer or a double. Outputs to a direct reference.
Usage: subtract $value $value &var
multiply
Multiplies two numbers. Numbers mean an integer or a double. Outputs to a direct reference.
Usage: multiply $value $value &var
divide
Divides two numbers. Numbers mean an integer or a double. Outputs to a direct reference.
Usage: divide $value $value &var
equal
Checks if two values are equal. Outputs a boolean to a direct reference.
Usage: equal $value $value &var
inequal
Checks if two values are not equal. Outputs a boolean to a direct reference.
Usage: inequal $value $value &var
greater
Checks if the left value is greater than the right value. Outputs a boolean to a direct reference.
Usage: greater $value $value &var
lesser
Checks if the left value is lesser than the right value. Outputs a boolean to a direct reference.
Usage: lesser $value $value &var