Skip to content

Commit 432ce2d

Browse files
committed
feat(reference): Introduction
1 parent c79eccb commit 432ce2d

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed

docs_config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ docs_groups:
7171
- stdlib/int64
7272
- stdlib/float32
7373
- stdlib/float64
74-
# Language Reference:
75-
# - reference/introduction
74+
Language Reference:
75+
- reference/introduction
7676
# - reference/lexical_structure:
7777
# - reference/lexical_structure/whitespace
7878
# - reference/lexical_structure/comments

src/reference/introduction.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
title: Introduction
3+
---
4+
5+
Hey there! This is a reference manual for the Grain programming language. It assumes that you have some general familiarity with the language—it's not meant to teach you how to use Grain or act as a tutorial. If you're looking to learn how to use the language, check out the [guide](/docs).
6+
7+
The reference manual attempts to explain concepts in a way that is approachable for the average reader. It tries to be as complete as possible, though it's difficult to capture every nuance of the language without being too formal. It doesn't dive deeply into the exact specifics of how language concepts are implemented as these are subject to change over time (and may vary between language implementations, though any implementation notes refer to `grainc`).
8+
9+
Information about the standard library is only included if it is relevant to the language itself—to find everything available, check out the full [standard library docs](/docs/stdlib/pervasives)!
10+
11+
## Syntax notation
12+
13+
Throughout the reference, we'll show the syntax of a construct using this notation:
14+
15+
```ebnf
16+
binary_operator =
17+
| "+"
18+
| "-"
19+
| "*"
20+
| "/"
21+
;
22+
23+
binary_operation = expression binary_operator expression ;
24+
25+
expression = ... ;
26+
```
27+
28+
This is a version of Extended Backus-Naur Form, and you can read more about it [here](https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form). In this example, a `binary_operator` is either a plus sign, hyphen, asterisk, or slash, and a `binary_operation` is two `expression`s separated by a `binary_operator`. Each rule is terminated by a semicolon.
29+
30+
### Alternatives
31+
32+
Each alternative in a rule (or subrule) is separated by a pipe (`|`). These alternatives represent a choice between one of the options listed. Subrules may be introduced using parentheses, e.g. `(foo | bar)`.
33+
34+
### Character classes
35+
36+
Alternatives between single characters are represented using brackets. For example, the class `['x' 'y']` represents a single character, `x` or `y`. A `-` is used to denote a range of characters, e.g. `['a'-'z' 'A'-'Z']` represents any capital or lowercase letter.
37+
38+
### Quantifiers
39+
40+
To represent a repeated number of something, we'll use a quantifier.
41+
42+
| quantifier | meaning | example |
43+
| ---------- | ------------ | -------- |
44+
| `?` | zero or one | `"foo"?` |
45+
| `*` | zero or more | `"foo"*` |
46+
| `+` | one or more | `"foo"+` |
47+
48+
### Tokens
49+
50+
Rules that appear in all caps, like `STRING`, are considered tokens. This section introduces a number of tokens that may be referred to throughout other sections of the language reference.

0 commit comments

Comments
 (0)