25 lines
1.5 KiB
Markdown
25 lines
1.5 KiB
Markdown
# Syntax introduction
|
|
Every Granite program is made up of "operations", a combination of operators and any number of arguments, including zero! These operations all begin with a `:` to denote the beginning of an operation, an operator, and then variables that are comma separated.
|
|
|
|
An example of a statement is the "set variable" operation, `:>10,balance`.
|
|
|
|
The statement example above simply places the integer 10 into the variable `balance`. The language's syntax may be a bit esoteric but it isn't too hard to wrap your head around!
|
|
|
|
The Granite language does not need spaces between arguments in an operation and if you add these they will be interpreted as different to how you expect!
|
|
|
|
For example the following two programs may look similar:
|
|
|
|
* `:>10,x:^x`
|
|
* `:> 10,x:^x`
|
|
|
|
but the bottom one will fail with the error `Non-number variable x on increment.` due to it perceiving the value as the string " 10" and not the integer 10.
|
|
|
|
## Types
|
|
Granite has two types: integers and strings.
|
|
|
|
Hence, Granite features no native support for floating point numbers however this can be emulated using fixed point mathematics (we do not go into this in this guidebook and should be independently researched if wanted).
|
|
|
|
Integers are considered integers if they can be coerced in string form, e.g. the string "52" can be coerced into the integer 52 hence it is an integer but the string "5 2" cannot as it is not exactly the same as a number.
|
|
|
|
## Continue the guidebook
|
|
* [Next page: Manipulating values](manipulating-values.md)
|