From 682ac98d672e6fdef03abc3e8bb99073fa376731 Mon Sep 17 00:00:00 2001
From: Maxwell Jeffress
Solstice's compiler is invoked via the solstice command. It provides some options:
-o or --output: Tells Solstice where to output a compiled file.-t or --type: Tells Solstice the type of file to output.-t or --type: Tells Solstice the type of file to output.
+At present, Solstice only supports Ground source files as an output type, but more types may be added in future.Example usage:
solstice fib.sols -o fib.grnd
@@ -60,16 +62,20 @@ puts true
puts "You can print out anything with puts!"
Solstice variables are quite simple. Assign values with =, and read them with the variable name.
x = 5
puts x
+ x = 5
+puts x
Types are automatically inferred by Solstice.
You can use + (add), - (subtract), * (multiply), and / (divide) to do math.
Math operations take two values on either side, and perform the operation. Order of operations is supported.
-x = 5 + 3
y = 10
puts x + y
+ x = 5 + 3
+y = 10
+puts x + y
Solstice supports if and while statements, as well as the ==, !=, >, >=, <, and <= operations.
Conditionals work just like maths: two values on either side, check whether the condition is correct or not based on those values, and output a boolean.
-puts 5 == 5
puts 5 != 5
+ puts 5 == 5
+puts 5 != 5
if and while statements take a conditional, and then a code block afterwards. See these examples:
x = 5 if x > 10 { @@ -91,7 +97,9 @@ while number < 10 {Functions
Note: Functions in Solstice are currently in beta. Type checking for functions is currently experimental, and arguments may not work as intended. Be warned!
-In Solstice, function definitions have a syntax like this:
+def functionName(type arg1, type arg2, type arg3) returnType {
// code goes here
}In Solstice, function definitions have a syntax like this:
def functionName(type arg1, type arg2, type arg3) returnType { + // code goes here +}Your types can be
int,double,string,bool, orchar(see the "Type System" section for more details)Return a value (which must be the same type as your
returnType) withreturn value.Here's an example function:
@@ -134,14 +142,20 @@ while number < 10 {Inline Ground is not vetted by the type checker. Be careful when modifying existing variables with inline ground! The type checker is not aware of any values created inside inline Ground.
If you would like the Solstice type checker to be aware of values created by Ground, initialise a variable with a blank of whatever type is made by Ground.
Variable names are the same inside inline Ground as they are in Solstice. Read Ground's syntax guide for an understanding on how it should work here.
-+ground {
set &x 5
println $x
}ground { + set &x 5 + println $x +}
Gets user input from the console until the next line. The msg is used as a prompt for the user. Returns inputted characters from the console.
-guess = input("What is the password? ")
if guess == "password123" {
puts "Good job!"
}
+ guess = input("What is the password? ")
+if guess == "password123" {
+ puts "Good job!"
+}