Document not found (404)
+This URL is invalid, sorry. Please use the navigation bar or search to continue.
+ +diff --git a/docs/.nojekyll b/docs/.nojekyll new file mode 100644 index 0000000..f173110 --- /dev/null +++ b/docs/.nojekyll @@ -0,0 +1 @@ +This file makes sure that Github Pages doesn't process mdBook's output. diff --git a/docs/404.html b/docs/404.html new file mode 100644 index 0000000..ae7b099 --- /dev/null +++ b/docs/404.html @@ -0,0 +1,225 @@ + + +
+ + +Press ← or → to navigate between chapters
+Press S or / to search in the book
+Press ? to show this help
+Press Esc to hide this help
+This URL is invalid, sorry. Please use the navigation bar or search to continue.
+ +Press ← or → to navigate between chapters
+Press S or / to search in the book
+Press ? to show this help
+Press Esc to hide this help
+Comments in Solstice can be done in 3 ways:
+// (Single-Line Comment)Use // to tell Solstice to ignore text until the end of the line.
This kind of comment should be used inside code to explain how parts of code work.
+/* */ (Multiline Comment)Use /* and */ to tell Solstice to ignore text in between the two markers.
This kind of comment should be used for explainations of how functions and structs work, placed above the definition.
+# (Shebang Comment)Use # to tell Solstice to ignore text until the end of the line.
This kind of comment should be used in a shebang (writing #!/usr/bin/env solstice at the top of your entry point source file), not in the middle.
#!/usr/bin/env solstice
+
+/*
+ This function does something.
+ Input:
+ funnyNumber: A funny number
+ Returns: Another funny number
+*/
+def doSomething(int funnyNumber) int {
+ // Tell the user the number is funny
+ puts "The number" funnyNumber "is very funny"
+
+ // Now give them another funny number
+ return 532
+}
+
+
+ Press ← or → to navigate between chapters
+Press S or / to search in the book
+Press ? to show this help
+Press Esc to hide this help
+An expression in Solstice is a combination of operators and values (whether literal or stored in a variable).;
+“Precedence” is a number which dictates the order of execution. The higher the precedence, the sooner an expression will be evaluated.
++: Adds two numbers on either side, or concatenates two strings
+-: Subtracts two numbers on either side
+*: Multiplies two numbers on either side
+/: Divides two numbers on either side
+==: Checks two values to determine if they are equal
+true if both provided values are exactly the same. false otherwise.!=: Checks two values to determine if they are not equal
+true if both provided values are not exactly the same. false otherwise.>: Checks two numbers to determine which is greater
+true if the number provided on the left is greater than the number provided on the right.false otherwise.<: Checks two numbers to determine which is lesser
+true if the number provided on the left is lesser than the number provided on the right.false otherwise.>=: Checks two numbers to determine which is greater, or whether both are equal
+true if the number provided on the left is greater than the number provided on the right, or if both numbers are equal.false otherwise.<=: Checks two numbers to determine which is lesser, or whether both are equal
+true if the number provided on the left is lesser than the number provided on the right, or if both numbers are equal.false otherwise.as: Converts between types.
+.: Accesses object fields
+(...): Evaluates an expression inside the brackets before outside expressions.
+...)(...): Calls the specified function.
+...)new: Creates a new object from a template.
+new keyword.int: 0double: 0.0string: ""char: '\0'bool: falsesizeof: Gets the size of something.
+int size fieldint size field of the object if provided an objectPress ← or → to navigate between chapters
+Press S or / to search in the book
+Press ? to show this help
+Press Esc to hide this help
+Define a named function with the following syntax:
+def functionName(args) type {
+ ...
+}
+
+where:
+functionName is the name of the function.
+functionName is already defined as a function or other value, it will only be overwritten if the type does not change.args is multiple comma-seperated pairs of:
+type is the type of value which the function will return... is the code inside the function (the function body).
+args.Example:
+def add(int a, int b) int {
+ return a + b
+}
+
+Define a lambda function with the following syntax:
+lambda(args) type {
+ ...
+}
+
+where:
+args is multiple comma-seperated pairs of:
+type is the type of value which the function will return... is the code inside the function (the function body).
+args.Example:
+add = lambda(int a, int b) int {
+ return a + b
+}
+
+Lambda functions are most useful when passed as arguments to other functions.
+ +Welcome to the Solstice docs! Feel free to read in whichever order you like, or come back when you feel like it. You can read these head to tail if you want to understand the whole of the language as well.
-See a mistake? Report it at this site's repository. -
Happy coding!
-Solstice is a high level programming language. It compiles to Ground's bytecode.
-solstice commandSolstice's compiler is invoked via the solstice command. It provides some options:
Note: For now, as we transition to the C-based compiler, Solstice does not support extra flags, and can only run and print code (printing with the -p flag)
--o or --output: Tells Solstice where to output a compiled file.-t or --type: Tells Solstice the type of file to output.
- This can either be "ground" or "program". "ground" outputs a .grnd program, and "program" outputs a compiled native executable. See here for details.Example usage:
-solstice fib.sols -o fib.grnd
- solstice fib.sols
- Solstice code consists of four main things: values, identifiers, operators, and code blocks.
-"Hello!", 32, or true. More on values and the Solstice type system later.+, =, or if. (if and while are operators in Solstice.){ and }.You can type // to insert a comment into your program. The rest of your line will be commented out.
-
The puts command in Solstice is used to print out a value. It is not a function, but a built in operator, similar to + or =.
Use it like this:
-puts "Hello, World!"
-puts 3.14
-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
- 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
- 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
- if and while statements take a conditional, and then a code block afterwards. See these examples:
x = 5
-if x > 10 {
- puts "x is bigger than 10"
-}
-if x < 10 {
- puts "x is smaller than 10"
-}
-if x == 10 {
- puts "x is 10"
-}
-
-number = 0
-
-while number < 10 {
- number = number + 1
- puts number
-}
-
- 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
-}
- Your types can be int, double, string, bool, or char (see the "Type System" section for more details)
Return a value (which must be the same type as your returnType) with return value.
Here's an example function:
-def add(int a, int b) int {
- return a + b
-}
- Function calling is done like in most other programming languages, with the syntax function(arg1, arg2, arg3).
Solstice allows you to write libraries in Solstice, or write wrappers for Ground libraries. Use the use keyword, followed by an identifier to import the library.
use io
-
-println("Hello!")
- You now know everything you need to know about Solstice to start programming! You can continue reading for more information.
-Solstice's type system is currently a work in progress, but what is so far implemented will be detailed.
-int: Signed 64 bit integerdouble: Double prescision floating point numberstring: Character arraychar: A single characterbool: Either true or falseThe type signature of a function looks like this:
-fun(argType, argType, argType) returnType
- The type signature of a template looks like this:
-template(fieldType fieldName, fieldType fieldName, fieldType fieldName)
- The type signature of an object looks like this:
-object(fieldType fieldName, fieldType fieldName, fieldType fieldName)
- Solstice statically checks types at compile time to ensure your data is used as intended. These are the details of the type checker.
-= are autoinferred and cannot be provided by the user. All variables must have a value.=, it's type must not mutate in any way.Note: Structs, templates, and objects in Solstice are currently in beta. A lot of work in the type checker has been done, but accessing fields is still an issue.
-In Solstice, you can create a struct to group various bits of data together. You can specify default values for each field with : or =.
struct Person {
- name: "John"
- age: 32
-}
- This struct generates a template named "Person" which can be used later to generate new objects.
-You can use the new operator to create new instances of templates.
max = new Person
- Since Solstice is built atop Ground, you can write Ground code inside Solstice code, usually to wrap a Ground function for the Solstice standard library.
-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
-}
- io libraryGets 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.
-use io
-
-guess = input("What is the password? ")
-if guess == "password123" {
- puts "Good job!"
-}
- Prints a string to the console.
-use io
-
-print("Hello, World!")
- Prints a string to the console. Appends a new line afterwards.
-use io
-
-println("Hello, World!")
- Ground has recently added a Ground->Native compiler which allows much faster execution of Ground programs.
-However, this is quite early in development, and only supports some features:
-To try the native compiler, use this command:
-solstice program.sols --output program --type native
- Solstice will create a temporary folder in your current directory which you can remove called ".(outputname)_solsbuild". In this folder is the assembly and object file generated by the compiler. If you think that there's a bug with Ground or Solstice, you can use these to find the issue.
-Press ← or → to navigate between chapters
+Press S or / to search in the book
+Press ? to show this help
+Press Esc to hide this help
Welcome to the Solstice docs! For now, the documentation is in the format of a specification, which instructs you on how Solstice should behave. In future, a tutorial (similar to the Rust book) will be written which shows you each part of the language, instead of declaring it like the spec.
+Docs generated by mdBook.
+ +tag - -document.addEventListener('DOMContentLoaded', function() { - highlightAllCode(); -}); - -function highlightAllCode() { - const codeElements = document.querySelectorAll('pre.code code'); - codeElements.forEach(element => { - // Get the text content (this automatically decodes HTML entities) - const code = element.textContent; - element.innerHTML = highlightSolstice(code); - }); -} - -function highlightSolstice(code) { - let result = ''; - let i = 0; - - // Tokenize the code - while (i < code.length) { - let matched = false; - - // Check for comments - if (code.substr(i, 2) === '//') { - let end = code.indexOf('\n', i); - if (end === -1) end = code.length; - result += `${escapeHtml(code.substring(i, end))}`; - i = end; - matched = true; - } - - // Check for strings - else if (code[i] === '"') { - let end = i + 1; - while (end < code.length && code[end] !== '"') { - if (code[end] === '\\') end++; // Skip escaped characters - end++; - } - end++; // Include closing quote - result += `${escapeHtml(code.substring(i, end))}`; - i = end; - matched = true; - } - - // Check for numbers - else if (/\d/.test(code[i])) { - let end = i; - while (end < code.length && /[\d.]/.test(code[end])) { - end++; - } - result += `${code.substring(i, end)}`; - i = end; - matched = true; - } - - // Check for keywords, types, built-ins, and identifiers - else if (/[a-zA-Z_]/.test(code[i])) { - let end = i; - while (end < code.length && /[a-zA-Z0-9_]/.test(code[end])) { - end++; - } - const word = code.substring(i, end); - - // Check what type of word it is - if (['def', 'if', 'while', 'return', 'ground', 'puts', 'def', 'struct', 'new', 'use'].includes(word)) { - result += `${word}`; - } else if (['input', 'print', 'println'].includes(word)) { - result += `${word}`; - } else if (['int', 'double', 'string', 'char', 'bool'].includes(word)) { - result += `${word}`; - } else if (['true', 'false'].includes(word)) { - result += `${word}`; - } else { - // Check if it's a function call (followed by '(') - let j = end; - while (j < code.length && /\s/.test(code[j])) j++; - if (code[j] === '(') { - result += `${word}`; - } else { - result += word; - } - } - i = end; - matched = true; - } - - // Check for operators - else if ('+-*/=!<>:'.includes(code[i])) { - let op = code[i]; - if (i + 1 < code.length && '='.includes(code[i + 1])) { - op += code[i + 1]; - i++; - } - result += `${escapeHtml(op)}`; - i++; - matched = true; - } - - // Everything else (whitespace, braces, etc.) - if (!matched) { - result += escapeHtml(code[i]); - i++; - } - } - - return result; -} - -function escapeHtml(text) { - return text - .replace(/&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"') - .replace(/'/g, '''); -} diff --git a/docs/index.css b/docs/index.css deleted file mode 100644 index 04376c7..0000000 --- a/docs/index.css +++ /dev/null @@ -1,119 +0,0 @@ -.twopane { - margin: 0; - padding: 0; - box-sizing: border-box; - display: flex; - align-items: flex-start; - gap: 5%; -} - -.box { - position: relative; -} - -.sidebar { - position: sticky; - top: 40px; - width: 250px; - padding: 20px; - background: #080511; - border-radius: 8px; - border: 1px solid #26146b; - color: white; -} - -.sidebar h3 { - margin-top: 0; - margin-bottom: 1rem; - font-size: 1.2rem; - color: #a594f9; -} - -.sidebar ul { - list-style: none; - padding: 0; - margin: 0; -} - -.sidebar li { - margin-bottom: 0.5rem; -} - -.sidebar a { - text-decoration: none; - color: #ccc; - display: block; - padding: 8px 12px; - border-radius: 6px; - transition: background-color 0.2s, color 0.2s; -} - -.sidebar a:hover { - background-color: #26146b; - color: white; -} - -.content { - flex: 1; -} - -@media (max-width: 768px) { - .twopane { - flex-direction: column; - } - - .sidebar { - width: 100%; - position: relative; - top: 0; - margin-bottom: 20px; - box-sizing: border-box; - } -} - -h2 { - font-size: 35px; -} - -h3 { - font-size: 25px; -} - -/* Syntax highlighting styles for Solstice */ -.comment { - color: #6c757d; - font-style: italic; -} - -.string { - color: #98c379; -} - -.number { - color: #d19a66; -} - -.keyword { - color: #c678dd; - font-weight: bold; -} - -.builtin { - color: #61afef; -} - -.type { - color: #e5c07b; -} - -.boolean { - color: #d19a66; -} - -.operator { - color: #56b6c2; -} - -.function { - color: #61afef; -} diff --git a/docs/index.html b/docs/index.html index f1b19ec..346512f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,225 +1,231 @@ - - + +
+ - -
- - - +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +