130 lines
8.5 KiB
HTML
130 lines
8.5 KiB
HTML
<!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>
|
|
<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>
|
|
<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>
|
|
<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>
|
|
<p>Math operations take two values on either side, and perform the operation. Order of operations is supported.</p>
|
|
<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 > 10 {
|
|
puts "x is bigger than 10"
|
|
}
|
|
if x < 10 {
|
|
puts "x is smaller than 10"
|
|
}
|
|
if x == 0 {
|
|
puts "x is 10"
|
|
}
|
|
|
|
number = 0
|
|
|
|
while number < 10 {
|
|
number = number + 1
|
|
puts number
|
|
}</<code></pre>
|
|
</code>
|
|
<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>
|
|
</div>
|
|
<div id="type_system">
|
|
<h2>Type System</h2>
|
|
<p>Solstice's type system is currently a work in progress, but what is so far implemented will be detailed.</p>
|
|
<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>
|
|
</div>
|
|
<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>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|