-
Notifications
You must be signed in to change notification settings - Fork 2
Primitives
Nikitin Ilya edited this page Apr 29, 2020
·
2 revisions
| Number literal | Example |
|---|---|
| Int |
42, -28
|
| Big int | 987654321L |
| Unsigned 8-bit int | 321::u8 |
| Complex (real=0, imag=15j) | 15j |
| 64 bit float |
42.0, 6e10
|
| 32 bit float | 8.22::f32 |
| String literal | Example |
|---|---|
| Simple |
"Hello!", 'Hello!'
|
| Multiline |
"""Hello!""", '''Hello!'''
|
| Formatted |
f"interpolated {value}", f'{value1}, {value2}'
|
| With special characters |
"special: \a\b\f\r\n\0", '\t\t\t'
|
| Raw |
r"raw symbols: \a\f\r\n\0", r'\r\n'
|
| Primitive | Example |
|---|---|
| Boolean |
true, false
|
| Strings |
"Hello, World!", 'Hello, World!'
|
| Characters |
`a`, `\n`, `あ`
|
| Addition | 31 + 44.3 |
| Division/Multiplication | 3.1416 / 23 * 36.6 |
| Exponentiation |
33.2 ** 2, 2 ** 8.5
|
| Ranges |
1..10, 1...5
|
| String concatenation | "Hello " + 'World' |
| Comparison |
>, <, >=, <=
|
| Boolean operations |
not, and, or
|
| Reference, Structural (deep) equality |
==, ===
|
| Indexers |
seq1[1], seq2[1..5], map1["key"]
|
| Comments |
### Multiline ###, # One line
|
| Collection type | Initializer syntax (type declaration is optional) |
|---|---|
| Tuple | x: (int, int) = (1, 2) |
| Array | x: int[5] = array(1, 2, 3, 4, 5) |
| Matrix | x: int[3, 2] = array((1, 2), (3, 4), (5, 6)) |
| Macro-based | |
| List | x: List[int] = [1, 2, 3, 4, 5] |
| Set | x: Set[int] = { "Text1", "Hello, world!", "Other string" } |
| Map | x: Map[int, str] = { 1: "Text1", 2: "Hello, world!", 55: "Other string" } |
Expressions
Public compiler interface
-
Units & Modules- TODO -
Compilerclass
Backend
- Lexer (Tokenizer)
- Syntax tree
- Traversing