]> git.proxmox.com Git - rustc.git/blob - src/doc/reference/src/identifiers.md
New upstream version 1.54.0+dfsg1
[rustc.git] / src / doc / reference / src / identifiers.md
1 # Identifiers
2
3 > **<sup>Lexer:<sup>**\
4 > IDENTIFIER_OR_KEYWORD :\
5 > &nbsp;&nbsp; &nbsp;&nbsp; XID_start XID_continue<sup>\*</sup>\
6 > &nbsp;&nbsp; | `_` XID_continue<sup>+</sup>
7 >
8 > RAW_IDENTIFIER : `r#` IDENTIFIER_OR_KEYWORD <sub>*Except `crate`, `self`, `super`, `Self`*</sub>
9 >
10 > NON_KEYWORD_IDENTIFIER : IDENTIFIER_OR_KEYWORD <sub>*Except a [strict] or [reserved] keyword*</sub>
11 >
12 > IDENTIFIER :\
13 > NON_KEYWORD_IDENTIFIER | RAW_IDENTIFIER
14
15 An identifier is any nonempty Unicode string of the following form:
16
17 Either
18
19 * The first character has property [`XID_start`].
20 * The remaining characters have property [`XID_continue`].
21
22 Or
23
24 * The first character is `_`.
25 * The identifier is more than one character. `_` alone is not an identifier.
26 * The remaining characters have property [`XID_continue`].
27
28 > **Note**: [`XID_start`] and [`XID_continue`] as character properties cover the
29 > character ranges used to form the more familiar C and Java language-family
30 > identifiers.
31
32 A raw identifier is like a normal identifier, but prefixed by `r#`. (Note that
33 the `r#` prefix is not included as part of the actual identifier.)
34 Unlike a normal identifier, a raw identifier may be any strict or reserved
35 keyword except the ones listed above for `RAW_IDENTIFIER`.
36
37 [strict]: keywords.md#strict-keywords
38 [reserved]: keywords.md#reserved-keywords
39 [`XID_start`]: http://unicode.org/cldr/utility/list-unicodeset.jsp?a=%5B%3AXID_Start%3A%5D&abb=on&g=&i=
40 [`XID_continue`]: http://unicode.org/cldr/utility/list-unicodeset.jsp?a=%5B%3AXID_Continue%3A%5D&abb=on&g=&i=