Skip to content

Commit bb6ed19

Browse files
committed
Added reference docs
1 parent a3a6ba1 commit bb6ed19

10 files changed

Lines changed: 249 additions & 2 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ package-lock.json
33
public
44
resources
55
.netlify
6-
.hugo_build.lock
6+
.hugo_build.lock
7+
package-lock.json

config/_default/menus/menus.en.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
[[main]]
5252
name = "Docs"
53-
url = "/docs/prologue/introduction/"
53+
url = "/docs/quick-start/introduction/"
5454
weight = 50
5555

5656
[[main]]

content/docs/reference/_index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
title : "Reference"
3+
description: ""
4+
lead: ""
5+
draft: false
6+
images: []
7+
weight: 150
8+
---
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: "Binary Operators"
3+
draft: false
4+
toc: true
5+
---
6+
7+
Binary operators operate two values to obtain a third one.
8+
9+
| Symbol | Name | Nodes | Code |
10+
| --- | --- | --- | --- |
11+
| | |
12+
| **Mathematic** | |
13+
| + | Add | | |
14+
| - | Subtract |
15+
| * | Multiply |
16+
| / | Divide |
17+
| % | Module |
18+
| | |
19+
| **Comparisons** | |
20+
| == | Equal |
21+
| != | Not Equal |
22+
| > | Greater |
23+
| < | Less |
24+
| >= ≥ | Greater or Equal |
25+
| <= ≤ | Less or Equal |
26+
| | |
27+
| **Logical** | |
28+
| && | and |
29+
| \|\| | or |
30+
| & | bitwise and |
31+
| \| | bitwise or |
32+
| ^ | exclusive or (xor) |

content/docs/reference/classes.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: "Classes"
3+
draft: false
4+
toc: true
5+
---
6+
7+
A class is a data type that contains [variables](../variables) and [functions](../functions).
8+
9+
A class’s [variables](../variables) and [functions](../functions) must have unique names inside the same class.
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
title: "Functions"
3+
draft: false
4+
toc: true
5+
---
6+
7+
## Arguments
8+
9+
Functions can have multiple input arguments.
10+
11+
Functions can also have multiple output arguments.
12+
13+
14+
## Definitions
15+
16+
<details>
17+
<summary>Nodes</summary>
18+
19+
</details>
20+
21+
<details>
22+
<summary>Code</summary>
23+
24+
```ruby
25+
FillZero(U32 color) {} # An argument value
26+
FillOne(U32 size, U32 color = 0) {} # Multiple argument values
27+
FillTwo() -> Bool {} # A return value
28+
FillThree() -> Bool, S32 { # Multiple return values
29+
return true, 2;
30+
}
31+
FillFour() -> Bool valid, S32 count { # Multiple named return values
32+
valid = true;
33+
count = 2; # All named values without a default must be assigned before return.
34+
}
35+
36+
FillFive(U32 color = 0) {} # Default argument values
37+
FillSix(U32 color) -> Bool=false {} # Default return values
38+
FillSeven() -> Bool=true, S32=undefined {} # Multiple return values with defaults
39+
FillEight() -> Bool valid=true, S32 count {} # Named returns with defaults
40+
```
41+
</details>
42+
43+
44+
## Calls
45+
46+
<details>
47+
<summary>Nodes</summary>
48+
49+
</details>
50+
51+
<details>
52+
<summary>Code</summary>
53+
54+
```ruby
55+
FillZero(); # Error, argument must be provided
56+
FillZero(0);
57+
FillOne(0); # color is set by default to 0
58+
FillOne(0, 0);
59+
FillOne(size = 1); # Set an argument by name
60+
FillOne(0, color = 1);
61+
FillOne(size = 1, 0); # ERROR: Named arguments must be at the end of the called function.
62+
FillOne(color = 0, size = 1); # Set multiple arguments by name
63+
64+
Bool result = FillTwo();
65+
[Bool result, S32 count] = FillThree(); # Define and assign returns
66+
67+
Bool result; S32 count;
68+
[result, count] = FillThree(); # Assigning a value to existing variables
69+
[result, count] = FillFour(); # Named return values are returned in order
70+
71+
[result, count] = FillThree(); # Named return values are returned in order
72+
```
73+
</details>
74+
75+
76+
## Member Functions
77+
78+
<details>
79+
<summary>Nodes</summary>
80+
81+
</details>
82+
83+
<details>
84+
<summary>Code</summary>
85+
86+
```ruby
87+
Type one;
88+
one.DoSomething();
89+
90+
Type* ptr = &one;
91+
ptr->DoSomething();
92+
```
93+
</details>
94+
95+
96+
## Properties
97+
98+
Functions can be marked with different properties to change their behavior.

content/docs/reference/modules.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
title: "Modules"
3+
draft: false
4+
toc: true
5+
---
6+
7+
A module is constituted by a folder that contains a module file (with *.rift* format).
8+
9+
Any type files (*.rf* format) inside this folder or its subfolders are considered part of that module and will be compiled together.
10+
11+
## Submodules
12+
If the subfolder of a module contains its own module file, this folder and all its files will be considered its own module.
13+
14+
## Exporting
15+
By default **functions, types, and variables of a module are exported** for other modules to use.
16+
17+
## Dependencies
18+
A module can have dependencies to other modules, granting it access to their code. Dependencies can be either Private or Public as it is explained later.
19+
20+
## Target types
21+
The target type defines if a module will be compiled into an executable, a static library, or a dynamic library.

content/docs/reference/statics.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: "Statics"
3+
draft: false
4+
toc: true
5+
---
6+
7+
An static type contains one or more static [functions](../functions), an static function being as function that can be called globally without being part of a class.
8+
9+
[Functions](../functions) must have unique names inside the same function library.

content/docs/reference/structs.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: "Structs"
3+
draft: false
4+
toc: true
5+
---
6+
7+
A struct is a data type that only contains [variables](../variables).
8+
9+
Structs don't have "constructors" but can be initialized with parameter values.
10+
11+
Structs are passed by copy by default.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
title: "Variables"
3+
draft: false
4+
toc: true
5+
---
6+
7+
A variable is a block of memory containing an struct, a class, a native type, pointers or function pointers.
8+
9+
## Initialization
10+
11+
Variables are always default-initialized unless marked as **undefined** which keeps the memory as it was before initialization (garbage memory).
12+
13+
<details>
14+
<summary>Nodes</summary>
15+
16+
</details>
17+
18+
<details>
19+
<summary>Code</summary>
20+
21+
```ruby
22+
struct Type
23+
{
24+
Bool alive;
25+
Bool running;
26+
}
27+
28+
void main()
29+
{
30+
Type one; // Default initialized
31+
Type two = undefined; // Not initialized (garbage)
32+
Type three(true); // 'alive' set to true
33+
Type four(running=true); // 'running' set to true
34+
35+
Type five = four; // Copy four into five
36+
Type six := four; // Move four into six
37+
Type* seven = &six; // Seven is pointer to four
38+
}
39+
```
40+
</details>
41+
42+
## Member Variables
43+
<details>
44+
<summary>Nodes</summary>
45+
46+
</details>
47+
48+
<details>
49+
<summary>Code</summary>
50+
51+
```ruby
52+
Type one;
53+
one.alive = true;
54+
55+
Type* ptr = &one;
56+
ptr->alive = false;
57+
```
58+
</details>

0 commit comments

Comments
 (0)