diff options
| author | Cody <cody@codyq.dev> | 2022-12-15 13:23:48 -0600 |
|---|---|---|
| committer | Cody <cody@codyq.dev> | 2022-12-15 13:23:48 -0600 |
| commit | bddb011df4999f7ffeeddf6a4b66e2da6ab19ea0 (patch) | |
| tree | 874d175f352f1a4688e7e62d1f9222a192ae9bff /tour/variables.sloth | |
| download | sloth-bddb011df4999f7ffeeddf6a4b66e2da6ab19ea0.tar.gz | |
Initial language designs & lexer from crafting interpreters
The very initial language designs I came up with for Sloth. Likely
contains inconsistencies and definitely contains things that will be
changed in the future. This is basically just a dump of every idea I've
had for the language thus far.
As for the lexer right now it is heavily based on the one from the
Crafting Interpretrs book and doesn't yet parse Sloth grammar.
Diffstat (limited to 'tour/variables.sloth')
| -rw-r--r-- | tour/variables.sloth | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tour/variables.sloth b/tour/variables.sloth new file mode 100644 index 0000000..d105716 --- /dev/null +++ b/tour/variables.sloth @@ -0,0 +1,16 @@ +# Variables can be declared using the `let` keyword, however they will be deeply +# immutable. If you would like to make the variable mutable you can use `let mut` +# +# Variables can not be exported and can not be referrenced accross modules. +let x = 0; +let mut y = 0; + +x = 5; # Invalid +y = 5; # Valid + +# Constants can be declared using the `const` keyword, unlike variables they can +# be exported and accessed across modules. +const FPS = 60; + +pub const WIDTH = 5; +pub const HEIGHT = 17; |
