Files
sols.dev/docs/index.html

159 lines
11 KiB
HTML
Raw Normal View History

2025-12-23 23:39:55 +11:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Solstice Docs</title>
<link rel="stylesheet" href="https://sols.dev/index.css">
<link rel="stylesheet" href="index.css">
</head>
<body>
<div class="box">
<div class="twopane">
<div class="sidebar">
<h3>Navigation</h3>
<ul>
<li><strong><a href="#core_concepts">Core Concepts</a></strong></li>
2025-12-24 16:26:43 +11:00
<li><strong><a href="#type_system">Type System</a></strong></li>
<li><a href="#value_types">Value Types</a></li>
<li><a href="#type_checker">Type Checker</a></li>
2025-12-23 23:39:55 +11:00
<li><strong><a href="#builtins">Built In Functions</a></strong></li>
<li><a href="#input_string_msg__string">input(string msg) string</a></li>
</ul>
</div>
<div class="content">
<h1>Solstice Docs</h1>
<p>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.</p>
<p>See a mistake? Report it at <a href="https://chsp.au/max/sols.dev">this site's repository</a>.
<p>Happy coding!</p>
<div id="core_concepts">
<h2>Core Concepts</h2>
<p>Solstice is a high level programming language. It compiles to Ground's bytecode.</p>
<h3>The <code>solstice</code> command</h3>
<p>Solstice's compiler is invoked via the <code>solstice</code> command. It provides some options:</p>
<ul>
<li><code>-o</code> or <code>--output</code>: Tells Solstice where to output a compiled file.</li>
<li><code>-t</code> or <code>--type</code>: Tells Solstice the type of file to output.<br>At present, Solstice only supports Ground source files as an output type, but more types may be added in future.</li>
</ul>
<p>Example usage:</p>
<pre class="code"><code>solstice fib.sols -o fib.grnd</code></pre>
<pre class="code"><code>solstice fib.sols</code></pre>
<h3>Writing Solstice code</h3>
<p>Solstice code consists of four main things: values, identifiers, operators, and code blocks.</p>
<ul>
<li>Values: these are your literal values in your program, like <code>"Hello!"</code>, <code>32</code>, or <code>true</code>. More on values and the Solstice type system later.</li>
<li>Identifiers: these are names of variables. They normally hold something in them.</li>
<li>Operators: these make up the actual logic of your program. Operators are thing like <code>+</code>, <code>=</code>, or <code>if</code>. (if and while are operators in Solstice.)</li>
<li>Code blocks: this is the collection of values, identifiers, and operators, usually in between <code>{</code> and <code>}</code>.</li>
</ul>
2025-12-25 22:40:00 +11:00
<h3>Comments</h3>
<p>You can type <code>//</code> to insert a comment into your program. The rest of your line will be commented out.
2025-12-23 23:39:55 +11:00
<h3>puts</h3>
<p>The <code>puts</code> command in Solstice is used to print out a value. It is not a function, but a built in operator, similar to <code>+</code> or <code>=</code>.</p>
<p>Use it like this:</p>
<pre class="code"><code>puts "Hello, World!"
puts 3.14
puts true
puts "You can print out anything with puts!"</code></pre>
<h3>Variables</h3>
<p>Solstice variables are quite simple. Assign values with <code>=</code>, and read them with the variable name.</p>
<pre class="code"><code>x = 5<br>puts x</code></pre>
<p>Types are automatically inferred by Solstice.</p>
<h3>Maths</h3>
<p>You can use <code>+</code> (add), <code>-</code> (subtract), <code>*</code> (multiply), and <code>/</code> (divide) to do math.</p>
2025-12-24 22:04:03 +11:00
<p>Math operations take two values on either side, and perform the operation. Order of operations is supported.</p>
2025-12-23 23:39:55 +11:00
<pre class="code"><code>x = 5 + 3<br>y = 10<br>puts x + y</code></pre>
<h3>Control Flow and Equalities</h3>
<p>Solstice supports <code>if</code> and <code>while</code> statements, as well as the <code>==</code>, <code>!=</code>, <code>></code>, <code>>=</code>, <code><</code>, and <code><=</code> operations.</p>
<p>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.</p>
<pre class="code"><code>puts 5 == 5<br>puts 5 != 5</code></pre>
<p><code>if</code> and <code>while</code> statements take a conditional, and then a code block afterwards. See these examples:</p>
<pre class="code"><code>x = 5
if x &gt; 10 {
puts "x is bigger than 10"
}
if x &lt; 10 {
puts "x is smaller than 10"
}
2026-01-13 20:10:11 +11:00
if x == 10 {
2025-12-23 23:39:55 +11:00
puts "x is 10"
}
number = 0
while number &lt; 10 {
number = number + 1
puts number
}</<code></pre>
2025-12-28 14:12:47 +11:00
</code>
<h3>Functions</h3>
<p><strong>Note:</strong> Functions in Solstice are currently in beta. Type checking for functions is currently experimental, and arguments may not work as intended. Be warned!</p>
<p>In Solstice, function definitions have a syntax like this: <pre class="code"><code>def functionName(type arg1, type arg2, type arg3) returnType {<br> // code goes here<br>}</code></pre></p>
<p>Your types can be <code>int</code>, <code>double</code>, <code>string</code>, <code>bool</code>, or <code>char</code> (see the "Type System" section for more details)</p>
<p>Return a value (which must be the same type as your <code>returnType</code>) with <code>return value</code>.</p>
<p>Here's an example function:</p>
<pre class="code"><code>def add(int a, int b) int {
return a + b
}</code></pre>
<h3>Calling Functions</h3>
<p>Function calling is done like in most other programming languages, with the syntax <code>function(arg1, arg2, arg3)</code>.</p>
<h3>That's it!</h3>
<p>You now know everything you need to know about Solstice to start programming! You can continue reading for more information.</p>
2025-12-23 23:39:55 +11:00
</div>
2025-12-24 16:26:43 +11:00
<div id="type_system">
<h2>Type System</h2>
2025-12-23 23:39:55 +11:00
<p>Solstice's type system is currently a work in progress, but what is so far implemented will be detailed.</p>
2025-12-24 16:26:43 +11:00
<div id="value_types">
<h3>Value Types</h3>
<ul>
<li><code>int</code>: Signed 64 bit integer</li>
<li><code>double</code>: Double prescision floating point number</li>
<li><code>string</code>: Character array</li>
<li><code>char</code>: A single character</li>
<li><code>bool</code>: Either true or false</li>
</ul>
</div>
<div id="type_checker">
<h3>Type Checker</h3>
<p>Solstice statically checks types at compile time to ensure your data is used as intended. These are the details of the type checker.</p>
<ul>
<li>Types of variables when setting with <code>=</code> are autoinferred and cannot be provided by the user. All variables must have a value.</li>
<li>When setting a variable with <code>=</code>, it's type must not mutate in any way.</li>
<li>Functions must have types annotated. There is no "any" type.</li>
<li>When using operators, integers are able to promote to doubles where required. No other types can automatically convert.</li>
<li>All equality operators require the same type on both sides of the equality.</li>
</ul>
</div>
2025-12-23 23:39:55 +11:00
</div>
2026-01-18 14:28:21 +11:00
<div id="inline_ground">
<h2>Inline Ground</h2>
<p>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.</p>
<p>Inline Ground is not vetted by the type checker. <strong>Be careful when modifying existing variables with inline ground!</strong> The type checker is not aware of any values created inside inline Ground.</p>
<p>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.</p>
<p>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 <a href="https://chookspace.com/ground/cground/src/branch/master/docs/syntax.md">here</a>.</p>
<pre class="code"><code>ground {<br> set &x 5<br> println $x<br>}</code></pre>
</div>
2025-12-23 23:39:55 +11:00
<div id="builtins">
<h2>Built In Functions</h2>
<div id="input_string_msg__string">
<h3>input(string msg) string</h3>
<p>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.</p>
<pre class="code"><code>guess = input("What is the password? ")<br>if guess == "password123" {<br> puts "Good job!"<br>}</code></pre>
</div>
2026-01-18 14:28:21 +11:00
<div id="print_string_msg__string">
<h3>print(string msg) string</h3>
<p>Prints a string to the console.</p>
<pre class="code"><code>print("Hello, World!")</code></pre>
</div>
<div id="println_string_msg__string">
<h3>println(string msg) string</h3>
<p>Prints a string to the console. Appends a new line afterwards.</p>
<pre class="code"><code>println("Hello, World!")</code></pre>
</div>
2025-12-23 23:39:55 +11:00
</div>
</div>
</div>
</div>
</body>
</html>