Skip to content

Commit 54300a7

Browse files
committed
Language Reference: Update syntax changes
1 parent 11a2808 commit 54300a7

6 files changed

Lines changed: 47 additions & 38 deletions

File tree

docs/language/03-language_reference/02-types/02-general.mdx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,14 @@ numerical values or create type encapsulation.
88

99
---
1010
## Booleans
11-
:::not-implemented
12-
:::
1311

1412
Booleans are types that can only represent the binary values `true` or `false`.
1513
These two values are extremely important to handle conditionals or hold simple
1614
states without messing the values.
1715

18-
| Alias | Size | Implementation |
19-
|-------|:---------------:|:----------------------:|
20-
| bool | 1-bit | [Std.Types.Boolean](#) |
16+
| Alias | Size |
17+
|-------|:---------------:|
18+
| bool | 1-bit |
2119

2220
```abs
2321
let bool cake = false
@@ -31,17 +29,15 @@ The cake is a lie!
3129

3230
---
3331
## Strings
34-
:::not-implemented
35-
:::
3632

3733
A string is a data structure that is able to store text data. A string can be
3834
used to store and reproduce text characters easily. \
3935
In Abstract, every string is encoded in UTF-8, with characters varying from 1-4
4036
bytes in length.
4137

42-
| Alias | Size | Implementation |
43-
|--------|:-----------------------------------------------:|:----------------------:|
44-
| string | variable (content is heap/statically-allocated) | [Std.Types.String](#) |
38+
| Alias | Size |
39+
|--------|:-----------------------------------------------:|
40+
| string | variable (content is heap/statically-allocated) |
4541

4642

4743
```abs

docs/language/03-language_reference/02-types/04-structures/01-packets.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ have full controll of the layout of all the bits stored on it.
1616
Packets can be implemented as structs, using the `@packed` attribute as following:
1717
```abs
1818
@packed(8) struct MyDinner {
19-
bool hasFork
20-
bool hasSpoon
21-
bool hasKnife
22-
bool hasPlate
23-
u4 hungerLevel
19+
@public let bool hasFork
20+
@public let bool hasSpoon
21+
@public let bool hasKnife
22+
@public let bool hasPlate
23+
@public let u4 hungerLevel
2424
}
2525
```
2626

docs/language/03-language_reference/02-types/04-structures/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ to know the type of the structure anywhere during runtime.
3838

3939
---
4040
### Constructors
41+
:::not-implemented
42+
:::
4143

4244
Sometimes, is usefull to have a single function to abstract complex initialization of data.
4345
for instance, take the following structure declaration example:

docs/language/03-language_reference/04-conditionals.mdx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
:::under-construction
44
:::
5-
:::not-implemented
6-
:::
75

86
Conditionals are a important aspect of a program, allowing it to do specific behaviors with specific inputs.
97

@@ -103,6 +101,8 @@ else {
103101

104102
---
105103
## Match
104+
:::not-implemented
105+
:::
106106

107107
A easier way to do collections of if - elif's
108108

@@ -139,8 +139,10 @@ let i32 by2 = match value {
139139

140140
---
141141
## Switch
142+
:::not-implemented
143+
:::
142144

143-
Most complex way of controll of code process \
145+
Most complex way of controll of process flow \
144146
switches manipulates groups of cases and conditions
145147

146148
Switches allows any condition evaluation \

docs/language/03-language_reference/05-loops.mdx

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,49 @@ until some condition is reached. Bellow are the loop types that abstract support
88

99
---
1010
## While loops
11-
:::not-implemented
12-
:::
1311

1412
While loops are the most basic loop types. It while it conditional is valid or
1513
the code reaches a breakpoint.
1614

17-
This is the structure of a while syntax:
15+
These are the possibilities for the while statement syntax:
1816
```abs
19-
while <condition> => <instruction>
17+
while <condition> do <instruction>
18+
while <condition> : <step> do <instruction>
19+
while <declaration> : <condition> : <step> do <instruction>
2020
```
21+
`declaration` - Context variables that will be accessible inside the loop
22+
`condition` - The boolean value that will be tested before each iteration. The loop will continue running while this is true
23+
`step` - A process to be executed after each loop iteration
24+
`instruction` - what the loop should do every iteration
2125

22-
While loops do not have iterators, so in this cse we must create our own:
23-
```abs
24-
let index = 10
25-
while index > 0 => {
26+
While loops are the most common way to do repetitive tasks in Abstract. it behave both like while and for loops in
27+
the majority of other languages.
28+
29+
```c title="In C"
30+
for (var i = 0; i < 5; i++) {
31+
puts("Hello, Scopped World!")
32+
}
33+
puts("Loop break")
34+
```
35+
```abs title="In Abstract"
36+
while let i = 0 : index < 5 : i++ do {
2637
Std.Console.log("Hello, Scopped World!")
27-
index -= 2
2838
}
29-
Std.Console.writeln(index)
39+
Std.Console.log("Loop break")
3040
```
3141
```text title="Console Output"
3242
Hello, Scopped World!
3343
Hello, Scopped World!
3444
Hello, Scopped World!
3545
Hello, Scopped World!
3646
Hello, Scopped World!
37-
0
47+
Loop break
3848
```
3949

40-
Using a `break` statement, it is possible to stop the loop before it has reached
41-
it condition:
50+
Using a `break` statement, it is possible to stop the loop before its condition fails:
4251
```abs
4352
let index = 10
44-
while index >= 0 => {
53+
while index >= 0 do {
4554
Std.Console.log("Hello, Scopped World!")
4655
index -= 2
4756
@@ -62,7 +71,7 @@ after each iteration:
6271
```abs
6372
# Parenthesis are optional, but helps to read!
6473
let index = 0
65-
while (index < 10) : (index++) => Std.Console.log("Hello, World!")
74+
while (index < 10) : (index++) do Std.Console.log("Hello, World!")
6675
```
6776

6877
---
@@ -76,14 +85,14 @@ while (index < 10) : (index++) => Std.Console.log("Hello, World!")
7685
from Std.Console import
7786
7887
# Looping from 0 to 49
79-
for i in ..50 => writeln(i)
88+
for i in ..50 do writeln(i)
8089
8190
# Looping from 0 to 50 in steps of 10
82-
for i in ..50:10 => writeln(i)
91+
for i in ..50:10 do writeln(i)
8392
8493
# Looping though each element of a array
8594
let []byte numbers = [22, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43]
86-
for v in numbers => {
95+
for v in numbers do {
8796
write("Example of a prime number:")
8897
writeln(v)
8998
}

src/theme/prism-aditional-langs/abs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Prism.languages.abs = {
44
greedy: true
55
},
66

7-
'keyword': /\b(import|from|func|struct|typedef|match|switch|case|enum|default|let|const|new|destroy|Flag|as|in|by|for|while|break|if|elif|else|and|or|try|catch|throw|return)\b/,
7+
'keyword': /\b(import|from|func|struct|typedef|match|switch|case|enum|default|let|const|new|destroy|Flag|as|in|by|for|while|do|break|if|elif|else|and|or|try|catch|throw|return)\b/,
88
'type': /(\!|\[\d*\]|\*|\?)*([iu](256|25[0-5]|2[0-4][0-9]|1?[0-9]{1,2}|ptr)|byte|f32|f64|float|double|string|char|bool|type|anytype|void|noreturn|fault)\b/,
99

1010
'fault': {
@@ -17,7 +17,7 @@ Prism.languages.abs = {
1717
'property': /@([a-zA-Z_][a-zA-Z0-9_]*)/,
1818
'function': /\b[a-zA-Z_][a-zA-Z0-9_]*(?=\()\b/,
1919

20-
'operator': /(\+\+|\*\*|\?\?|==|>=|<=|\!=|\+=|-=|\*=|\/=|%=|=>|\+|-|\*|\/|%|=|>|<|\.)/,
20+
'operator': /(\+\+|\*\*|\?\?|==|>=|<=|\!=|\+=|-=|\*=|\/=|%=|=>|\+|-|\*|\/|%|=|>|<|\.|\&)/,
2121
'punctuation': /(\[|\]|{|}|\(|\))/,
2222

2323
// values

0 commit comments

Comments
 (0)