Skip to content

Commit 94b7788

Browse files
committed
feat(reference): Lexical Structure—Identifiers
1 parent 481e3a2 commit 94b7788

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

docs_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ docs_groups:
9898
- reference/lexical_structure/whitespace
9999
- reference/lexical_structure/comments
100100
- reference/lexical_structure/keywords
101-
# - reference/lexical_structure/identifiers
101+
- reference/lexical_structure/identifiers
102102
# - reference/lexical_structure/literals
103103
# - reference/lexical_structure/operators
104104
# - reference/lexical_structure/delimiters
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
title: Identifiers
3+
---
4+
5+
There are two kinds of identifiers in Grain—those that begin with an uppercase letter, and those that do not.
6+
7+
## Uppercase identifiers
8+
9+
Identifers that start with an uppercase letter are used for the names of modules and concrete types. We call these tokens `UIDENT`s (**U**ppercase **Ident**ifiers).
10+
11+
```ebnf
12+
UIDENT = ['A'-'Z']['A'-'Z' 'a-z' '0'-'9' '_']* ;
13+
```
14+
15+
A `UIDENT` starts with an uppercase letter A through Z, followed by any number of:
16+
17+
- Uppercase letters A through Z
18+
- Lowercase letters a through z
19+
- Digits 0 through 9
20+
- Underscores
21+
22+
## Lowercase identifiers
23+
24+
Identifers that don't start with an uppercase letter are used for the names of new bindings, record fields, type variables, and more. We call these tokens `LIDENT`s (**L**owercase **Ident**ifiers) though it should be noted that `LIDENT`s may also start with underscores.
25+
26+
```ebnf
27+
LIDENT = ['a-z' '_']['A'-'Z' 'a-z' '0'-'9' '_']* ;
28+
```
29+
30+
An `LIDENT` starts with an underscore or a lowercase letter a through z, followed by any number of:
31+
32+
- Uppercase letters A through Z
33+
- Lowercase letters a through z
34+
- Digits 0 through 9
35+
- Underscores

0 commit comments

Comments
 (0)