aboutsummaryrefslogtreecommitdiff
path: root/docs/SYNTAX.md
diff options
context:
space:
mode:
authorJJ2024-01-28 09:05:03 +0000
committerJJ2024-01-28 09:07:00 +0000
commitba8ce3875d09b88463da76148ba5d563049b089f (patch)
tree73868472e6ba7a948fadf49e12362c500cef1843 /docs/SYNTAX.md
parent6da57c3a2c5c222591b0994acce79183b81d7f99 (diff)
docs: complete MODULES.md. minor updates elsewhere. prepare for hosting
Diffstat (limited to 'docs/SYNTAX.md')
-rw-r--r--docs/SYNTAX.md47
1 files changed, 41 insertions, 6 deletions
diff --git a/docs/SYNTAX.md b/docs/SYNTAX.md
index a1c8bfb..1bd3331 100644
--- a/docs/SYNTAX.md
+++ b/docs/SYNTAX.md
@@ -1,5 +1,7 @@
# Syntax: A Casual and Formal Look
+> ! This section is **incomplete**. Proceed with caution.
+
## Reserved Keywords
The following keywords are reserved:
@@ -15,13 +17,46 @@ The following keywords are reserved:
- types: `type` `distinct` `ref`
- types: `struct` `tuple` `union` `enum` `interface`
- reserved:
- - `impl` `object` `class` `concept` `auto` `empty` `effect` `case` `nil`
+ - `impl` `object` `class` `concept` `auto` `empty` `effect` `case`
- `suspend` `resume` `spawn` `pool` `thread` `closure`
- `cyclic` `acyclic` `sink` `move` `destroy` `copy` `trace` `deepcopy`
+The following identifiers are in use by the standard prelude:
+- logic: `not` `and` `or` `xor` `shl` `shr` `div` `mod` `rem`
+- logic: `+` `-` `*` `/` `<` `>` `<=` `>=` `==` `!=` `is`
+- async: `async` `await`
+- types: `int` `uint` `float`
+ - `i8` `i16` `i32` `i64` `i128`
+ - `u8` `u16` `u32` `u64` `u128`
+ - `f32` `f64` `f128`
+ - `dec64` `dec128`
+- types: `bool` `byte` `char` `str`
+- types: `void` `never`
+- strings: `&` (string append)
+
+The following punctuation is taken:
+- `=` (assignment)
+- `.` (chaining)
+- `,` (params)
+- `;` (statements)
+- `:` (types)
+- `#` (comment)
+- `_` (unused bindings)
+- `|` (generics)
+- `\` (string/char escaping)
+- `()` (params, tuples)
+- `{}` (scope, structs)
+- `[]` (generics, lists)
+- `""` (strings)
+- `''` (chars)
+- ``` `` ``` (unquoting)
+- unused: `~` `@` `$` `%`
+
## A Formal Grammar
-We now shall take a look at a more formal description of Puck's syntax. Syntax rules are described in [extended Backus–Naur form](https://en.wikipedia.org/wiki/Extended_Backus–Naur_form) (EBNF): however, most rules surrounding whitespace, and scope, and line breaks, are modified to how they would appear after a lexing step.
+We now shall take a look at a more formal description of Puck's syntax.
+
+Syntax rules are described in [extended Backus–Naur form](https://en.wikipedia.org/wiki/Extended_Backus–Naur_form) (EBNF): however, most rules surrounding whitespace, and scope, and line breaks, are modified to how they would appear after a lexing step.
### Identifiers
```
@@ -144,7 +179,7 @@ Body ::= Expr | ('{' Expr (';' Expr)* '}')
---
References:
-- https://www.joshwcomeau.com/javascript/statements-vs-expressions/
-- https://pgrandinetti.github.io/compilers/
-- https://docs.swift.org/swift-book/ReferenceManual/LexicalStructure.html
-- https://nim-lang.github.io/Nim/manual.html
+- [Statements vs. Expressions](https://www.joshwcomeau.com/javascript/statements-vs-expressions/)
+- [Swift's Lexical Structure](https://docs.swift.org/swift-book/ReferenceManual/LexicalStructure.html)
+- [The Nim Programming Language](https://nim-lang.github.io/Nim/manual.html)
+- [Pietro's Notes on Compilers](https://pgrandinetti.github.io/compilers/)