From bddb011df4999f7ffeeddf6a4b66e2da6ab19ea0 Mon Sep 17 00:00:00 2001 From: Cody Date: Thu, 15 Dec 2022 13:23:48 -0600 Subject: 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. --- tour/variables.sloth | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tour/variables.sloth (limited to 'tour/variables.sloth') 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; -- cgit v1.2.3