Skip to content

Commit 0f61ee0

Browse files
authored
feat: port syntax guide + add some info (#125)
1 parent 08abb65 commit 0f61ee0

File tree

3 files changed

+86
-1
lines changed

3 files changed

+86
-1
lines changed

docs/.vitepress/config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,10 @@ export default {
10571057
{
10581058
text: 'String Sample',
10591059
link: '/developer-guides/string-sample'
1060+
},
1061+
{
1062+
text: 'Syntax Guide',
1063+
link: '/developer-guides/syntax-guide'
10601064
}
10611065
]
10621066
},

docs/developer-guides/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@
2525
- [Type Modules](plugins/01-type-modules)
2626
- [Libpeas](plugins/02-libpeas)
2727

28-
#### [String Sample](string-sample)
28+
#### [String Sample](string-sample)
29+
30+
#### [Syntax Guide](syntax-guide)
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Syntax Guide
2+
3+
Original Source: [Vala Syntax Guide](https://wiki.gnome.org/Projects/Vala/Syntax)
4+
5+
The syntax of Vala is similar to C#, modified to better fit the GObject type system. Vala supports modern language features as the following:
6+
7+
- OOP (classes, abstract classes, mixin interfaces, type polymorphism)
8+
- Namespaces
9+
- Delegates
10+
- Properties
11+
- Signals
12+
- Property change notifications
13+
- Foreach
14+
- Lambda expressions / Closures
15+
- Type inference for local variables
16+
- Generics
17+
- Non-null types
18+
- Assisted memory management (automatic reference counting)
19+
- Deterministic destructors (suitable for RAII)
20+
- Exception handling (checked exceptions)
21+
- Asynchronous methods (coroutines)
22+
- Preconditions and postconditions (contract programming)
23+
- Run-time type information
24+
- Named constructors
25+
- Verbatim strings and string templates
26+
- Array and string slicing
27+
- Conditional compilation
28+
- Dynamic and static D-Bus support
29+
- C# like syntax
30+
- C ABI compatibility
31+
- Experimental:
32+
- Chained relational expressions
33+
- Regular expression literals
34+
- Main blocks
35+
36+
## Keywords
37+
38+
- Selection: `if, else, switch, case, default`
39+
- Iteration: `do, while, for, foreach, in`
40+
- Jumping: `break, continue, return`
41+
- Exception Handling: `try, catch, finally, throw`
42+
- Synchronization: `lock, unlock`
43+
- Type Declaration: `class, interface, struct, enum, delegate, errordomain`
44+
- Type Modifiers: `const, weak, unowned, dynamic`
45+
- Modifiers: `abstract, virtual, override, signal, extern, static, async, inline, new, sealed, partial`
46+
- Access Modifiers: `public, private, protected, internal`
47+
- Method Parameters: `out, ref`
48+
- Method Contract Keywords: `throws, requires, ensures`
49+
- Namespaces: `namespace, using`
50+
- Operator Keywords: `as, is, in, new, delete, sizeof, typeof`
51+
- Access Keywords: `this, base`
52+
- Literal Keywords: `null, true, false`
53+
- Property Context: `get, set, construct, default, value`
54+
- Construction Blocks: `construct, static construct, class construct`
55+
- Other: `void, var, yield, global, owned, with`
56+
57+
## Operators
58+
59+
- Arithmetic: `+`, `-`, `*`, `/`, `%`
60+
- Bitwise: `~`, `&`, `|`, `^`, `<<`, `>>`
61+
- Relational: `<`, `>`, `<=`, `>=`
62+
- Equality: `==`, `!=`
63+
- Logic: `!`, `&&`, `||`
64+
- Assignment: `=`, `+=`, `-=`, `*=` , `/=`, `%=`, `&=`, `|=`, `^=`, `<<=`, `>>=`
65+
- Increment, Decrement: `++`, `--`
66+
- Pointer: `&`, `*`, `->`, `delete`
67+
- Conditional: `?:`
68+
- Null-Coalescing: `??`
69+
- String Concatenation: `+`
70+
- Method Invocation: `()`
71+
- Member Access: `.`
72+
- Index: `[]`
73+
- Slice: `[:]`
74+
- Lambda: `=>`
75+
- Casting: `(`_Type_`)`, `(!)`, `as`
76+
- Type Checking: `is`
77+
- Ownership Transfer: `(owned)`
78+
- Namespace Alias Qualifier: `::` (currently only with `global`)
79+
- Other: `new`, `sizeof`, `typeof`, `in`

0 commit comments

Comments
 (0)