Skip to content

Commit 267cdd8

Browse files
authored
Merge pull request #253 from matthewjasper/identifier-and-keywords
Split identifiers from keywords or identifiers
2 parents ec079d3 + 08d1207 commit 267cdd8

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

src/identifiers.md

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
# Identifiers
22

33
> **<sup>Lexer:<sup>**
4-
> IDENTIFIER :
4+
> IDENTIFIER_OR_KEYWORD :
55
> &nbsp;&nbsp; &nbsp;&nbsp; [`a`-`z` `A`-`Z`]&nbsp;[`a`-`z` `A`-`Z` `0`-`9` `_`]<sup>\*</sup>
66
> &nbsp;&nbsp; | `_` [`a`-`z` `A`-`Z` `0`-`9` `_`]<sup>+</sup>
7+
>
8+
> IDENTIFIER :
9+
> IDENTIFIER_OR_KEYWORD <sub>*Except a [strict] or [reserved] keyword*</sub>
710
811
An identifier is any nonempty ASCII string of the following form:
912

1013
Either
1114

12-
* The first character is a letter
13-
* The remaining characters are alphanumeric or `_`
15+
* The first character is a letter.
16+
* The remaining characters are alphanumeric or `_`.
1417

1518
Or
1619

17-
* The first character is `_`
18-
* The identifier is more than one character, `_` alone is not an identifier
19-
* The remaining characters are alphanumeric or `_`
20+
* The first character is `_`.
21+
* The identifier is more than one character. `_` alone is not an identifier.
22+
* The remaining characters are alphanumeric or `_`.
23+
24+
[strict]: keywords.html#strict-keywords
25+
[reserved]: keywords.html#reserved-keywords

src/macros-by-example.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ syntax named by _designator_. Valid designators are:
2626
* `pat`: a [pattern]
2727
* `expr`: an [expression]
2828
* `ty`: a [type]
29-
* `ident`: an [identifier]
29+
* `ident`: an [identifier] or [keyword]
3030
* `path`: a [path]
3131
* `tt`: a token tree (a single [token] by matching `()`, `[]`, or `{}`)
3232
* `meta`: the contents of an [attribute]
@@ -38,6 +38,7 @@ syntax named by _designator_. Valid designators are:
3838
[expression]: expressions.html
3939
[type]: types.html
4040
[identifier]: identifiers.html
41+
[keyword]: keyword.html
4142
[path]: paths.html
4243
[token]: tokens.html
4344
[attribute]: attributes.html

src/tokens.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -486,10 +486,16 @@ The two values of the boolean type are written `true` and `false`.
486486
## Lifetimes and loop labels
487487

488488
> **<sup>Lexer</sup>**
489+
> LIFETIME_TOKEN
490+
> &nbsp;&nbsp; &nbsp;&nbsp; `'` [IDENTIFIER_OR_KEYWORD][identifier]
491+
> &nbsp;&nbsp; | `'_`
492+
>
489493
> LIFETIME_OR_LABEL:
490494
> &nbsp;&nbsp; &nbsp;&nbsp; `'` [IDENTIFIER][identifier]
491495
492-
Lifetime parameters and [loop labels] both use this syntax.
496+
Lifetime parameters and [loop labels] use LIFETIME_OR_LABEL tokens. Any
497+
LIFETIME_TOKEN will be accepted by the lexer, and for example, can be used in
498+
macros.
493499

494500
[loop labels]: expressions/loop-expr.html
495501

0 commit comments

Comments
 (0)