Files
cppdraft_translate/cppdraft/lex/name.md
2025-10-25 03:02:53 +03:00

117 lines
5.6 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[lex.name]
# 5 Lexical conventions [[lex]](./#lex)
## 5.11 Identifiers [lex.name]
[identifier:](#nt:identifier "5.11Identifiers[lex.name]")
[*identifier-start*](#nt:identifier-start "5.11Identifiers[lex.name]")
[*identifier*](#nt:identifier "5.11Identifiers[lex.name]") [*identifier-continue*](#nt:identifier-continue "5.11Identifiers[lex.name]")
[identifier-start:](#nt:identifier-start "5.11Identifiers[lex.name]")
[*nondigit*](#nt:nondigit "5.11Identifiers[lex.name]")
an element of the translation character set with the Unicode property XID_Start
[identifier-continue:](#nt:identifier-continue "5.11Identifiers[lex.name]")
[*digit*](#nt:digit "5.11Identifiers[lex.name]")
[*nondigit*](#nt:nondigit "5.11Identifiers[lex.name]")
an element of the translation character set with the Unicode property XID_Continue
[nondigit:](#nt:nondigit "5.11Identifiers[lex.name]") one of
a b c d e f g h i j k l m
n o p q r s t u v w x y z
A B C D E F G H I J K L M
N O P Q R S T U V W X Y Z _
[digit:](#nt:digit "5.11Identifiers[lex.name]") one of
0 1 2 3 4 5 6 7 8 9
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L928)
[*Note [1](#note-1)*:
The character properties XID_Start and XID_Continue are described by UAX #44 of the Unicode Standard[.](#1.sentence-1)[13](#footnote-13 "On systems in which linkers cannot accept extended characters, an encoding of the universal-character-name can be used in forming valid external identifiers. For example, some otherwise unused character or sequence of characters can be used to encode the \u in a universal-character-name. Extended characters can produce a long external identifier, but C++ does not place a translation limit on significant characters for external identifiers.")
— *end note*]
The program is ill-formed
if an [*identifier*](#nt:identifier "5.11Identifiers[lex.name]") does not conform to
Normalization Form C as specified in the Unicode Standard[.](#1.sentence-2)
[*Note [2](#note-2)*:
Identifiers are case-sensitive[.](#1.sentence-3)
— *end note*]
[*Note [3](#note-3)*:
[[uaxid]](uaxid "Annex E(informative)Conformance with UAX #31") compares the requirements of UAX #31 of the Unicode Standard
with the C++ rules for identifiers[.](#1.sentence-4)
— *end note*]
[*Note [4](#note-4)*:
In translation phase 4,[*identifier*](#nt:identifier "5.11Identifiers[lex.name]") also includes
those [*preprocessing-token*](lex.pptoken#nt:preprocessing-token "5.5Preprocessing tokens[lex.pptoken]")*s* ([[lex.pptoken]](lex.pptoken "5.5Preprocessing tokens"))
differentiated as keywords ([[lex.key]](lex.key "5.12Keywords"))
in the later translation phase 7 ([[lex.token]](lex.token "5.10Tokens"))[.](#1.sentence-5)
— *end note*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L962)
The identifiers in Table [4](#tab:lex.name.special "Table 4: Identifiers with special meaning") have a special meaning when
appearing in a certain context[.](#2.sentence-1)
When referred to in the grammar, these identifiers
are used explicitly rather than using the [*identifier*](#nt:identifier "5.11Identifiers[lex.name]") grammar production[.](#2.sentence-2)
Unless otherwise specified, any ambiguity as to whether a given[*identifier*](#nt:identifier "5.11Identifiers[lex.name]") has a special meaning is resolved to interpret the
token as a regular [*identifier*](#nt:identifier "5.11Identifiers[lex.name]")[.](#2.sentence-3)
Table [4](#tab:lex.name.special) — Identifiers with special meaning [[tab:lex.name.special]](./tab:lex.name.special)
| [🔗](#tab:lex.name.special-row-1)<br>final | import | post | replaceable_if_eligible |
| --- | --- | --- | --- |
| [🔗](#tab:lex.name.special-row-2)<br>override | module | pre | trivially_relocatable_if_eligible |
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L988)
In addition, some identifiers
appearing as a [*token*](lex.token#nt:token "5.10Tokens[lex.token]") or [*preprocessing-token*](lex.pptoken#nt:preprocessing-token "5.5Preprocessing tokens[lex.pptoken]") are reserved for use by C++
implementations and shall
not be used otherwise; no diagnostic is required[.](#3.sentence-1)
- [(3.1)](#3.1)
Each identifier that contains a double underscore__or begins with an underscore followed by
an uppercase letter,
other than those specified in this document
(for example, __cplusplus ([[cpp.predefined]](cpp.predefined "15.12Predefined macro names"))),is reserved to the implementation for any use[.](#3.1.sentence-1)
- [(3.2)](#3.2)
Each identifier that begins with an underscore isreserved to the implementation for use as a name in the global namespace[.](#3.2.sentence-1)
[13)](#footnote-13)[13)](#footnoteref-13)
On systems in which linkers cannot accept extended
characters, an encoding of the [*universal-character-name*](lex.universal.char#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]") can be used in
forming valid external identifiers[.](#footnote-13.sentence-1)
For example, some otherwise unused
character or sequence of characters can be used to encode the\u in a [*universal-character-name*](lex.universal.char#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]")[.](#footnote-13.sentence-2)
Extended
characters can produce a long external identifier, but C++ does not
place a translation limit on significant characters for external
identifiers[.](#footnote-13.sentence-3)