File tree 3 files changed +21
-8
lines changed
3 files changed +21
-8
lines changed Original file line number Diff line number Diff line change 1
1
# Identifiers
2
2
3
3
> ** <sup >Lexer:<sup >**
4
- > IDENTIFIER :
4
+ > IDENTIFIER_OR_KEYWORD :
5
5
>   ;  ;   ;  ; [ ` a ` -` z ` ` A ` -` Z ` ]   ; [ ` a ` -` z ` ` A ` -` Z ` ` 0 ` -` 9 ` ` _ ` ] <sup >\* </sup >
6
6
>   ;  ; | ` _ ` [ ` a ` -` z ` ` A ` -` Z ` ` 0 ` -` 9 ` ` _ ` ] <sup >+</sup >
7
+ >
8
+ > IDENTIFIER :
9
+ > IDENTIFIER_OR_KEYWORD <sub >* Except a [ strict] or [ reserved] keyword* </sub >
7
10
8
11
An identifier is any nonempty ASCII string of the following form:
9
12
10
13
Either
11
14
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 ` _ ` .
14
17
15
18
Or
16
19
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
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ syntax named by _designator_. Valid designators are:
26
26
* ` pat ` : a [ pattern]
27
27
* ` expr ` : an [ expression]
28
28
* ` ty ` : a [ type]
29
- * ` ident ` : an [ identifier]
29
+ * ` ident ` : an [ identifier] or [ keyword ]
30
30
* ` path ` : a [ path]
31
31
* ` tt ` : a token tree (a single [ token] by matching ` () ` , ` [] ` , or ` {} ` )
32
32
* ` meta ` : the contents of an [ attribute]
@@ -38,6 +38,7 @@ syntax named by _designator_. Valid designators are:
38
38
[ expression ] : expressions.html
39
39
[ type ] : types.html
40
40
[ identifier ] : identifiers.html
41
+ [ keyword ] : keyword.html
41
42
[ path ] : paths.html
42
43
[ token ] : tokens.html
43
44
[ attribute ] : attributes.html
Original file line number Diff line number Diff line change @@ -486,10 +486,16 @@ The two values of the boolean type are written `true` and `false`.
486
486
## Lifetimes and loop labels
487
487
488
488
> ** <sup >Lexer</sup >**
489
+ > LIFETIME_TOKEN
490
+ >   ;  ;   ;  ; ` ' ` [ IDENTIFIER_OR_KEYWORD] [ identifier ]
491
+ >   ;  ; | ` '_ `
492
+ >
489
493
> LIFETIME_OR_LABEL:
490
494
>   ;  ;   ;  ; ` ' ` [ IDENTIFIER] [ identifier ]
491
495
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.
493
499
494
500
[ loop labels ] : expressions/loop-expr.html
495
501
You can’t perform that action at this time.
0 commit comments