This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

19
cppdraft/lex/bool.md Normal file
View File

@@ -0,0 +1,19 @@
[lex.bool]
# 5 Lexical conventions [[lex]](./#lex)
## 5.13 Literals [[lex.literal]](lex.literal#lex.bool)
### 5.13.7 Boolean literals [lex.bool]
[boolean-literal:](#nt:boolean-literal "5.13.7Boolean literals[lex.bool]")
false
true
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2138)
The Boolean literals are the keywords false and true[.](#1.sentence-1)
Such literals have type bool[.](#1.sentence-2)

186
cppdraft/lex/ccon.md Normal file
View File

@@ -0,0 +1,186 @@
[lex.ccon]
# 5 Lexical conventions [[lex]](./#lex)
## 5.13 Literals [[lex.literal]](lex.literal#lex.ccon)
### 5.13.3 Character literals [lex.ccon]
[character-literal:](#nt:character-literal "5.13.3Character literals[lex.ccon]")
[*encoding-prefix*](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]")opt ' [*c-char-sequence*](#nt:c-char-sequence "5.13.3Character literals[lex.ccon]") '
[encoding-prefix:](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]") one of
u8 u U L
[c-char-sequence:](#nt:c-char-sequence "5.13.3Character literals[lex.ccon]")
[*c-char*](#nt:c-char "5.13.3Character literals[lex.ccon]") [*c-char-sequence*](#nt:c-char-sequence "5.13.3Character literals[lex.ccon]")opt
[c-char:](#nt:c-char "5.13.3Character literals[lex.ccon]")
[*basic-c-char*](#nt:basic-c-char "5.13.3Character literals[lex.ccon]")
[*escape-sequence*](#nt:escape-sequence "5.13.3Character literals[lex.ccon]")
[*universal-character-name*](lex.universal.char#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]")
[basic-c-char:](#nt:basic-c-char "5.13.3Character literals[lex.ccon]")
any member of the translation character set except the U+0027 apostrophe,
U+005c reverse solidus, or new-line character
[escape-sequence:](#nt:escape-sequence "5.13.3Character literals[lex.ccon]")
[*simple-escape-sequence*](#nt:simple-escape-sequence "5.13.3Character literals[lex.ccon]")
[*numeric-escape-sequence*](#nt:numeric-escape-sequence "5.13.3Character literals[lex.ccon]")
[*conditional-escape-sequence*](#nt:conditional-escape-sequence "5.13.3Character literals[lex.ccon]")
[simple-escape-sequence:](#nt:simple-escape-sequence "5.13.3Character literals[lex.ccon]")
\ [*simple-escape-sequence-char*](#nt:simple-escape-sequence-char "5.13.3Character literals[lex.ccon]")
[simple-escape-sequence-char:](#nt:simple-escape-sequence-char "5.13.3Character literals[lex.ccon]") one of
' " ? \ a b f n r t v
[numeric-escape-sequence:](#nt:numeric-escape-sequence "5.13.3Character literals[lex.ccon]")
[*octal-escape-sequence*](#nt:octal-escape-sequence "5.13.3Character literals[lex.ccon]")
[*hexadecimal-escape-sequence*](#nt:hexadecimal-escape-sequence "5.13.3Character literals[lex.ccon]")
[simple-octal-digit-sequence:](#nt:simple-octal-digit-sequence "5.13.3Character literals[lex.ccon]")
[*octal-digit*](lex.icon#nt:octal-digit "5.13.2Integer literals[lex.icon]") [*simple-octal-digit-sequence*](#nt:simple-octal-digit-sequence "5.13.3Character literals[lex.ccon]")opt
[octal-escape-sequence:](#nt:octal-escape-sequence "5.13.3Character literals[lex.ccon]")
\ [*octal-digit*](lex.icon#nt:octal-digit "5.13.2Integer literals[lex.icon]")
\ [*octal-digit*](lex.icon#nt:octal-digit "5.13.2Integer literals[lex.icon]") [*octal-digit*](lex.icon#nt:octal-digit "5.13.2Integer literals[lex.icon]")
\ [*octal-digit*](lex.icon#nt:octal-digit "5.13.2Integer literals[lex.icon]") [*octal-digit*](lex.icon#nt:octal-digit "5.13.2Integer literals[lex.icon]") [*octal-digit*](lex.icon#nt:octal-digit "5.13.2Integer literals[lex.icon]")
\o{ [*simple-octal-digit-sequence*](#nt:simple-octal-digit-sequence "5.13.3Character literals[lex.ccon]") }
[hexadecimal-escape-sequence:](#nt:hexadecimal-escape-sequence "5.13.3Character literals[lex.ccon]")
\x [*simple-hexadecimal-digit-sequence*](lex.universal.char#nt:simple-hexadecimal-digit-sequence "5.3.2Universal character names[lex.universal.char]")
\x{ [*simple-hexadecimal-digit-sequence*](lex.universal.char#nt:simple-hexadecimal-digit-sequence "5.3.2Universal character names[lex.universal.char]") }
[conditional-escape-sequence:](#nt:conditional-escape-sequence "5.13.3Character literals[lex.ccon]")
\ [*conditional-escape-sequence-char*](#nt:conditional-escape-sequence-char "5.13.3Character literals[lex.ccon]")
[conditional-escape-sequence-char:](#nt:conditional-escape-sequence-char "5.13.3Character literals[lex.ccon]")
any member of the basic character set that is not an [*octal-digit*](lex.icon#nt:octal-digit "5.13.2Integer literals[lex.icon]"), a [*simple-escape-sequence-char*](#nt:simple-escape-sequence-char "5.13.3Character literals[lex.ccon]"), or the characters N, o, u, U, or x
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1505)
A [*multicharacter literal*](#def:literal,multicharacter "5.13.3Character literals[lex.ccon]") is a [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]") whose [*c-char-sequence*](#nt:c-char-sequence "5.13.3Character literals[lex.ccon]") consists of
more than one [*c-char*](#nt:c-char "5.13.3Character literals[lex.ccon]")[.](#1.sentence-1)
A multicharacter literal shall not have an [*encoding-prefix*](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]")[.](#1.sentence-2)
If a multicharacter literal contains a [*c-char*](#nt:c-char "5.13.3Character literals[lex.ccon]") that is not encodable as a single code unit in the ordinary literal encoding,
the program is ill-formed[.](#1.sentence-3)
Multicharacter literals are conditionally-supported[.](#1.sentence-4)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1525)
The kind of a [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]"),
its type, and its associated character encoding ([[lex.charset]](lex.charset "5.3.1Character sets"))
are determined by
its [*encoding-prefix*](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]") and its [*c-char-sequence*](#nt:c-char-sequence "5.13.3Character literals[lex.ccon]") as defined by Table [9](#tab:lex.ccon.literal "Table 9: Character literals")[.](#2.sentence-1)
Table [9](#tab:lex.ccon.literal) — Character literals [[tab:lex.ccon.literal]](./tab:lex.ccon.literal)
| [🔗](#tab:lex.ccon.literal-row-1)<br>**Encoding** | **Kind** | **Type** | **Associated char-** | **Example** |
| --- | --- | --- | --- | --- |
| [🔗](#tab:lex.ccon.literal-row-2)<br>**prefix** | | | **acter encoding** | |
| [🔗](#tab:lex.ccon.literal-row-3)<br>none | [*ordinary character literal*](#def:literal,character,ordinary "5.13.3Character literals[lex.ccon]") | char | ordinary literal | 'v' |
| [🔗](#tab:lex.ccon.literal-row-4)<br> | multicharacter literal | int | encoding | 'abcd' |
| [🔗](#tab:lex.ccon.literal-row-5)<br>L | [*wide character literal*](#def:literal,character,wide "5.13.3Character literals[lex.ccon]") | wchar_t | wide literal | L'w' |
| [🔗](#tab:lex.ccon.literal-row-6) | | | encoding | |
| [🔗](#tab:lex.ccon.literal-row-7)<br>u8 | [*UTF-8 character literal*](#def:literal,character,UTF-8 "5.13.3Character literals[lex.ccon]") | char8_t | UTF-8 | u8'x' |
| [🔗](#tab:lex.ccon.literal-row-8)<br>u | [*UTF-16 character literal*](#def:literal,character,UTF-16 "5.13.3Character literals[lex.ccon]") | char16_t | UTF-16 | u'y' |
| [🔗](#tab:lex.ccon.literal-row-9)<br>U | [*UTF-32 character literal*](#def:literal,character,UTF-32 "5.13.3Character literals[lex.ccon]") | char32_t | UTF-32 | U'z' |
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1571)
In translation phase 4,
the value of a [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]") is determined
using the range of representable values
of the [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]")'s type in translation phase 7[.](#3.sentence-1)
A multicharacter literal has animplementation-defined
value[.](#3.sentence-2)
The value of any other kind of [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]") is determined as follows:
- [(3.1)](#3.1)
A [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]") with
a [*c-char-sequence*](#nt:c-char-sequence "5.13.3Character literals[lex.ccon]") consisting of a single[*basic-c-char*](#nt:basic-c-char "5.13.3Character literals[lex.ccon]"),[*simple-escape-sequence*](#nt:simple-escape-sequence "5.13.3Character literals[lex.ccon]"), or[*universal-character-name*](lex.universal.char#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]") is the code unit value of the specified character
as encoded in the literal's associated character encoding[.](#3.1.sentence-1)
If the specified character lacks
representation in the literal's associated character encoding or
if it cannot be encoded as a single code unit,
then the program is ill-formed[.](#3.1.sentence-2)
- [(3.2)](#3.2)
A [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]") with
a [*c-char-sequence*](#nt:c-char-sequence "5.13.3Character literals[lex.ccon]") consisting of
a single [*numeric-escape-sequence*](#nt:numeric-escape-sequence "5.13.3Character literals[lex.ccon]") has a value as follows:
* [(3.2.1)](#3.2.1)
Let v be the integer value represented by
the octal number comprising
the sequence of [*octal-digit*](lex.icon#nt:octal-digit "5.13.2Integer literals[lex.icon]")*s* in
an [*octal-escape-sequence*](#nt:octal-escape-sequence "5.13.3Character literals[lex.ccon]") or by
the hexadecimal number comprising
the sequence of [*hexadecimal-digit*](lex.icon#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]")*s* in
a [*hexadecimal-escape-sequence*](#nt:hexadecimal-escape-sequence "5.13.3Character literals[lex.ccon]")[.](#3.2.1.sentence-1)
* [(3.2.2)](#3.2.2)
If v does not exceed
the range of representable values of the [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]")'s type,
then the value is v[.](#3.2.2.sentence-1)
* [(3.2.3)](#3.2.3)
Otherwise,
if the [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]")'s [*encoding-prefix*](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]") is absent or L, andv does not exceed the range of representable values of the corresponding unsigned type for the underlying type of the [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]")'s type,
then the value is the unique value of the [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]")'s type T that is congruent to v modulo 2N, where N is the width of T[.](#3.2.3.sentence-1)
* [(3.2.4)](#3.2.4)
Otherwise, the program is ill-formed[.](#3.2.4.sentence-1)
- [(3.3)](#3.3)
A [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]") with
a [*c-char-sequence*](#nt:c-char-sequence "5.13.3Character literals[lex.ccon]") consisting of
a single [*conditional-escape-sequence*](#nt:conditional-escape-sequence "5.13.3Character literals[lex.ccon]") is conditionally-supported and
has an implementation-defined value[.](#3.3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1629)
The character specified by a [*simple-escape-sequence*](#nt:simple-escape-sequence "5.13.3Character literals[lex.ccon]") is specified in Table [10](#tab:lex.ccon.esc "Table 10: Simple escape sequences")[.](#4.sentence-1)
[*Note [1](#note-1)*:
Using an escape sequence for a question mark
is supported for compatibility with C++ 2014 and C[.](#4.sentence-2)
— *end note*]
Table [10](#tab:lex.ccon.esc) — Simple escape sequences [[tab:lex.ccon.esc]](./tab:lex.ccon.esc)
| [🔗](#tab:lex.ccon.esc-row-1)<br>**character** | | **[*simple-escape-sequence*](#nt:simple-escape-sequence "5.13.3Character literals[lex.ccon]")** |
| --- | --- | --- |
| [🔗](#tab:lex.ccon.esc-row-2)<br>U+000a | line feed | \n |
| [🔗](#tab:lex.ccon.esc-row-3)<br>U+0009 | character tabulation | \t |
| [🔗](#tab:lex.ccon.esc-row-4)<br>U+000b | line tabulation | \v |
| [🔗](#tab:lex.ccon.esc-row-5)<br>U+0008 | backspace | \b |
| [🔗](#tab:lex.ccon.esc-row-6)<br>U+000d | carriage return | \r |
| [🔗](#tab:lex.ccon.esc-row-7)<br>U+000c | form feed | \f |
| [🔗](#tab:lex.ccon.esc-row-8)<br>U+0007 | alert | \a |
| [🔗](#tab:lex.ccon.esc-row-9)<br>U+005c | reverse solidus | \\ |
| [🔗](#tab:lex.ccon.esc-row-10)<br>U+003f | question mark | \? |
| [🔗](#tab:lex.ccon.esc-row-11)<br>U+0027 | apostrophe | \' |
| [🔗](#tab:lex.ccon.esc-row-12)<br>U+0022 | quotation mark | \" |

240
cppdraft/lex/char.md Normal file
View File

@@ -0,0 +1,240 @@
[lex.char]
# 5 Lexical conventions [[lex]](./#lex)
## 5.3 Characters [lex.char]
### [5.3.1](#lex.charset) Character sets [[lex.charset]](lex.charset)
[1](#lex.charset-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L298)
The [*translation character set*](#def:character_set,translation "5.3.1Character sets[lex.charset]") consists of the following elements:
- [(1.1)](#lex.charset-1.1)
each abstract character assigned a code point in the Unicode codespace
as specified in the Unicode Standard, and
- [(1.2)](#lex.charset-1.2)
a distinct character for each Unicode scalar value
not assigned to an abstract character[.](#lex.charset-1.sentence-1)
[*Note [1](#lex.charset-note-1)*:
Unicode code points are integers
in the range [0, 10FFFF] (hexadecimal)[.](#lex.charset-1.sentence-2)
A surrogate code point is a value
in the range [D800, DFFF] (hexadecimal)[.](#lex.charset-1.sentence-3)
A Unicode scalar value is any code point that is not a surrogate code point[.](#lex.charset-1.sentence-4)
— *end note*]
[2](#lex.charset-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L317)
The [*basic character set*](#def:character_set,basic "5.3.1Character sets[lex.charset]") is a subset of the translation character set,
consisting of 99 characters as specified in Table [1](#tab:lex.charset.basic "Table 1: Basic character set")[.](#lex.charset-2.sentence-1)
[*Note [2](#lex.charset-note-2)*:
Unicode short names are given only as a means to identifying the character;
the numerical value has no other meaning in this context[.](#lex.charset-2.sentence-2)
— *end note*]
Table [1](#tab:lex.charset.basic) — Basic character set [[tab:lex.charset.basic]](./tab:lex.charset.basic)
| [🔗](#tab:lex.charset.basic-row-1)<br>**character** | | **glyph** |
| --- | --- | --- |
| [🔗](#tab:lex.charset.basic-row-2)<br>U+0009 | character tabulation | |
| [🔗](#tab:lex.charset.basic-row-3)<br>U+000b | line tabulation | |
| [🔗](#tab:lex.charset.basic-row-4)<br>U+000c | form feed | |
| [🔗](#tab:lex.charset.basic-row-5)<br>U+0020 | space | |
| [🔗](#tab:lex.charset.basic-row-6)<br>U+000a | line feed | new-line |
| [🔗](#tab:lex.charset.basic-row-7)<br>U+0021 | exclamation mark | ! |
| [🔗](#tab:lex.charset.basic-row-8)<br>U+0022 | quotation mark | " |
| [🔗](#tab:lex.charset.basic-row-9)<br>U+0023 | number sign | # |
| [🔗](#tab:lex.charset.basic-row-10)<br>U+0024 | dollar sign | $ |
| [🔗](#tab:lex.charset.basic-row-11)<br>U+0025 | percent sign | % |
| [🔗](#tab:lex.charset.basic-row-12)<br>U+0026 | ampersand | & |
| [🔗](#tab:lex.charset.basic-row-13)<br>U+0027 | apostrophe | ' |
| [🔗](#tab:lex.charset.basic-row-14)<br>U+0028 | left parenthesis | ( |
| [🔗](#tab:lex.charset.basic-row-15)<br>U+0029 | right parenthesis | ) |
| [🔗](#tab:lex.charset.basic-row-16)<br>U+002a | asterisk | * |
| [🔗](#tab:lex.charset.basic-row-17)<br>U+002b | plus sign | + |
| [🔗](#tab:lex.charset.basic-row-18)<br>U+002c | comma | , |
| [🔗](#tab:lex.charset.basic-row-19)<br>U+002d | hyphen-minus | - |
| [🔗](#tab:lex.charset.basic-row-20)<br>U+002e | full stop | . |
| [🔗](#tab:lex.charset.basic-row-21)<br>U+002f | solidus | / |
| [🔗](#tab:lex.charset.basic-row-22)<br>U+0030 .[.](#tab:lex.charset.basic-row-22-column-1-sentence-1) U+0039 | digit zero .. nine | 0 1 2 3 4 5 6 7 8 9 |
| [🔗](#tab:lex.charset.basic-row-23)<br>U+003a | colon | : |
| [🔗](#tab:lex.charset.basic-row-24)<br>U+003b | semicolon | ; |
| [🔗](#tab:lex.charset.basic-row-25)<br>U+003c | less-than sign | < |
| [🔗](#tab:lex.charset.basic-row-26)<br>U+003d | equals sign | = |
| [🔗](#tab:lex.charset.basic-row-27)<br>U+003e | greater-than sign | > |
| [🔗](#tab:lex.charset.basic-row-28)<br>U+003f | question mark | ? |
| [🔗](#tab:lex.charset.basic-row-29)<br>U+0040 | commercial at | @ |
| [🔗](#tab:lex.charset.basic-row-30)<br>U+0041 .[.](#tab:lex.charset.basic-row-30-column-1-sentence-1) U+005a | latin capital letter a .. z | A B C D E F G H I J K L M |
| [🔗](#tab:lex.charset.basic-row-31) | | N O P Q R S T U V W X Y Z |
| [🔗](#tab:lex.charset.basic-row-32)<br>U+005b | left square bracket | [ |
| [🔗](#tab:lex.charset.basic-row-33)<br>U+005c | reverse solidus | \ |
| [🔗](#tab:lex.charset.basic-row-34)<br>U+005d | right square bracket | ] |
| [🔗](#tab:lex.charset.basic-row-35)<br>U+005e | circumflex accent | ^ |
| [🔗](#tab:lex.charset.basic-row-36)<br>U+005f | low line | _ |
| [🔗](#tab:lex.charset.basic-row-37)<br>U+0060 | grave accent | ` |
| [🔗](#tab:lex.charset.basic-row-38)<br>U+0061 .[.](#tab:lex.charset.basic-row-38-column-1-sentence-1) U+007a | latin small letter a .. z | a b c d e f g h i j k l m |
| [🔗](#tab:lex.charset.basic-row-39) | | n o p q r s t u v w x y z |
| [🔗](#tab:lex.charset.basic-row-40)<br>U+007b | left curly bracket | { |
| [🔗](#tab:lex.charset.basic-row-41)<br>U+007c | vertical line | | |
| [🔗](#tab:lex.charset.basic-row-42)<br>U+007d | right curly bracket | } |
| [🔗](#tab:lex.charset.basic-row-43)<br>U+007e | tilde | ~ |
[3](#lex.charset-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L372)
The [*basic literal character set*](#def:character_set,basic_literal "5.3.1Character sets[lex.charset]") consists of
all characters of the basic character set,
plus the control characters specified in Table [2](#tab:lex.charset.literal "Table 2: Additional control characters in the basic literal character set")[.](#lex.charset-3.sentence-1)
Table [2](#tab:lex.charset.literal) — Additional control characters in the basic literal character set [[tab:lex.charset.literal]](./tab:lex.charset.literal)
| [🔗](#tab:lex.charset.literal-row-1)<br>**character** | |
| --- | --- |
| [🔗](#tab:lex.charset.literal-row-2)<br>U+0000 | null |
| [🔗](#tab:lex.charset.literal-row-3)<br>U+0007 | alert |
| [🔗](#tab:lex.charset.literal-row-4)<br>U+0008 | backspace |
| [🔗](#tab:lex.charset.literal-row-5)<br>U+000d | carriage return |
[4](#lex.charset-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L386)
A [*code unit*](#def:code_unit "5.3.1Character sets[lex.charset]") is an integer value
of character type ([[basic.fundamental]](basic.fundamental "6.9.2Fundamental types"))[.](#lex.charset-4.sentence-1)
Characters in a [*character-literal*](lex.ccon#nt:character-literal "5.13.3Character literals[lex.ccon]") other than a multicharacter or non-encodable character literal or
in a [*string-literal*](lex.string#nt:string-literal "5.13.5String literals[lex.string]") are encoded as
a sequence of one or more code units, as determined
by the [*encoding-prefix*](lex.ccon#nt:encoding-prefix "5.13.3Character literals[lex.ccon]") ([[lex.ccon]](lex.ccon "5.13.3Character literals"), [[lex.string]](lex.string "5.13.5String literals"));
this is termed the respective [*literal encoding*](#def:encoding,literal "5.3.1Character sets[lex.charset]")[.](#lex.charset-4.sentence-2)
The [*ordinary literal encoding*](#def:encoding,ordinary_literal "5.3.1Character sets[lex.charset]") is
the encoding applied to an ordinary character or string literal[.](#lex.charset-4.sentence-3)
The [*wide literal encoding*](#def:encoding,wide_literal "5.3.1Character sets[lex.charset]") is the encoding applied
to a wide character or string literal[.](#lex.charset-4.sentence-4)
[5](#lex.charset-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L400)
A literal encoding or a locale-specific encoding of one of
the execution character sets ([[character.seq]](character.seq "16.3.3.3.4Character sequences"))
encodes each element of the basic literal character set as
a single code unit with non-negative value,
distinct from the code unit for any other such element[.](#lex.charset-5.sentence-1)
[*Note [3](#lex.charset-note-3)*:
A character not in the basic literal character set
can be encoded with more than one code unit;
the value of such a code unit can be the same as
that of a code unit for an element of the basic literal character set[.](#lex.charset-5.sentence-2)
— *end note*]
The U+0000 null character is encoded as the value 0[.](#lex.charset-5.sentence-3)
No other element of the translation character set
is encoded with a code unit of value 0[.](#lex.charset-5.sentence-4)
The code unit value of each decimal digit character after the digit 0 (U+0030)
shall be one greater than the value of the previous[.](#lex.charset-5.sentence-5)
The ordinary and wide literal encodings are otherwiseimplementation-defined[.](#lex.charset-5.sentence-6)
For a UTF-8, UTF-16, or UTF-32 literal,
the implementation shall encode
the Unicode scalar value
corresponding to each character of the translation character set
as specified in the Unicode Standard
for the respective Unicode encoding form[.](#lex.charset-5.sentence-7)
### [5.3.2](#lex.universal.char) Universal character names [[lex.universal.char]](lex.universal.char)
[n-char:](#nt:n-char "5.3.2Universal character names[lex.universal.char]")
any member of the translation character set except the U+007d right curly bracket or new-line character
[n-char-sequence:](#nt:n-char-sequence "5.3.2Universal character names[lex.universal.char]")
[*n-char*](#nt:n-char "5.3.2Universal character names[lex.universal.char]") [*n-char-sequence*](#nt:n-char-sequence "5.3.2Universal character names[lex.universal.char]")opt
[named-universal-character:](#nt:named-universal-character "5.3.2Universal character names[lex.universal.char]")
\N{ [*n-char-sequence*](#nt:n-char-sequence "5.3.2Universal character names[lex.universal.char]") }
[hex-quad:](#nt:hex-quad "5.3.2Universal character names[lex.universal.char]")
[*hexadecimal-digit*](lex.icon#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]") [*hexadecimal-digit*](lex.icon#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]") [*hexadecimal-digit*](lex.icon#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]") [*hexadecimal-digit*](lex.icon#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]")
[simple-hexadecimal-digit-sequence:](#nt:simple-hexadecimal-digit-sequence "5.3.2Universal character names[lex.universal.char]")
[*hexadecimal-digit*](lex.icon#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]") [*simple-hexadecimal-digit-sequence*](#nt:simple-hexadecimal-digit-sequence "5.3.2Universal character names[lex.universal.char]")opt
[universal-character-name:](#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]")
\u [*hex-quad*](#nt:hex-quad "5.3.2Universal character names[lex.universal.char]")
\U [*hex-quad*](#nt:hex-quad "5.3.2Universal character names[lex.universal.char]") [*hex-quad*](#nt:hex-quad "5.3.2Universal character names[lex.universal.char]")
\u{ [*simple-hexadecimal-digit-sequence*](#nt:simple-hexadecimal-digit-sequence "5.3.2Universal character names[lex.universal.char]") }
[*named-universal-character*](#nt:named-universal-character "5.3.2Universal character names[lex.universal.char]")
[1](#lex.universal.char-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L467)
The [*universal-character-name*](#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]") construct provides a way to name any
element in the translation character set using just the basic character set[.](#lex.universal.char-1.sentence-1)
If a [*universal-character-name*](#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]") outside
the [*c-char-sequence*](lex.ccon#nt:c-char-sequence "5.13.3Character literals[lex.ccon]"), [*s-char-sequence*](lex.string#nt:s-char-sequence "5.13.5String literals[lex.string]"), or[*r-char-sequence*](lex.string#nt:r-char-sequence "5.13.5String literals[lex.string]") of a [*character-literal*](lex.ccon#nt:character-literal "5.13.3Character literals[lex.ccon]") or[*string-literal*](lex.string#nt:string-literal "5.13.5String literals[lex.string]") (in either case, including within a [*user-defined-literal*](lex.ext#nt:user-defined-literal "5.13.9User-defined literals[lex.ext]"))
corresponds to a control character or to a character in the basic character set,
the program is ill-formed[.](#lex.universal.char-1.sentence-2)
[*Note [1](#lex.universal.char-note-1)*:
A sequence of characters resembling a [*universal-character-name*](#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]") in an[*r-char-sequence*](lex.string#nt:r-char-sequence "5.13.5String literals[lex.string]") ([[lex.string]](lex.string "5.13.5String literals")) does not form a[*universal-character-name*](#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]")[.](#lex.universal.char-1.sentence-3)
— *end note*]
[2](#lex.universal.char-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L483)
A [*universal-character-name*](#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]") of the form \u [*hex-quad*](#nt:hex-quad "5.3.2Universal character names[lex.universal.char]"),\U [*hex-quad*](#nt:hex-quad "5.3.2Universal character names[lex.universal.char]") [*hex-quad*](#nt:hex-quad "5.3.2Universal character names[lex.universal.char]"), or\u{[*simple-hexadecimal-digit-sequence*](#nt:simple-hexadecimal-digit-sequence "5.3.2Universal character names[lex.universal.char]")} designates the character in the translation character set
whose Unicode scalar value is the hexadecimal number represented by
the sequence of [*hexadecimal-digit*](lex.icon#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]")*s* in the [*universal-character-name*](#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]")[.](#lex.universal.char-2.sentence-1)
The program is ill-formed if that number is not a Unicode scalar value[.](#lex.universal.char-2.sentence-2)
[3](#lex.universal.char-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L494)
A [*universal-character-name*](#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]") that is a [*named-universal-character*](#nt:named-universal-character "5.3.2Universal character names[lex.universal.char]") designates the corresponding character
in the Unicode Standard (chapter 4.8 Name)
if the [*n-char-sequence*](#nt:n-char-sequence "5.3.2Universal character names[lex.universal.char]") is equal
to its character name or
to one of its character name aliases of
type “control”, “correction”, or “alternate”;
otherwise, the program is ill-formed[.](#lex.universal.char-3.sentence-1)
[*Note [2](#lex.universal.char-note-2)*:
These aliases are listed in
the Unicode Character Database's NameAliases.txt[.](#lex.universal.char-3.sentence-2)
None of these names or aliases have leading or trailing spaces[.](#lex.universal.char-3.sentence-3)
— *end note*]

168
cppdraft/lex/charset.md Normal file
View File

@@ -0,0 +1,168 @@
[lex.charset]
# 5 Lexical conventions [[lex]](./#lex)
## 5.3 Characters [[lex.char]](lex.char#lex.charset)
### 5.3.1 Character sets [lex.charset]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L298)
The [*translation character set*](#def:character_set,translation "5.3.1Character sets[lex.charset]") consists of the following elements:
- [(1.1)](#1.1)
each abstract character assigned a code point in the Unicode codespace
as specified in the Unicode Standard, and
- [(1.2)](#1.2)
a distinct character for each Unicode scalar value
not assigned to an abstract character[.](#1.sentence-1)
[*Note [1](#note-1)*:
Unicode code points are integers
in the range [0, 10FFFF] (hexadecimal)[.](#1.sentence-2)
A surrogate code point is a value
in the range [D800, DFFF] (hexadecimal)[.](#1.sentence-3)
A Unicode scalar value is any code point that is not a surrogate code point[.](#1.sentence-4)
— *end note*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L317)
The [*basic character set*](#def:character_set,basic "5.3.1Character sets[lex.charset]") is a subset of the translation character set,
consisting of 99 characters as specified in Table [1](#tab:lex.charset.basic "Table 1: Basic character set")[.](#2.sentence-1)
[*Note [2](#note-2)*:
Unicode short names are given only as a means to identifying the character;
the numerical value has no other meaning in this context[.](#2.sentence-2)
— *end note*]
Table [1](#tab:lex.charset.basic) — Basic character set [[tab:lex.charset.basic]](./tab:lex.charset.basic)
| [🔗](#tab:lex.charset.basic-row-1)<br>**character** | | **glyph** |
| --- | --- | --- |
| [🔗](#tab:lex.charset.basic-row-2)<br>U+0009 | character tabulation | |
| [🔗](#tab:lex.charset.basic-row-3)<br>U+000b | line tabulation | |
| [🔗](#tab:lex.charset.basic-row-4)<br>U+000c | form feed | |
| [🔗](#tab:lex.charset.basic-row-5)<br>U+0020 | space | |
| [🔗](#tab:lex.charset.basic-row-6)<br>U+000a | line feed | new-line |
| [🔗](#tab:lex.charset.basic-row-7)<br>U+0021 | exclamation mark | ! |
| [🔗](#tab:lex.charset.basic-row-8)<br>U+0022 | quotation mark | " |
| [🔗](#tab:lex.charset.basic-row-9)<br>U+0023 | number sign | # |
| [🔗](#tab:lex.charset.basic-row-10)<br>U+0024 | dollar sign | $ |
| [🔗](#tab:lex.charset.basic-row-11)<br>U+0025 | percent sign | % |
| [🔗](#tab:lex.charset.basic-row-12)<br>U+0026 | ampersand | & |
| [🔗](#tab:lex.charset.basic-row-13)<br>U+0027 | apostrophe | ' |
| [🔗](#tab:lex.charset.basic-row-14)<br>U+0028 | left parenthesis | ( |
| [🔗](#tab:lex.charset.basic-row-15)<br>U+0029 | right parenthesis | ) |
| [🔗](#tab:lex.charset.basic-row-16)<br>U+002a | asterisk | * |
| [🔗](#tab:lex.charset.basic-row-17)<br>U+002b | plus sign | + |
| [🔗](#tab:lex.charset.basic-row-18)<br>U+002c | comma | , |
| [🔗](#tab:lex.charset.basic-row-19)<br>U+002d | hyphen-minus | - |
| [🔗](#tab:lex.charset.basic-row-20)<br>U+002e | full stop | . |
| [🔗](#tab:lex.charset.basic-row-21)<br>U+002f | solidus | / |
| [🔗](#tab:lex.charset.basic-row-22)<br>U+0030 .[.](#tab:lex.charset.basic-row-22-column-1-sentence-1) U+0039 | digit zero .. nine | 0 1 2 3 4 5 6 7 8 9 |
| [🔗](#tab:lex.charset.basic-row-23)<br>U+003a | colon | : |
| [🔗](#tab:lex.charset.basic-row-24)<br>U+003b | semicolon | ; |
| [🔗](#tab:lex.charset.basic-row-25)<br>U+003c | less-than sign | < |
| [🔗](#tab:lex.charset.basic-row-26)<br>U+003d | equals sign | = |
| [🔗](#tab:lex.charset.basic-row-27)<br>U+003e | greater-than sign | > |
| [🔗](#tab:lex.charset.basic-row-28)<br>U+003f | question mark | ? |
| [🔗](#tab:lex.charset.basic-row-29)<br>U+0040 | commercial at | @ |
| [🔗](#tab:lex.charset.basic-row-30)<br>U+0041 .[.](#tab:lex.charset.basic-row-30-column-1-sentence-1) U+005a | latin capital letter a .. z | A B C D E F G H I J K L M |
| [🔗](#tab:lex.charset.basic-row-31) | | N O P Q R S T U V W X Y Z |
| [🔗](#tab:lex.charset.basic-row-32)<br>U+005b | left square bracket | [ |
| [🔗](#tab:lex.charset.basic-row-33)<br>U+005c | reverse solidus | \ |
| [🔗](#tab:lex.charset.basic-row-34)<br>U+005d | right square bracket | ] |
| [🔗](#tab:lex.charset.basic-row-35)<br>U+005e | circumflex accent | ^ |
| [🔗](#tab:lex.charset.basic-row-36)<br>U+005f | low line | _ |
| [🔗](#tab:lex.charset.basic-row-37)<br>U+0060 | grave accent | ` |
| [🔗](#tab:lex.charset.basic-row-38)<br>U+0061 .[.](#tab:lex.charset.basic-row-38-column-1-sentence-1) U+007a | latin small letter a .. z | a b c d e f g h i j k l m |
| [🔗](#tab:lex.charset.basic-row-39) | | n o p q r s t u v w x y z |
| [🔗](#tab:lex.charset.basic-row-40)<br>U+007b | left curly bracket | { |
| [🔗](#tab:lex.charset.basic-row-41)<br>U+007c | vertical line | | |
| [🔗](#tab:lex.charset.basic-row-42)<br>U+007d | right curly bracket | } |
| [🔗](#tab:lex.charset.basic-row-43)<br>U+007e | tilde | ~ |
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L372)
The [*basic literal character set*](#def:character_set,basic_literal "5.3.1Character sets[lex.charset]") consists of
all characters of the basic character set,
plus the control characters specified in Table [2](#tab:lex.charset.literal "Table 2: Additional control characters in the basic literal character set")[.](#3.sentence-1)
Table [2](#tab:lex.charset.literal) — Additional control characters in the basic literal character set [[tab:lex.charset.literal]](./tab:lex.charset.literal)
| [🔗](#tab:lex.charset.literal-row-1)<br>**character** | |
| --- | --- |
| [🔗](#tab:lex.charset.literal-row-2)<br>U+0000 | null |
| [🔗](#tab:lex.charset.literal-row-3)<br>U+0007 | alert |
| [🔗](#tab:lex.charset.literal-row-4)<br>U+0008 | backspace |
| [🔗](#tab:lex.charset.literal-row-5)<br>U+000d | carriage return |
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L386)
A [*code unit*](#def:code_unit "5.3.1Character sets[lex.charset]") is an integer value
of character type ([[basic.fundamental]](basic.fundamental "6.9.2Fundamental types"))[.](#4.sentence-1)
Characters in a [*character-literal*](lex.ccon#nt:character-literal "5.13.3Character literals[lex.ccon]") other than a multicharacter or non-encodable character literal or
in a [*string-literal*](lex.string#nt:string-literal "5.13.5String literals[lex.string]") are encoded as
a sequence of one or more code units, as determined
by the [*encoding-prefix*](lex.ccon#nt:encoding-prefix "5.13.3Character literals[lex.ccon]") ([[lex.ccon]](lex.ccon "5.13.3Character literals"), [[lex.string]](lex.string "5.13.5String literals"));
this is termed the respective [*literal encoding*](#def:encoding,literal "5.3.1Character sets[lex.charset]")[.](#4.sentence-2)
The [*ordinary literal encoding*](#def:encoding,ordinary_literal "5.3.1Character sets[lex.charset]") is
the encoding applied to an ordinary character or string literal[.](#4.sentence-3)
The [*wide literal encoding*](#def:encoding,wide_literal "5.3.1Character sets[lex.charset]") is the encoding applied
to a wide character or string literal[.](#4.sentence-4)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L400)
A literal encoding or a locale-specific encoding of one of
the execution character sets ([[character.seq]](character.seq "16.3.3.3.4Character sequences"))
encodes each element of the basic literal character set as
a single code unit with non-negative value,
distinct from the code unit for any other such element[.](#5.sentence-1)
[*Note [3](#note-3)*:
A character not in the basic literal character set
can be encoded with more than one code unit;
the value of such a code unit can be the same as
that of a code unit for an element of the basic literal character set[.](#5.sentence-2)
— *end note*]
The U+0000 null character is encoded as the value 0[.](#5.sentence-3)
No other element of the translation character set
is encoded with a code unit of value 0[.](#5.sentence-4)
The code unit value of each decimal digit character after the digit 0 (U+0030)
shall be one greater than the value of the previous[.](#5.sentence-5)
The ordinary and wide literal encodings are otherwiseimplementation-defined[.](#5.sentence-6)
For a UTF-8, UTF-16, or UTF-32 literal,
the implementation shall encode
the Unicode scalar value
corresponding to each character of the translation character set
as specified in the Unicode Standard
for the respective Unicode encoding form[.](#5.sentence-7)

28
cppdraft/lex/comment.md Normal file
View File

@@ -0,0 +1,28 @@
[lex.comment]
# 5 Lexical conventions [[lex]](./#lex)
## 5.4 Comments [lex.comment]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L512)
The characters /* start a comment, which terminates with the
characters */[.](#1.sentence-1)
These comments do not nest[.](#1.sentence-2)
The characters // start a comment, which terminates immediately before the
next new-line character[.](#1.sentence-3)
[*Note [1](#note-1)*:
The comment characters //, /*,
and */ have no special meaning within a // comment and
are treated just like other characters[.](#1.sentence-4)
Similarly, the comment
characters // and /* have no special meaning within a/* comment[.](#1.sentence-5)
— *end note*]

50
cppdraft/lex/digraph.md Normal file
View File

@@ -0,0 +1,50 @@
[lex.digraph]
# 5 Lexical conventions [[lex]](./#lex)
## 5.9 Alternative tokens [lex.digraph]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L815)
Alternative token representations are provided for some operators and
punctuators[.](#1.sentence-1)[10](#footnote-10 "These include “digraphs” and additional reserved words. The term “digraph” (token consisting of two characters) is not perfectly descriptive, since one of the alternative preprocessing-tokens is %:%: and of course several primary tokens contain two characters. Nonetheless, those alternative tokens that aren't lexical keywords are colloquially known as “digraphs”.")
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L829)
In all respects of the language, each alternative token behaves the
same, respectively, as its primary token, except for its spelling[.](#2.sentence-1)[11](#footnote-11 "Thus the “stringized” values ([cpp.stringize]) of [ and &lt;: will be different, maintaining the source spelling, but the tokens can otherwise be freely interchanged.")
The set of alternative tokens is defined in
Table [3](#tab:lex.digraph "Table 3: Alternative tokens")[.](#2.sentence-2)
Table [3](#tab:lex.digraph) — Alternative tokens [[tab:lex.digraph]](./tab:lex.digraph)
| [🔗](#tab:lex.digraph-row-1)<br>**Alternative** | **Primary** | **Alternative** | **Primary** | **Alternative** | **Primary** |
| --- | --- | --- | --- | --- | --- |
| [🔗](#tab:lex.digraph-row-2)<br><% | { | and | && | and_eq | &= |
| [🔗](#tab:lex.digraph-row-3)<br>%> | } | bitor | | | or_eq | |= |
| [🔗](#tab:lex.digraph-row-4)<br><: | [ | or | || | xor_eq | ^= |
| [🔗](#tab:lex.digraph-row-5)<br>:> | ] | xor | ^ | not | ! |
| [🔗](#tab:lex.digraph-row-6)<br>%: | # | compl | ~ | not_eq | != |
| [🔗](#tab:lex.digraph-row-7)<br>%:%: | ## | bitand | & | | |
[10)](#footnote-10)[10)](#footnoteref-10)
These include “digraphs” and additional reserved words[.](#footnote-10.sentence-1)
The term
“digraph” (token consisting of two characters) is not perfectly
descriptive, since one of the alternative [*preprocessing-token*](lex.pptoken#nt:preprocessing-token "5.5Preprocessing tokens[lex.pptoken]")*s* is%:%: and of course several primary tokens contain two
characters[.](#footnote-10.sentence-2)
Nonetheless, those alternative tokens that aren't lexical
keywords are colloquially known as “digraphs”[.](#footnote-10.sentence-3)
[11)](#footnote-11)[11)](#footnoteref-11)
Thus the “stringized” values ([[cpp.stringize]](cpp.stringize "15.7.3The # operator")) of[ and <: will be different, maintaining the source
spelling, but the tokens can otherwise be freely interchanged[.](#footnote-11.sentence-1)

166
cppdraft/lex/ext.md Normal file
View File

@@ -0,0 +1,166 @@
[lex.ext]
# 5 Lexical conventions [[lex]](./#lex)
## 5.13 Literals [[lex.literal]](lex.literal#lex.ext)
### 5.13.9 User-defined literals [lex.ext]
[user-defined-literal:](#nt:user-defined-literal "5.13.9User-defined literals[lex.ext]")
[*user-defined-integer-literal*](#nt:user-defined-integer-literal "5.13.9User-defined literals[lex.ext]")
[*user-defined-floating-point-literal*](#nt:user-defined-floating-point-literal "5.13.9User-defined literals[lex.ext]")
[*user-defined-string-literal*](#nt:user-defined-string-literal "5.13.9User-defined literals[lex.ext]")
[*user-defined-character-literal*](#nt:user-defined-character-literal "5.13.9User-defined literals[lex.ext]")
[user-defined-integer-literal:](#nt:user-defined-integer-literal "5.13.9User-defined literals[lex.ext]")
[*decimal-literal*](lex.icon#nt:decimal-literal "5.13.2Integer literals[lex.icon]") [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[*octal-literal*](lex.icon#nt:octal-literal "5.13.2Integer literals[lex.icon]") [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[*hexadecimal-literal*](lex.icon#nt:hexadecimal-literal "5.13.2Integer literals[lex.icon]") [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[*binary-literal*](lex.icon#nt:binary-literal "5.13.2Integer literals[lex.icon]") [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[user-defined-floating-point-literal:](#nt:user-defined-floating-point-literal "5.13.9User-defined literals[lex.ext]")
[*fractional-constant*](lex.fcon#nt:fractional-constant "5.13.4Floating-point literals[lex.fcon]") [*exponent-part*](lex.fcon#nt:exponent-part "5.13.4Floating-point literals[lex.fcon]")opt [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[*digit-sequence*](lex.fcon#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]") [*exponent-part*](lex.fcon#nt:exponent-part "5.13.4Floating-point literals[lex.fcon]") [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[*hexadecimal-prefix*](lex.icon#nt:hexadecimal-prefix "5.13.2Integer literals[lex.icon]") [*hexadecimal-fractional-constant*](lex.fcon#nt:hexadecimal-fractional-constant "5.13.4Floating-point literals[lex.fcon]") [*binary-exponent-part*](lex.fcon#nt:binary-exponent-part "5.13.4Floating-point literals[lex.fcon]") [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[*hexadecimal-prefix*](lex.icon#nt:hexadecimal-prefix "5.13.2Integer literals[lex.icon]") [*hexadecimal-digit-sequence*](lex.icon#nt:hexadecimal-digit-sequence "5.13.2Integer literals[lex.icon]") [*binary-exponent-part*](lex.fcon#nt:binary-exponent-part "5.13.4Floating-point literals[lex.fcon]") [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[user-defined-string-literal:](#nt:user-defined-string-literal "5.13.9User-defined literals[lex.ext]")
[*string-literal*](lex.string#nt:string-literal "5.13.5String literals[lex.string]") [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[user-defined-character-literal:](#nt:user-defined-character-literal "5.13.9User-defined literals[lex.ext]")
[*character-literal*](lex.ccon#nt:character-literal "5.13.3Character literals[lex.ccon]") [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[ud-suffix:](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[*identifier*](lex.name#nt:identifier "5.11Identifiers[lex.name]")
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2203)
If a token matches both [*user-defined-literal*](#nt:user-defined-literal "5.13.9User-defined literals[lex.ext]") and another [*literal*](lex.literal.kinds#nt:literal "5.13.1Kinds of literals[lex.literal.kinds]") kind, it
is treated as the latter[.](#1.sentence-1)
[*Example [1](#example-1)*:
123_km is a [*user-defined-literal*](#nt:user-defined-literal "5.13.9User-defined literals[lex.ext]"), but 12LL is an[*integer-literal*](lex.icon#nt:integer-literal "5.13.2Integer literals[lex.icon]")[.](#1.sentence-2)
— *end example*]
The syntactic non-terminal preceding the [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]") in a[*user-defined-literal*](#nt:user-defined-literal "5.13.9User-defined literals[lex.ext]") is taken to be the longest sequence of
characters that could match that non-terminal[.](#1.sentence-3)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2215)
A [*user-defined-literal*](#nt:user-defined-literal "5.13.9User-defined literals[lex.ext]") is treated as a call to a literal operator or
literal operator template ([[over.literal]](over.literal "12.6User-defined literals"))[.](#2.sentence-1)
To determine the form of this call for
a given [*user-defined-literal*](#nt:user-defined-literal "5.13.9User-defined literals[lex.ext]") *L* with [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]") *X*,
first let *S* be the set of declarations
found by unqualified lookup for the [*literal-operator-id*](over.literal#nt:literal-operator-id "12.6User-defined literals[over.literal]") whose literal suffix identifier is *X* ([[basic.lookup.unqual]](basic.lookup.unqual "6.5.3Unqualified name lookup"))[.](#2.sentence-2)
*S* shall not be empty[.](#2.sentence-3)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2226)
If *L* is a [*user-defined-integer-literal*](#nt:user-defined-integer-literal "5.13.9User-defined literals[lex.ext]"), let *n* be the literal
without its [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")[.](#3.sentence-1)
If *S* contains a literal operator with
parameter type unsigned long long, the literal *L* is treated as a call of
the formoperator ""*X*(*n*ULL)
Otherwise, *S* shall contain a raw literal operator
or a numeric literal operator template ([[over.literal]](over.literal "12.6User-defined literals")) but not both[.](#3.sentence-3)
If *S* contains a raw literal operator,
the literal *L* is treated as a call of the formoperator ""*X*("*n*")
Otherwise (*S* contains a numeric literal operator template),*L* is treated as a call of the formoperator ""*X*<'c1', 'c2', ... 'ck'>() where *n* is the source character sequence c1c2...ck[.](#3.sentence-5)
[*Note [1](#note-1)*:
The sequencec1c2...ck can only contain characters from the basic character set[.](#3.sentence-6)
— *end note*]
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2252)
If *L* is a [*user-defined-floating-point-literal*](#nt:user-defined-floating-point-literal "5.13.9User-defined literals[lex.ext]"), let *f* be the
literal without its [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")[.](#4.sentence-1)
If *S* contains a literal operator
with parameter type long double, the literal *L* is treated as a call of
the formoperator ""*X*(*f*L)
Otherwise, *S* shall contain a raw literal operator
or a numeric literal operator template ([[over.literal]](over.literal "12.6User-defined literals")) but not both[.](#4.sentence-3)
If *S* contains a raw literal operator,
the [*literal*](lex.literal.kinds#nt:literal "5.13.1Kinds of literals[lex.literal.kinds]") *L* is treated as a call of the formoperator ""*X*("*f*")
Otherwise (*S* contains a numeric literal operator template),*L* is treated as a call of the formoperator ""*X*<'c1', 'c2', ... 'ck'>() where *f* is the source character sequence c1c2...ck[.](#4.sentence-5)
[*Note [2](#note-2)*:
The sequencec1c2...ck can only contain characters from the basic character set[.](#4.sentence-6)
— *end note*]
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2278)
If *L* is a [*user-defined-string-literal*](#nt:user-defined-string-literal "5.13.9User-defined literals[lex.ext]"),
let *str* be the literal without its [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]") and let *len* be the number of code units in *str* (i.e., its length excluding the terminating null character)[.](#5.sentence-1)
If *S* contains a literal operator template with
a constant template parameter for which *str* is
a well-formed [*template-argument*](temp.names#nt:template-argument "13.3Names of template specializations[temp.names]"),
the literal *L* is treated as a call of the formoperator ""*X*<*str*>()
Otherwise, the literal *L* is treated as a call of the formoperator ""*X*(*str*, *len*)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2295)
If *L* is a [*user-defined-character-literal*](#nt:user-defined-character-literal "5.13.9User-defined literals[lex.ext]"), let *ch* be the
literal without its [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")[.](#6.sentence-1)
*S* shall contain a [literal operator](over.literal#def:literal,operator "12.6User-defined literals[over.literal]") whose only parameter has
the type of *ch* and the
literal *L* is treated as a call
of the formoperator ""*X*(*ch*)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2306)
[*Example [2](#example-2)*: long double operator ""_w(long double);
std::string operator ""_w(const char16_t*, std::size_t);unsigned operator ""_w(const char*);int main() {1.2_w; // calls operator ""_w(1.2L)u"one"_w; // calls operator ""_w(u"one", 3)12_w; // calls operator ""_w("12")"two"_w; // error: no applicable literal operator} — *end example*]
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2321)
In translation phase 6 ([[lex.phases]](lex.phases "5.2Phases of translation")), adjacent [*string-literal*](lex.string#nt:string-literal "5.13.5String literals[lex.string]")*s* are concatenated and[*user-defined-string-literal*](#nt:user-defined-string-literal "5.13.9User-defined literals[lex.ext]")*s* are considered [*string-literal*](lex.string#nt:string-literal "5.13.5String literals[lex.string]")*s* for that
purpose[.](#8.sentence-1)
During concatenation, [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")es are removed and ignored and
the concatenation process occurs as described in [[lex.string]](lex.string "5.13.5String literals")[.](#8.sentence-2)
At the end of phase
6, if a [*string-literal*](lex.string#nt:string-literal "5.13.5String literals[lex.string]") is the result of a concatenation involving at least one[*user-defined-string-literal*](#nt:user-defined-string-literal "5.13.9User-defined literals[lex.ext]"), all the participating[*user-defined-string-literal*](#nt:user-defined-string-literal "5.13.9User-defined literals[lex.ext]")*s* shall have the same [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]") and that suffix is applied to the result of the concatenation[.](#8.sentence-3)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2331)
[*Example [3](#example-3)*: int main() {L"A" "B" "C"_x; // OK, same as L"ABC"_x"P"_x "Q" "R"_y; // error: two different [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")es} — *end example*]

119
cppdraft/lex/fcon.md Normal file
View File

@@ -0,0 +1,119 @@
[lex.fcon]
# 5 Lexical conventions [[lex]](./#lex)
## 5.13 Literals [[lex.literal]](lex.literal#lex.fcon)
### 5.13.4 Floating-point literals [lex.fcon]
[floating-point-literal:](#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]")
[*decimal-floating-point-literal*](#nt:decimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]")
[*hexadecimal-floating-point-literal*](#nt:hexadecimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]")
[decimal-floating-point-literal:](#nt:decimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]")
[*fractional-constant*](#nt:fractional-constant "5.13.4Floating-point literals[lex.fcon]") [*exponent-part*](#nt:exponent-part "5.13.4Floating-point literals[lex.fcon]")opt [*floating-point-suffix*](#nt:floating-point-suffix "5.13.4Floating-point literals[lex.fcon]")opt
[*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]") [*exponent-part*](#nt:exponent-part "5.13.4Floating-point literals[lex.fcon]") [*floating-point-suffix*](#nt:floating-point-suffix "5.13.4Floating-point literals[lex.fcon]")opt
[hexadecimal-floating-point-literal:](#nt:hexadecimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]")
[*hexadecimal-prefix*](lex.icon#nt:hexadecimal-prefix "5.13.2Integer literals[lex.icon]") [*hexadecimal-fractional-constant*](#nt:hexadecimal-fractional-constant "5.13.4Floating-point literals[lex.fcon]") [*binary-exponent-part*](#nt:binary-exponent-part "5.13.4Floating-point literals[lex.fcon]") [*floating-point-suffix*](#nt:floating-point-suffix "5.13.4Floating-point literals[lex.fcon]")opt
[*hexadecimal-prefix*](lex.icon#nt:hexadecimal-prefix "5.13.2Integer literals[lex.icon]") [*hexadecimal-digit-sequence*](lex.icon#nt:hexadecimal-digit-sequence "5.13.2Integer literals[lex.icon]") [*binary-exponent-part*](#nt:binary-exponent-part "5.13.4Floating-point literals[lex.fcon]") [*floating-point-suffix*](#nt:floating-point-suffix "5.13.4Floating-point literals[lex.fcon]")opt
[fractional-constant:](#nt:fractional-constant "5.13.4Floating-point literals[lex.fcon]")
[*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]")opt . [*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]")
[*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]") .
[hexadecimal-fractional-constant:](#nt:hexadecimal-fractional-constant "5.13.4Floating-point literals[lex.fcon]")
[*hexadecimal-digit-sequence*](lex.icon#nt:hexadecimal-digit-sequence "5.13.2Integer literals[lex.icon]")opt . [*hexadecimal-digit-sequence*](lex.icon#nt:hexadecimal-digit-sequence "5.13.2Integer literals[lex.icon]")
[*hexadecimal-digit-sequence*](lex.icon#nt:hexadecimal-digit-sequence "5.13.2Integer literals[lex.icon]") .
[exponent-part:](#nt:exponent-part "5.13.4Floating-point literals[lex.fcon]")
e [*sign*](#nt:sign "5.13.4Floating-point literals[lex.fcon]")opt [*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]")
E [*sign*](#nt:sign "5.13.4Floating-point literals[lex.fcon]")opt [*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]")
[binary-exponent-part:](#nt:binary-exponent-part "5.13.4Floating-point literals[lex.fcon]")
p [*sign*](#nt:sign "5.13.4Floating-point literals[lex.fcon]")opt [*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]")
P [*sign*](#nt:sign "5.13.4Floating-point literals[lex.fcon]")opt [*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]")
[sign:](#nt:sign "5.13.4Floating-point literals[lex.fcon]") one of
+ -
[digit-sequence:](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]")
[*digit*](lex.name#nt:digit "5.11Identifiers[lex.name]")
[*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]") 'opt [*digit*](lex.name#nt:digit "5.11Identifiers[lex.name]")
[floating-point-suffix:](#nt:floating-point-suffix "5.13.4Floating-point literals[lex.fcon]") one of
f l f16 f32 f64 f128 bf16 F L F16 F32 F64 F128 BF16
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1718)
The type of
a [*floating-point-literal*](#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]") ([[basic.fundamental]](basic.fundamental "6.9.2Fundamental types"), [[basic.extended.fp]](basic.extended.fp "6.9.3Optional extended floating-point types"))
is determined by
its [*floating-point-suffix*](#nt:floating-point-suffix "5.13.4Floating-point literals[lex.fcon]") as specified in Table [11](#tab:lex.fcon.type "Table 11: Types of floating-point-literals")[.](#1.sentence-1)
[*Note [1](#note-1)*:
The floating-point suffixesf16, f32, f64, f128, bf16,F16, F32, F64, F128, and BF16 are conditionally-supported[.](#1.sentence-2)
See [[basic.extended.fp]](basic.extended.fp "6.9.3Optional extended floating-point types")[.](#1.sentence-3)
— *end note*]
Table [11](#tab:lex.fcon.type) — Types of [*floating-point-literal*](#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]")*s* [[tab:lex.fcon.type]](./tab:lex.fcon.type)
| [🔗](#tab:lex.fcon.type-row-1)<br>**[*floating-point-suffix*](#nt:floating-point-suffix "5.13.4Floating-point literals[lex.fcon]")** | **type** |
| --- | --- |
| [🔗](#tab:lex.fcon.type-row-2)<br>none | double |
| [🔗](#tab:lex.fcon.type-row-3)<br>f or F | float |
| [🔗](#tab:lex.fcon.type-row-4)<br>l or L | long double |
| [🔗](#tab:lex.fcon.type-row-5)<br>f16 or F16 | std::float16_t |
| [🔗](#tab:lex.fcon.type-row-6)<br>f32 or F32 | std::float32_t |
| [🔗](#tab:lex.fcon.type-row-7)<br>f64 or F64 | std::float64_t |
| [🔗](#tab:lex.fcon.type-row-8)<br>f128 or F128 | std::float128_t |
| [🔗](#tab:lex.fcon.type-row-9)<br>bf16 or BF16 | std::bfloat16_t |
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1752)
The [*significand*](#def:significand "5.13.4Floating-point literals[lex.fcon]") of a [*floating-point-literal*](#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]") is the [*fractional-constant*](#nt:fractional-constant "5.13.4Floating-point literals[lex.fcon]") or [*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]") of a [*decimal-floating-point-literal*](#nt:decimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]") or the [*hexadecimal-fractional-constant*](#nt:hexadecimal-fractional-constant "5.13.4Floating-point literals[lex.fcon]") or [*hexadecimal-digit-sequence*](lex.icon#nt:hexadecimal-digit-sequence "5.13.2Integer literals[lex.icon]") of a [*hexadecimal-floating-point-literal*](#nt:hexadecimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]")[.](#2.sentence-1)
In the significand,
the sequence of [*digit*](lex.name#nt:digit "5.11Identifiers[lex.name]")*s* or [*hexadecimal-digit*](lex.icon#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]")*s* and optional period are interpreted as a base N real number s,
where N is 10 for a [*decimal-floating-point-literal*](#nt:decimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]") and
16 for a [*hexadecimal-floating-point-literal*](#nt:hexadecimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]")[.](#2.sentence-2)
[*Note [2](#note-2)*:
Any optional separating single quotes are ignored when determining the value[.](#2.sentence-3)
— *end note*]
If an [*exponent-part*](#nt:exponent-part "5.13.4Floating-point literals[lex.fcon]") or [*binary-exponent-part*](#nt:binary-exponent-part "5.13.4Floating-point literals[lex.fcon]") is present,
the exponent e of the [*floating-point-literal*](#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]") is the result of interpreting
the sequence of an optional [*sign*](#nt:sign "5.13.4Floating-point literals[lex.fcon]") and the [*digit*](lex.name#nt:digit "5.11Identifiers[lex.name]")*s* as a base 10 integer[.](#2.sentence-4)
Otherwise, the exponent e is 0[.](#2.sentence-5)
The scaled value of the literal iss×10e for a [*decimal-floating-point-literal*](#nt:decimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]") ands×2e for a [*hexadecimal-floating-point-literal*](#nt:hexadecimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]")[.](#2.sentence-6)
[*Example [1](#example-1)*:
The [*floating-point-literal*](#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]")*s*49.625 and 0xC.68p+2 have the same value[.](#2.sentence-7)
The [*floating-point-literal*](#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]")*s*1.602'176'565e-19 and 1.602176565e-19 have the same value[.](#2.sentence-8)
— *end example*]
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1786)
If the scaled value is not in the range of representable
values for its type, the program is ill-formed[.](#3.sentence-1)
Otherwise, the value of a [*floating-point-literal*](#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]") is the scaled value if representable,
else the larger or smaller representable value nearest the scaled value,
chosen in an implementation-defined manner[.](#3.sentence-2)

54
cppdraft/lex/header.md Normal file
View File

@@ -0,0 +1,54 @@
[lex.header]
# 5 Lexical conventions [[lex]](./#lex)
## 5.6 Header names [lex.header]
[header-name:](#nt:header-name "5.6Header names[lex.header]")
< [*h-char-sequence*](#nt:h-char-sequence "5.6Header names[lex.header]") >
" [*q-char-sequence*](#nt:q-char-sequence "5.6Header names[lex.header]") "
[h-char-sequence:](#nt:h-char-sequence "5.6Header names[lex.header]")
[*h-char*](#nt:h-char "5.6Header names[lex.header]") [*h-char-sequence*](#nt:h-char-sequence "5.6Header names[lex.header]")opt
[h-char:](#nt:h-char "5.6Header names[lex.header]")
any member of the translation character set except new-line and U+003e greater-than sign
[q-char-sequence:](#nt:q-char-sequence "5.6Header names[lex.header]")
[*q-char*](#nt:q-char "5.6Header names[lex.header]") [*q-char-sequence*](#nt:q-char-sequence "5.6Header names[lex.header]")opt
[q-char:](#nt:q-char "5.6Header names[lex.header]")
any member of the translation character set except new-line and U+0022 quotation mark
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L715)
The sequences in both forms of [*header-name*](#nt:header-name "5.6Header names[lex.header]")*s* are mapped in animplementation-defined manner to headers or to
external source file names as specified in [[cpp.include]](cpp.include "15.3Source file inclusion")[.](#1.sentence-1)
[*Note [1](#note-1)*:
Header name preprocessing tokens appear only within
a #include preprocessing directive,
a __has_include preprocessing expression, or
after certain occurrences of an import token
(see [[lex.pptoken]](lex.pptoken "5.5Preprocessing tokens"))[.](#1.sentence-2)
— *end note*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L727)
The appearance of either of the characters ' or \ or of
either of the character sequences /* or // in a[*q-char-sequence*](#nt:q-char-sequence "5.6Header names[lex.header]") or an [*h-char-sequence*](#nt:h-char-sequence "5.6Header names[lex.header]") is conditionally-supported with implementation-defined semantics, as is the appearance of the character" in an [*h-char-sequence*](#nt:h-char-sequence "5.6Header names[lex.header]")[.](#2.sentence-1)
[*Note [2](#note-2)*:
Thus, a sequence of characters
that resembles an escape sequence can result in an error, be interpreted as the
character corresponding to the escape sequence, or have a completely different meaning,
depending on the implementation[.](#2.sentence-2)
— *end note*]

173
cppdraft/lex/icon.md Normal file
View File

@@ -0,0 +1,173 @@
[lex.icon]
# 5 Lexical conventions [[lex]](./#lex)
## 5.13 Literals [[lex.literal]](lex.literal#lex.icon)
### 5.13.2 Integer literals [lex.icon]
[integer-literal:](#nt:integer-literal "5.13.2Integer literals[lex.icon]")
[*binary-literal*](#nt:binary-literal "5.13.2Integer literals[lex.icon]") [*integer-suffix*](#nt:integer-suffix "5.13.2Integer literals[lex.icon]")opt
[*octal-literal*](#nt:octal-literal "5.13.2Integer literals[lex.icon]") [*integer-suffix*](#nt:integer-suffix "5.13.2Integer literals[lex.icon]")opt
[*decimal-literal*](#nt:decimal-literal "5.13.2Integer literals[lex.icon]") [*integer-suffix*](#nt:integer-suffix "5.13.2Integer literals[lex.icon]")opt
[*hexadecimal-literal*](#nt:hexadecimal-literal "5.13.2Integer literals[lex.icon]") [*integer-suffix*](#nt:integer-suffix "5.13.2Integer literals[lex.icon]")opt
[binary-literal:](#nt:binary-literal "5.13.2Integer literals[lex.icon]")
0b [*binary-digit*](#nt:binary-digit "5.13.2Integer literals[lex.icon]")
0B [*binary-digit*](#nt:binary-digit "5.13.2Integer literals[lex.icon]")
[*binary-literal*](#nt:binary-literal "5.13.2Integer literals[lex.icon]") 'opt [*binary-digit*](#nt:binary-digit "5.13.2Integer literals[lex.icon]")
[octal-literal:](#nt:octal-literal "5.13.2Integer literals[lex.icon]")
0
[*octal-literal*](#nt:octal-literal "5.13.2Integer literals[lex.icon]") 'opt [*octal-digit*](#nt:octal-digit "5.13.2Integer literals[lex.icon]")
[decimal-literal:](#nt:decimal-literal "5.13.2Integer literals[lex.icon]")
[*nonzero-digit*](#nt:nonzero-digit "5.13.2Integer literals[lex.icon]")
[*decimal-literal*](#nt:decimal-literal "5.13.2Integer literals[lex.icon]") 'opt [*digit*](lex.name#nt:digit "5.11Identifiers[lex.name]")
[hexadecimal-literal:](#nt:hexadecimal-literal "5.13.2Integer literals[lex.icon]")
[*hexadecimal-prefix*](#nt:hexadecimal-prefix "5.13.2Integer literals[lex.icon]") [*hexadecimal-digit-sequence*](#nt:hexadecimal-digit-sequence "5.13.2Integer literals[lex.icon]")
[binary-digit:](#nt:binary-digit "5.13.2Integer literals[lex.icon]") one of
0 1
[octal-digit:](#nt:octal-digit "5.13.2Integer literals[lex.icon]") one of
0 1 2 3 4 5 6 7
[nonzero-digit:](#nt:nonzero-digit "5.13.2Integer literals[lex.icon]") one of
1 2 3 4 5 6 7 8 9
[hexadecimal-prefix:](#nt:hexadecimal-prefix "5.13.2Integer literals[lex.icon]") one of
0x 0X
[hexadecimal-digit-sequence:](#nt:hexadecimal-digit-sequence "5.13.2Integer literals[lex.icon]")
[*hexadecimal-digit*](#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]")
[*hexadecimal-digit-sequence*](#nt:hexadecimal-digit-sequence "5.13.2Integer literals[lex.icon]") 'opt [*hexadecimal-digit*](#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]")
[hexadecimal-digit:](#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]") one of
0 1 2 3 4 5 6 7 8 9
a b c d e f
A B C D E F
[integer-suffix:](#nt:integer-suffix "5.13.2Integer literals[lex.icon]")
[*unsigned-suffix*](#nt:unsigned-suffix "5.13.2Integer literals[lex.icon]") [*long-suffix*](#nt:long-suffix "5.13.2Integer literals[lex.icon]")opt
[*unsigned-suffix*](#nt:unsigned-suffix "5.13.2Integer literals[lex.icon]") [*long-long-suffix*](#nt:long-long-suffix "5.13.2Integer literals[lex.icon]")opt
[*unsigned-suffix*](#nt:unsigned-suffix "5.13.2Integer literals[lex.icon]") [*size-suffix*](#nt:size-suffix "5.13.2Integer literals[lex.icon]")opt
[*long-suffix*](#nt:long-suffix "5.13.2Integer literals[lex.icon]") [*unsigned-suffix*](#nt:unsigned-suffix "5.13.2Integer literals[lex.icon]")opt
[*long-long-suffix*](#nt:long-long-suffix "5.13.2Integer literals[lex.icon]") [*unsigned-suffix*](#nt:unsigned-suffix "5.13.2Integer literals[lex.icon]")opt
[*size-suffix*](#nt:size-suffix "5.13.2Integer literals[lex.icon]") [*unsigned-suffix*](#nt:unsigned-suffix "5.13.2Integer literals[lex.icon]")opt
[unsigned-suffix:](#nt:unsigned-suffix "5.13.2Integer literals[lex.icon]") one of
u U
[long-suffix:](#nt:long-suffix "5.13.2Integer literals[lex.icon]") one of
l L
[long-long-suffix:](#nt:long-long-suffix "5.13.2Integer literals[lex.icon]") one of
ll LL
[size-suffix:](#nt:size-suffix "5.13.2Integer literals[lex.icon]") one of
z Z
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1268)
In an [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]"),
the sequence of[*binary-digit*](#nt:binary-digit "5.13.2Integer literals[lex.icon]")*s*,[*octal-digit*](#nt:octal-digit "5.13.2Integer literals[lex.icon]")*s*,[*digit*](lex.name#nt:digit "5.11Identifiers[lex.name]")*s*, or[*hexadecimal-digit*](#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]")*s* is interpreted as a base N integer as shown in Table [7](#tab:lex.icon.base "Table 7: Base of integer-literals");
the lexically first digit of the sequence of digits is the most significant[.](#1.sentence-1)
[*Note [1](#note-1)*:
The prefix and any optional separating single quotes are ignored
when determining the value[.](#1.sentence-2)
— *end note*]
Table [7](#tab:lex.icon.base) — Base of [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]")*s* [[tab:lex.icon.base]](./tab:lex.icon.base)
| [🔗](#tab:lex.icon.base-row-1)<br>**Kind of [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]")** | **base N** |
| --- | --- |
| [🔗](#tab:lex.icon.base-row-2)<br>[*binary-literal*](#nt:binary-literal "5.13.2Integer literals[lex.icon]") | 2 |
| [🔗](#tab:lex.icon.base-row-3)<br>[*octal-literal*](#nt:octal-literal "5.13.2Integer literals[lex.icon]") | 8 |
| [🔗](#tab:lex.icon.base-row-4)<br>[*decimal-literal*](#nt:decimal-literal "5.13.2Integer literals[lex.icon]") | 10 |
| [🔗](#tab:lex.icon.base-row-5)<br>[*hexadecimal-literal*](#nt:hexadecimal-literal "5.13.2Integer literals[lex.icon]") | 16 |
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1297)
The [*hexadecimal-digit*](#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]")*s*a through f and A through F have decimal values ten through fifteen[.](#2.sentence-1)
[*Example [1](#example-1)*:
The number twelve can be written 12, 014,0XC, or 0b1100[.](#2.sentence-2)
The [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]")*s* 1048576,1'048'576, 0X100000, 0x10'0000, and0'004'000'000 all have the same value[.](#2.sentence-3)
— *end example*]
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1308)
The type of an [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]") is
the first type in the list in Table [8](#tab:lex.icon.type "Table 8: Types of integer-literals") corresponding to its optional [*integer-suffix*](#nt:integer-suffix "5.13.2Integer literals[lex.icon]") in which its value can be represented[.](#3.sentence-1)
Table [8](#tab:lex.icon.type) — Types of [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]")*s* [[tab:lex.icon.type]](./tab:lex.icon.type)
| [🔗](#tab:lex.icon.type-row-1)<br>**[*integer-suffix*](#nt:integer-suffix "5.13.2Integer literals[lex.icon]")** | **[*decimal-literal*](#nt:decimal-literal "5.13.2Integer literals[lex.icon]")** | **[*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]") other than [*decimal-literal*](#nt:decimal-literal "5.13.2Integer literals[lex.icon]")** |
| --- | --- | --- |
| [🔗](#tab:lex.icon.type-row-2)<br>none | int | int |
| [🔗](#tab:lex.icon.type-row-3) | long int | unsigned int |
| [🔗](#tab:lex.icon.type-row-4) | long long int | long int |
| [🔗](#tab:lex.icon.type-row-5) | | unsigned long int |
| [🔗](#tab:lex.icon.type-row-6) | | long long int |
| [🔗](#tab:lex.icon.type-row-7) | | unsigned long long int |
| [🔗](#tab:lex.icon.type-row-8)<br>u or U | unsigned int | unsigned int |
| [🔗](#tab:lex.icon.type-row-9) | unsigned long int | unsigned long int |
| [🔗](#tab:lex.icon.type-row-10) | unsigned long long int | unsigned long long int |
| [🔗](#tab:lex.icon.type-row-11)<br>l or L | long int | long int |
| [🔗](#tab:lex.icon.type-row-12) | long long int | unsigned long int |
| [🔗](#tab:lex.icon.type-row-13) | | long long int |
| [🔗](#tab:lex.icon.type-row-14) | | unsigned long long int |
| [🔗](#tab:lex.icon.type-row-15)<br>Both u or U | unsigned long int | unsigned long int |
| [🔗](#tab:lex.icon.type-row-16)<br>and l or L | unsigned long long int | unsigned long long int |
| [🔗](#tab:lex.icon.type-row-17)<br>ll or LL | long long int | long long int |
| [🔗](#tab:lex.icon.type-row-18) | | unsigned long long int |
| [🔗](#tab:lex.icon.type-row-19)<br>Both u or U | unsigned long long int | unsigned long long int |
| [🔗](#tab:lex.icon.type-row-20)<br>and ll or LL | | |
| [🔗](#tab:lex.icon.type-row-21)<br>z or Z | the signed integer type corresponding | the signed integer type |
| [🔗](#tab:lex.icon.type-row-22) | to std::size_t ([[support.types.layout]](support.types.layout "17.2.4Sizes, alignments, and offsets")) | corresponding to std::size_t |
| [🔗](#tab:lex.icon.type-row-23) | | std::size_t |
| [🔗](#tab:lex.icon.type-row-24)<br>Both u or U | std::size_t | std::size_t |
| [🔗](#tab:lex.icon.type-row-25)<br>and z or Z | | |
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1399)
Except for [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]")*s* containing
a [*size-suffix*](#nt:size-suffix "5.13.2Integer literals[lex.icon]"),
if the value of an [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]") cannot be represented by any type in its list and
an extended integer type ([[basic.fundamental]](basic.fundamental "6.9.2Fundamental types")) can represent its value,
it may have that extended integer type[.](#4.sentence-1)
If all of the types in the list for the [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]") are signed,
the extended integer type is signed[.](#4.sentence-2)
If all of the types in the list for the [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]") are unsigned,
the extended integer type is unsigned[.](#4.sentence-3)
If the list contains both signed and unsigned types,
the extended integer type may be signed or unsigned[.](#4.sentence-4)
If an [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]") cannot be represented by any of the allowed types,
the program is ill-formed[.](#4.sentence-5)
[*Note [2](#note-2)*:
An [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]") with a z or Z suffix
is ill-formed if it cannot be represented by std::size_t[.](#4.sentence-6)
— *end note*]

62
cppdraft/lex/key.md Normal file
View File

@@ -0,0 +1,62 @@
[lex.key]
# 5 Lexical conventions [[lex]](./#lex)
## 5.12 Keywords [lex.key]
[keyword:](#nt:keyword "5.12Keywords[lex.key]")
any identifier listed in Table [5](#tab:lex.key "Table 5: Keywords")
*import-keyword*
*module-keyword*
*export-keyword*
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1026)
The identifiers shown in Table [5](#tab:lex.key "Table 5: Keywords") are reserved for use
as keywords (that is, they are unconditionally treated as keywords in
phase 7) except in an [*attribute-token*](dcl.attr.grammar#nt:attribute-token "9.13.1Attribute syntax and semantics[dcl.attr.grammar]") ([[dcl.attr.grammar]](dcl.attr.grammar "9.13.1Attribute syntax and semantics"))[.](#1.sentence-1)
[*Note [1](#note-1)*:
The register keyword is unused but
is reserved for future use[.](#1.sentence-2)
— *end note*]
Table [5](#tab:lex.key) — Keywords [[tab:lex.key]](./tab:lex.key)
| [🔗](#tab:lex.key-row-1)<br>alignas | constinit | extern | protected | throw |
| --- | --- | --- | --- | --- |
| [🔗](#tab:lex.key-row-2)<br>alignof | const_cast | false | public | true |
| [🔗](#tab:lex.key-row-3)<br>asm | continue | float | register | try |
| [🔗](#tab:lex.key-row-4)<br>auto | contract_assert | for | reinterpret_cast | typedef |
| [🔗](#tab:lex.key-row-5)<br>bool | co_await | friend | requires | typeid |
| [🔗](#tab:lex.key-row-6)<br>break | co_return | goto | return | typename |
| [🔗](#tab:lex.key-row-7)<br>case | co_yield | if | short | union |
| [🔗](#tab:lex.key-row-8)<br>catch | decltype | inline | signed | unsigned |
| [🔗](#tab:lex.key-row-9)<br>char | default | int | sizeof | using |
| [🔗](#tab:lex.key-row-10)<br>char8_t | delete | long | static | virtual |
| [🔗](#tab:lex.key-row-11)<br>char16_t | do | mutable | static_assert | void |
| [🔗](#tab:lex.key-row-12)<br>char32_t | double | namespace | static_cast | volatile |
| [🔗](#tab:lex.key-row-13)<br>class | dynamic_cast | new | struct | wchar_t |
| [🔗](#tab:lex.key-row-14)<br>concept | else | noexcept | switch | while |
| [🔗](#tab:lex.key-row-15)<br>const | enum | nullptr | template | |
| [🔗](#tab:lex.key-row-16)<br>consteval | explicit | operator | this | |
| [🔗](#tab:lex.key-row-17)<br>constexpr | export | private | thread_local | |
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1126)
Furthermore, the alternative representations shown in
Table [6](#tab:lex.key.digraph "Table 6: Alternative representations") for certain operators and
punctuators ([[lex.digraph]](lex.digraph "5.9Alternative tokens")) are reserved and shall not be used
otherwise[.](#2.sentence-1)
Table [6](#tab:lex.key.digraph) — Alternative representations [[tab:lex.key.digraph]](./tab:lex.key.digraph)
| [🔗](#tab:lex.key.digraph-row-1)<br>and | and_eq | bitand | bitor | compl | not |
| --- | --- | --- | --- | --- | --- |
| [🔗](#tab:lex.key.digraph-row-2)<br>not_eq | or | or_eq | xor | xor_eq | |

992
cppdraft/lex/literal.md Normal file
View File

@@ -0,0 +1,992 @@
[lex.literal]
# 5 Lexical conventions [[lex]](./#lex)
## 5.13 Literals [lex.literal]
### [5.13.1](#kinds) Kinds of literals [[lex.literal.kinds]](lex.literal.kinds)
[1](#kinds-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1146)
There are several kinds of literals[.](#kinds-1.sentence-1)[14](#footnote-14 "The term “literal” generally designates, in this document, those tokens that are called “constants” in C.")
[literal:](#nt:literal "5.13.1Kinds of literals[lex.literal.kinds]")
[*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]")
[*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]")
[*floating-point-literal*](#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]")
[*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")
[*boolean-literal*](#nt:boolean-literal "5.13.7Boolean literals[lex.bool]")
[*pointer-literal*](#nt:pointer-literal "5.13.8Pointer literals[lex.nullptr]")
[*user-defined-literal*](#nt:user-defined-literal "5.13.9User-defined literals[lex.ext]")
[*Note [1](#kinds-note-1)*:
When appearing as an [*expression*](expr.comma#nt:expression "7.6.20Comma operator[expr.comma]"),
a literal has a type and a value category ([[expr.prim.literal]](expr.prim.literal "7.5.2Literals"))[.](#kinds-1.sentence-2)
— *end note*]
[14)](#footnote-14)[14)](#footnoteref-14)
The term “literal” generally designates, in this
document, those tokens that are called “constants” in C[.](#footnote-14.sentence-1)
### [5.13.2](#lex.icon) Integer literals [[lex.icon]](lex.icon)
[integer-literal:](#nt:integer-literal "5.13.2Integer literals[lex.icon]")
[*binary-literal*](#nt:binary-literal "5.13.2Integer literals[lex.icon]") [*integer-suffix*](#nt:integer-suffix "5.13.2Integer literals[lex.icon]")opt
[*octal-literal*](#nt:octal-literal "5.13.2Integer literals[lex.icon]") [*integer-suffix*](#nt:integer-suffix "5.13.2Integer literals[lex.icon]")opt
[*decimal-literal*](#nt:decimal-literal "5.13.2Integer literals[lex.icon]") [*integer-suffix*](#nt:integer-suffix "5.13.2Integer literals[lex.icon]")opt
[*hexadecimal-literal*](#nt:hexadecimal-literal "5.13.2Integer literals[lex.icon]") [*integer-suffix*](#nt:integer-suffix "5.13.2Integer literals[lex.icon]")opt
[binary-literal:](#nt:binary-literal "5.13.2Integer literals[lex.icon]")
0b [*binary-digit*](#nt:binary-digit "5.13.2Integer literals[lex.icon]")
0B [*binary-digit*](#nt:binary-digit "5.13.2Integer literals[lex.icon]")
[*binary-literal*](#nt:binary-literal "5.13.2Integer literals[lex.icon]") 'opt [*binary-digit*](#nt:binary-digit "5.13.2Integer literals[lex.icon]")
[octal-literal:](#nt:octal-literal "5.13.2Integer literals[lex.icon]")
0
[*octal-literal*](#nt:octal-literal "5.13.2Integer literals[lex.icon]") 'opt [*octal-digit*](#nt:octal-digit "5.13.2Integer literals[lex.icon]")
[decimal-literal:](#nt:decimal-literal "5.13.2Integer literals[lex.icon]")
[*nonzero-digit*](#nt:nonzero-digit "5.13.2Integer literals[lex.icon]")
[*decimal-literal*](#nt:decimal-literal "5.13.2Integer literals[lex.icon]") 'opt [*digit*](lex.name#nt:digit "5.11Identifiers[lex.name]")
[hexadecimal-literal:](#nt:hexadecimal-literal "5.13.2Integer literals[lex.icon]")
[*hexadecimal-prefix*](#nt:hexadecimal-prefix "5.13.2Integer literals[lex.icon]") [*hexadecimal-digit-sequence*](#nt:hexadecimal-digit-sequence "5.13.2Integer literals[lex.icon]")
[binary-digit:](#nt:binary-digit "5.13.2Integer literals[lex.icon]") one of
0 1
[octal-digit:](#nt:octal-digit "5.13.2Integer literals[lex.icon]") one of
0 1 2 3 4 5 6 7
[nonzero-digit:](#nt:nonzero-digit "5.13.2Integer literals[lex.icon]") one of
1 2 3 4 5 6 7 8 9
[hexadecimal-prefix:](#nt:hexadecimal-prefix "5.13.2Integer literals[lex.icon]") one of
0x 0X
[hexadecimal-digit-sequence:](#nt:hexadecimal-digit-sequence "5.13.2Integer literals[lex.icon]")
[*hexadecimal-digit*](#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]")
[*hexadecimal-digit-sequence*](#nt:hexadecimal-digit-sequence "5.13.2Integer literals[lex.icon]") 'opt [*hexadecimal-digit*](#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]")
[hexadecimal-digit:](#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]") one of
0 1 2 3 4 5 6 7 8 9
a b c d e f
A B C D E F
[integer-suffix:](#nt:integer-suffix "5.13.2Integer literals[lex.icon]")
[*unsigned-suffix*](#nt:unsigned-suffix "5.13.2Integer literals[lex.icon]") [*long-suffix*](#nt:long-suffix "5.13.2Integer literals[lex.icon]")opt
[*unsigned-suffix*](#nt:unsigned-suffix "5.13.2Integer literals[lex.icon]") [*long-long-suffix*](#nt:long-long-suffix "5.13.2Integer literals[lex.icon]")opt
[*unsigned-suffix*](#nt:unsigned-suffix "5.13.2Integer literals[lex.icon]") [*size-suffix*](#nt:size-suffix "5.13.2Integer literals[lex.icon]")opt
[*long-suffix*](#nt:long-suffix "5.13.2Integer literals[lex.icon]") [*unsigned-suffix*](#nt:unsigned-suffix "5.13.2Integer literals[lex.icon]")opt
[*long-long-suffix*](#nt:long-long-suffix "5.13.2Integer literals[lex.icon]") [*unsigned-suffix*](#nt:unsigned-suffix "5.13.2Integer literals[lex.icon]")opt
[*size-suffix*](#nt:size-suffix "5.13.2Integer literals[lex.icon]") [*unsigned-suffix*](#nt:unsigned-suffix "5.13.2Integer literals[lex.icon]")opt
[unsigned-suffix:](#nt:unsigned-suffix "5.13.2Integer literals[lex.icon]") one of
u U
[long-suffix:](#nt:long-suffix "5.13.2Integer literals[lex.icon]") one of
l L
[long-long-suffix:](#nt:long-long-suffix "5.13.2Integer literals[lex.icon]") one of
ll LL
[size-suffix:](#nt:size-suffix "5.13.2Integer literals[lex.icon]") one of
z Z
[1](#lex.icon-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1268)
In an [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]"),
the sequence of[*binary-digit*](#nt:binary-digit "5.13.2Integer literals[lex.icon]")*s*,[*octal-digit*](#nt:octal-digit "5.13.2Integer literals[lex.icon]")*s*,[*digit*](lex.name#nt:digit "5.11Identifiers[lex.name]")*s*, or[*hexadecimal-digit*](#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]")*s* is interpreted as a base N integer as shown in Table [7](#tab:lex.icon.base "Table 7: Base of integer-literals");
the lexically first digit of the sequence of digits is the most significant[.](#lex.icon-1.sentence-1)
[*Note [1](#lex.icon-note-1)*:
The prefix and any optional separating single quotes are ignored
when determining the value[.](#lex.icon-1.sentence-2)
— *end note*]
Table [7](#tab:lex.icon.base) — Base of [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]")*s* [[tab:lex.icon.base]](./tab:lex.icon.base)
| [🔗](#tab:lex.icon.base-row-1)<br>**Kind of [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]")** | **base N** |
| --- | --- |
| [🔗](#tab:lex.icon.base-row-2)<br>[*binary-literal*](#nt:binary-literal "5.13.2Integer literals[lex.icon]") | 2 |
| [🔗](#tab:lex.icon.base-row-3)<br>[*octal-literal*](#nt:octal-literal "5.13.2Integer literals[lex.icon]") | 8 |
| [🔗](#tab:lex.icon.base-row-4)<br>[*decimal-literal*](#nt:decimal-literal "5.13.2Integer literals[lex.icon]") | 10 |
| [🔗](#tab:lex.icon.base-row-5)<br>[*hexadecimal-literal*](#nt:hexadecimal-literal "5.13.2Integer literals[lex.icon]") | 16 |
[2](#lex.icon-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1297)
The [*hexadecimal-digit*](#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]")*s*a through f and A through F have decimal values ten through fifteen[.](#lex.icon-2.sentence-1)
[*Example [1](#lex.icon-example-1)*:
The number twelve can be written 12, 014,0XC, or 0b1100[.](#lex.icon-2.sentence-2)
The [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]")*s* 1048576,1'048'576, 0X100000, 0x10'0000, and0'004'000'000 all have the same value[.](#lex.icon-2.sentence-3)
— *end example*]
[3](#lex.icon-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1308)
The type of an [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]") is
the first type in the list in Table [8](#tab:lex.icon.type "Table 8: Types of integer-literals") corresponding to its optional [*integer-suffix*](#nt:integer-suffix "5.13.2Integer literals[lex.icon]") in which its value can be represented[.](#lex.icon-3.sentence-1)
Table [8](#tab:lex.icon.type) — Types of [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]")*s* [[tab:lex.icon.type]](./tab:lex.icon.type)
| [🔗](#tab:lex.icon.type-row-1)<br>**[*integer-suffix*](#nt:integer-suffix "5.13.2Integer literals[lex.icon]")** | **[*decimal-literal*](#nt:decimal-literal "5.13.2Integer literals[lex.icon]")** | **[*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]") other than [*decimal-literal*](#nt:decimal-literal "5.13.2Integer literals[lex.icon]")** |
| --- | --- | --- |
| [🔗](#tab:lex.icon.type-row-2)<br>none | int | int |
| [🔗](#tab:lex.icon.type-row-3) | long int | unsigned int |
| [🔗](#tab:lex.icon.type-row-4) | long long int | long int |
| [🔗](#tab:lex.icon.type-row-5) | | unsigned long int |
| [🔗](#tab:lex.icon.type-row-6) | | long long int |
| [🔗](#tab:lex.icon.type-row-7) | | unsigned long long int |
| [🔗](#tab:lex.icon.type-row-8)<br>u or U | unsigned int | unsigned int |
| [🔗](#tab:lex.icon.type-row-9) | unsigned long int | unsigned long int |
| [🔗](#tab:lex.icon.type-row-10) | unsigned long long int | unsigned long long int |
| [🔗](#tab:lex.icon.type-row-11)<br>l or L | long int | long int |
| [🔗](#tab:lex.icon.type-row-12) | long long int | unsigned long int |
| [🔗](#tab:lex.icon.type-row-13) | | long long int |
| [🔗](#tab:lex.icon.type-row-14) | | unsigned long long int |
| [🔗](#tab:lex.icon.type-row-15)<br>Both u or U | unsigned long int | unsigned long int |
| [🔗](#tab:lex.icon.type-row-16)<br>and l or L | unsigned long long int | unsigned long long int |
| [🔗](#tab:lex.icon.type-row-17)<br>ll or LL | long long int | long long int |
| [🔗](#tab:lex.icon.type-row-18) | | unsigned long long int |
| [🔗](#tab:lex.icon.type-row-19)<br>Both u or U | unsigned long long int | unsigned long long int |
| [🔗](#tab:lex.icon.type-row-20)<br>and ll or LL | | |
| [🔗](#tab:lex.icon.type-row-21)<br>z or Z | the signed integer type corresponding | the signed integer type |
| [🔗](#tab:lex.icon.type-row-22) | to std::size_t ([[support.types.layout]](support.types.layout "17.2.4Sizes, alignments, and offsets")) | corresponding to std::size_t |
| [🔗](#tab:lex.icon.type-row-23) | | std::size_t |
| [🔗](#tab:lex.icon.type-row-24)<br>Both u or U | std::size_t | std::size_t |
| [🔗](#tab:lex.icon.type-row-25)<br>and z or Z | | |
[4](#lex.icon-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1399)
Except for [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]")*s* containing
a [*size-suffix*](#nt:size-suffix "5.13.2Integer literals[lex.icon]"),
if the value of an [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]") cannot be represented by any type in its list and
an extended integer type ([[basic.fundamental]](basic.fundamental "6.9.2Fundamental types")) can represent its value,
it may have that extended integer type[.](#lex.icon-4.sentence-1)
If all of the types in the list for the [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]") are signed,
the extended integer type is signed[.](#lex.icon-4.sentence-2)
If all of the types in the list for the [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]") are unsigned,
the extended integer type is unsigned[.](#lex.icon-4.sentence-3)
If the list contains both signed and unsigned types,
the extended integer type may be signed or unsigned[.](#lex.icon-4.sentence-4)
If an [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]") cannot be represented by any of the allowed types,
the program is ill-formed[.](#lex.icon-4.sentence-5)
[*Note [2](#lex.icon-note-2)*:
An [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]") with a z or Z suffix
is ill-formed if it cannot be represented by std::size_t[.](#lex.icon-4.sentence-6)
— *end note*]
### [5.13.3](#lex.ccon) Character literals [[lex.ccon]](lex.ccon)
[character-literal:](#nt:character-literal "5.13.3Character literals[lex.ccon]")
[*encoding-prefix*](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]")opt ' [*c-char-sequence*](#nt:c-char-sequence "5.13.3Character literals[lex.ccon]") '
[encoding-prefix:](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]") one of
u8 u U L
[c-char-sequence:](#nt:c-char-sequence "5.13.3Character literals[lex.ccon]")
[*c-char*](#nt:c-char "5.13.3Character literals[lex.ccon]") [*c-char-sequence*](#nt:c-char-sequence "5.13.3Character literals[lex.ccon]")opt
[c-char:](#nt:c-char "5.13.3Character literals[lex.ccon]")
[*basic-c-char*](#nt:basic-c-char "5.13.3Character literals[lex.ccon]")
[*escape-sequence*](#nt:escape-sequence "5.13.3Character literals[lex.ccon]")
[*universal-character-name*](lex.universal.char#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]")
[basic-c-char:](#nt:basic-c-char "5.13.3Character literals[lex.ccon]")
any member of the translation character set except the U+0027 apostrophe,
U+005c reverse solidus, or new-line character
[escape-sequence:](#nt:escape-sequence "5.13.3Character literals[lex.ccon]")
[*simple-escape-sequence*](#nt:simple-escape-sequence "5.13.3Character literals[lex.ccon]")
[*numeric-escape-sequence*](#nt:numeric-escape-sequence "5.13.3Character literals[lex.ccon]")
[*conditional-escape-sequence*](#nt:conditional-escape-sequence "5.13.3Character literals[lex.ccon]")
[simple-escape-sequence:](#nt:simple-escape-sequence "5.13.3Character literals[lex.ccon]")
\ [*simple-escape-sequence-char*](#nt:simple-escape-sequence-char "5.13.3Character literals[lex.ccon]")
[simple-escape-sequence-char:](#nt:simple-escape-sequence-char "5.13.3Character literals[lex.ccon]") one of
' " ? \ a b f n r t v
[numeric-escape-sequence:](#nt:numeric-escape-sequence "5.13.3Character literals[lex.ccon]")
[*octal-escape-sequence*](#nt:octal-escape-sequence "5.13.3Character literals[lex.ccon]")
[*hexadecimal-escape-sequence*](#nt:hexadecimal-escape-sequence "5.13.3Character literals[lex.ccon]")
[simple-octal-digit-sequence:](#nt:simple-octal-digit-sequence "5.13.3Character literals[lex.ccon]")
[*octal-digit*](#nt:octal-digit "5.13.2Integer literals[lex.icon]") [*simple-octal-digit-sequence*](#nt:simple-octal-digit-sequence "5.13.3Character literals[lex.ccon]")opt
[octal-escape-sequence:](#nt:octal-escape-sequence "5.13.3Character literals[lex.ccon]")
\ [*octal-digit*](#nt:octal-digit "5.13.2Integer literals[lex.icon]")
\ [*octal-digit*](#nt:octal-digit "5.13.2Integer literals[lex.icon]") [*octal-digit*](#nt:octal-digit "5.13.2Integer literals[lex.icon]")
\ [*octal-digit*](#nt:octal-digit "5.13.2Integer literals[lex.icon]") [*octal-digit*](#nt:octal-digit "5.13.2Integer literals[lex.icon]") [*octal-digit*](#nt:octal-digit "5.13.2Integer literals[lex.icon]")
\o{ [*simple-octal-digit-sequence*](#nt:simple-octal-digit-sequence "5.13.3Character literals[lex.ccon]") }
[hexadecimal-escape-sequence:](#nt:hexadecimal-escape-sequence "5.13.3Character literals[lex.ccon]")
\x [*simple-hexadecimal-digit-sequence*](lex.universal.char#nt:simple-hexadecimal-digit-sequence "5.3.2Universal character names[lex.universal.char]")
\x{ [*simple-hexadecimal-digit-sequence*](lex.universal.char#nt:simple-hexadecimal-digit-sequence "5.3.2Universal character names[lex.universal.char]") }
[conditional-escape-sequence:](#nt:conditional-escape-sequence "5.13.3Character literals[lex.ccon]")
\ [*conditional-escape-sequence-char*](#nt:conditional-escape-sequence-char "5.13.3Character literals[lex.ccon]")
[conditional-escape-sequence-char:](#nt:conditional-escape-sequence-char "5.13.3Character literals[lex.ccon]")
any member of the basic character set that is not an [*octal-digit*](#nt:octal-digit "5.13.2Integer literals[lex.icon]"), a [*simple-escape-sequence-char*](#nt:simple-escape-sequence-char "5.13.3Character literals[lex.ccon]"), or the characters N, o, u, U, or x
[1](#lex.ccon-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1505)
A [*multicharacter literal*](#def:literal,multicharacter "5.13.3Character literals[lex.ccon]") is a [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]") whose [*c-char-sequence*](#nt:c-char-sequence "5.13.3Character literals[lex.ccon]") consists of
more than one [*c-char*](#nt:c-char "5.13.3Character literals[lex.ccon]")[.](#lex.ccon-1.sentence-1)
A multicharacter literal shall not have an [*encoding-prefix*](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]")[.](#lex.ccon-1.sentence-2)
If a multicharacter literal contains a [*c-char*](#nt:c-char "5.13.3Character literals[lex.ccon]") that is not encodable as a single code unit in the ordinary literal encoding,
the program is ill-formed[.](#lex.ccon-1.sentence-3)
Multicharacter literals are conditionally-supported[.](#lex.ccon-1.sentence-4)
[2](#lex.ccon-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1525)
The kind of a [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]"),
its type, and its associated character encoding ([[lex.charset]](lex.charset "5.3.1Character sets"))
are determined by
its [*encoding-prefix*](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]") and its [*c-char-sequence*](#nt:c-char-sequence "5.13.3Character literals[lex.ccon]") as defined by Table [9](#tab:lex.ccon.literal "Table 9: Character literals")[.](#lex.ccon-2.sentence-1)
Table [9](#tab:lex.ccon.literal) — Character literals [[tab:lex.ccon.literal]](./tab:lex.ccon.literal)
| [🔗](#tab:lex.ccon.literal-row-1)<br>**Encoding** | **Kind** | **Type** | **Associated char-** | **Example** |
| --- | --- | --- | --- | --- |
| [🔗](#tab:lex.ccon.literal-row-2)<br>**prefix** | | | **acter encoding** | |
| [🔗](#tab:lex.ccon.literal-row-3)<br>none | [*ordinary character literal*](#def:literal,character,ordinary "5.13.3Character literals[lex.ccon]") | char | ordinary literal | 'v' |
| [🔗](#tab:lex.ccon.literal-row-4)<br> | multicharacter literal | int | encoding | 'abcd' |
| [🔗](#tab:lex.ccon.literal-row-5)<br>L | [*wide character literal*](#def:literal,character,wide "5.13.3Character literals[lex.ccon]") | wchar_t | wide literal | L'w' |
| [🔗](#tab:lex.ccon.literal-row-6) | | | encoding | |
| [🔗](#tab:lex.ccon.literal-row-7)<br>u8 | [*UTF-8 character literal*](#def:literal,character,UTF-8 "5.13.3Character literals[lex.ccon]") | char8_t | UTF-8 | u8'x' |
| [🔗](#tab:lex.ccon.literal-row-8)<br>u | [*UTF-16 character literal*](#def:literal,character,UTF-16 "5.13.3Character literals[lex.ccon]") | char16_t | UTF-16 | u'y' |
| [🔗](#tab:lex.ccon.literal-row-9)<br>U | [*UTF-32 character literal*](#def:literal,character,UTF-32 "5.13.3Character literals[lex.ccon]") | char32_t | UTF-32 | U'z' |
[3](#lex.ccon-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1571)
In translation phase 4,
the value of a [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]") is determined
using the range of representable values
of the [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]")'s type in translation phase 7[.](#lex.ccon-3.sentence-1)
A multicharacter literal has animplementation-defined
value[.](#lex.ccon-3.sentence-2)
The value of any other kind of [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]") is determined as follows:
- [(3.1)](#lex.ccon-3.1)
A [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]") with
a [*c-char-sequence*](#nt:c-char-sequence "5.13.3Character literals[lex.ccon]") consisting of a single[*basic-c-char*](#nt:basic-c-char "5.13.3Character literals[lex.ccon]"),[*simple-escape-sequence*](#nt:simple-escape-sequence "5.13.3Character literals[lex.ccon]"), or[*universal-character-name*](lex.universal.char#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]") is the code unit value of the specified character
as encoded in the literal's associated character encoding[.](#lex.ccon-3.1.sentence-1)
If the specified character lacks
representation in the literal's associated character encoding or
if it cannot be encoded as a single code unit,
then the program is ill-formed[.](#lex.ccon-3.1.sentence-2)
- [(3.2)](#lex.ccon-3.2)
A [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]") with
a [*c-char-sequence*](#nt:c-char-sequence "5.13.3Character literals[lex.ccon]") consisting of
a single [*numeric-escape-sequence*](#nt:numeric-escape-sequence "5.13.3Character literals[lex.ccon]") has a value as follows:
* [(3.2.1)](#lex.ccon-3.2.1)
Let v be the integer value represented by
the octal number comprising
the sequence of [*octal-digit*](#nt:octal-digit "5.13.2Integer literals[lex.icon]")*s* in
an [*octal-escape-sequence*](#nt:octal-escape-sequence "5.13.3Character literals[lex.ccon]") or by
the hexadecimal number comprising
the sequence of [*hexadecimal-digit*](#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]")*s* in
a [*hexadecimal-escape-sequence*](#nt:hexadecimal-escape-sequence "5.13.3Character literals[lex.ccon]")[.](#lex.ccon-3.2.1.sentence-1)
* [(3.2.2)](#lex.ccon-3.2.2)
If v does not exceed
the range of representable values of the [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]")'s type,
then the value is v[.](#lex.ccon-3.2.2.sentence-1)
* [(3.2.3)](#lex.ccon-3.2.3)
Otherwise,
if the [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]")'s [*encoding-prefix*](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]") is absent or L, andv does not exceed the range of representable values of the corresponding unsigned type for the underlying type of the [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]")'s type,
then the value is the unique value of the [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]")'s type T that is congruent to v modulo 2N, where N is the width of T[.](#lex.ccon-3.2.3.sentence-1)
* [(3.2.4)](#lex.ccon-3.2.4)
Otherwise, the program is ill-formed[.](#lex.ccon-3.2.4.sentence-1)
- [(3.3)](#lex.ccon-3.3)
A [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]") with
a [*c-char-sequence*](#nt:c-char-sequence "5.13.3Character literals[lex.ccon]") consisting of
a single [*conditional-escape-sequence*](#nt:conditional-escape-sequence "5.13.3Character literals[lex.ccon]") is conditionally-supported and
has an implementation-defined value[.](#lex.ccon-3.3.sentence-1)
[4](#lex.ccon-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1629)
The character specified by a [*simple-escape-sequence*](#nt:simple-escape-sequence "5.13.3Character literals[lex.ccon]") is specified in Table [10](#tab:lex.ccon.esc "Table 10: Simple escape sequences")[.](#lex.ccon-4.sentence-1)
[*Note [1](#lex.ccon-note-1)*:
Using an escape sequence for a question mark
is supported for compatibility with C++ 2014 and C[.](#lex.ccon-4.sentence-2)
— *end note*]
Table [10](#tab:lex.ccon.esc) — Simple escape sequences [[tab:lex.ccon.esc]](./tab:lex.ccon.esc)
| [🔗](#tab:lex.ccon.esc-row-1)<br>**character** | | **[*simple-escape-sequence*](#nt:simple-escape-sequence "5.13.3Character literals[lex.ccon]")** |
| --- | --- | --- |
| [🔗](#tab:lex.ccon.esc-row-2)<br>U+000a | line feed | \n |
| [🔗](#tab:lex.ccon.esc-row-3)<br>U+0009 | character tabulation | \t |
| [🔗](#tab:lex.ccon.esc-row-4)<br>U+000b | line tabulation | \v |
| [🔗](#tab:lex.ccon.esc-row-5)<br>U+0008 | backspace | \b |
| [🔗](#tab:lex.ccon.esc-row-6)<br>U+000d | carriage return | \r |
| [🔗](#tab:lex.ccon.esc-row-7)<br>U+000c | form feed | \f |
| [🔗](#tab:lex.ccon.esc-row-8)<br>U+0007 | alert | \a |
| [🔗](#tab:lex.ccon.esc-row-9)<br>U+005c | reverse solidus | \\ |
| [🔗](#tab:lex.ccon.esc-row-10)<br>U+003f | question mark | \? |
| [🔗](#tab:lex.ccon.esc-row-11)<br>U+0027 | apostrophe | \' |
| [🔗](#tab:lex.ccon.esc-row-12)<br>U+0022 | quotation mark | \" |
### [5.13.4](#lex.fcon) Floating-point literals [[lex.fcon]](lex.fcon)
[floating-point-literal:](#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]")
[*decimal-floating-point-literal*](#nt:decimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]")
[*hexadecimal-floating-point-literal*](#nt:hexadecimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]")
[decimal-floating-point-literal:](#nt:decimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]")
[*fractional-constant*](#nt:fractional-constant "5.13.4Floating-point literals[lex.fcon]") [*exponent-part*](#nt:exponent-part "5.13.4Floating-point literals[lex.fcon]")opt [*floating-point-suffix*](#nt:floating-point-suffix "5.13.4Floating-point literals[lex.fcon]")opt
[*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]") [*exponent-part*](#nt:exponent-part "5.13.4Floating-point literals[lex.fcon]") [*floating-point-suffix*](#nt:floating-point-suffix "5.13.4Floating-point literals[lex.fcon]")opt
[hexadecimal-floating-point-literal:](#nt:hexadecimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]")
[*hexadecimal-prefix*](#nt:hexadecimal-prefix "5.13.2Integer literals[lex.icon]") [*hexadecimal-fractional-constant*](#nt:hexadecimal-fractional-constant "5.13.4Floating-point literals[lex.fcon]") [*binary-exponent-part*](#nt:binary-exponent-part "5.13.4Floating-point literals[lex.fcon]") [*floating-point-suffix*](#nt:floating-point-suffix "5.13.4Floating-point literals[lex.fcon]")opt
[*hexadecimal-prefix*](#nt:hexadecimal-prefix "5.13.2Integer literals[lex.icon]") [*hexadecimal-digit-sequence*](#nt:hexadecimal-digit-sequence "5.13.2Integer literals[lex.icon]") [*binary-exponent-part*](#nt:binary-exponent-part "5.13.4Floating-point literals[lex.fcon]") [*floating-point-suffix*](#nt:floating-point-suffix "5.13.4Floating-point literals[lex.fcon]")opt
[fractional-constant:](#nt:fractional-constant "5.13.4Floating-point literals[lex.fcon]")
[*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]")opt . [*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]")
[*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]") .
[hexadecimal-fractional-constant:](#nt:hexadecimal-fractional-constant "5.13.4Floating-point literals[lex.fcon]")
[*hexadecimal-digit-sequence*](#nt:hexadecimal-digit-sequence "5.13.2Integer literals[lex.icon]")opt . [*hexadecimal-digit-sequence*](#nt:hexadecimal-digit-sequence "5.13.2Integer literals[lex.icon]")
[*hexadecimal-digit-sequence*](#nt:hexadecimal-digit-sequence "5.13.2Integer literals[lex.icon]") .
[exponent-part:](#nt:exponent-part "5.13.4Floating-point literals[lex.fcon]")
e [*sign*](#nt:sign "5.13.4Floating-point literals[lex.fcon]")opt [*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]")
E [*sign*](#nt:sign "5.13.4Floating-point literals[lex.fcon]")opt [*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]")
[binary-exponent-part:](#nt:binary-exponent-part "5.13.4Floating-point literals[lex.fcon]")
p [*sign*](#nt:sign "5.13.4Floating-point literals[lex.fcon]")opt [*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]")
P [*sign*](#nt:sign "5.13.4Floating-point literals[lex.fcon]")opt [*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]")
[sign:](#nt:sign "5.13.4Floating-point literals[lex.fcon]") one of
+ -
[digit-sequence:](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]")
[*digit*](lex.name#nt:digit "5.11Identifiers[lex.name]")
[*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]") 'opt [*digit*](lex.name#nt:digit "5.11Identifiers[lex.name]")
[floating-point-suffix:](#nt:floating-point-suffix "5.13.4Floating-point literals[lex.fcon]") one of
f l f16 f32 f64 f128 bf16 F L F16 F32 F64 F128 BF16
[1](#lex.fcon-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1718)
The type of
a [*floating-point-literal*](#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]") ([[basic.fundamental]](basic.fundamental "6.9.2Fundamental types"), [[basic.extended.fp]](basic.extended.fp "6.9.3Optional extended floating-point types"))
is determined by
its [*floating-point-suffix*](#nt:floating-point-suffix "5.13.4Floating-point literals[lex.fcon]") as specified in Table [11](#tab:lex.fcon.type "Table 11: Types of floating-point-literals")[.](#lex.fcon-1.sentence-1)
[*Note [1](#lex.fcon-note-1)*:
The floating-point suffixesf16, f32, f64, f128, bf16,F16, F32, F64, F128, and BF16 are conditionally-supported[.](#lex.fcon-1.sentence-2)
See [[basic.extended.fp]](basic.extended.fp "6.9.3Optional extended floating-point types")[.](#lex.fcon-1.sentence-3)
— *end note*]
Table [11](#tab:lex.fcon.type) — Types of [*floating-point-literal*](#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]")*s* [[tab:lex.fcon.type]](./tab:lex.fcon.type)
| [🔗](#tab:lex.fcon.type-row-1)<br>**[*floating-point-suffix*](#nt:floating-point-suffix "5.13.4Floating-point literals[lex.fcon]")** | **type** |
| --- | --- |
| [🔗](#tab:lex.fcon.type-row-2)<br>none | double |
| [🔗](#tab:lex.fcon.type-row-3)<br>f or F | float |
| [🔗](#tab:lex.fcon.type-row-4)<br>l or L | long double |
| [🔗](#tab:lex.fcon.type-row-5)<br>f16 or F16 | std::float16_t |
| [🔗](#tab:lex.fcon.type-row-6)<br>f32 or F32 | std::float32_t |
| [🔗](#tab:lex.fcon.type-row-7)<br>f64 or F64 | std::float64_t |
| [🔗](#tab:lex.fcon.type-row-8)<br>f128 or F128 | std::float128_t |
| [🔗](#tab:lex.fcon.type-row-9)<br>bf16 or BF16 | std::bfloat16_t |
[2](#lex.fcon-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1752)
The [*significand*](#def:significand "5.13.4Floating-point literals[lex.fcon]") of a [*floating-point-literal*](#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]") is the [*fractional-constant*](#nt:fractional-constant "5.13.4Floating-point literals[lex.fcon]") or [*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]") of a [*decimal-floating-point-literal*](#nt:decimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]") or the [*hexadecimal-fractional-constant*](#nt:hexadecimal-fractional-constant "5.13.4Floating-point literals[lex.fcon]") or [*hexadecimal-digit-sequence*](#nt:hexadecimal-digit-sequence "5.13.2Integer literals[lex.icon]") of a [*hexadecimal-floating-point-literal*](#nt:hexadecimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]")[.](#lex.fcon-2.sentence-1)
In the significand,
the sequence of [*digit*](lex.name#nt:digit "5.11Identifiers[lex.name]")*s* or [*hexadecimal-digit*](#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]")*s* and optional period are interpreted as a base N real number s,
where N is 10 for a [*decimal-floating-point-literal*](#nt:decimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]") and
16 for a [*hexadecimal-floating-point-literal*](#nt:hexadecimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]")[.](#lex.fcon-2.sentence-2)
[*Note [2](#lex.fcon-note-2)*:
Any optional separating single quotes are ignored when determining the value[.](#lex.fcon-2.sentence-3)
— *end note*]
If an [*exponent-part*](#nt:exponent-part "5.13.4Floating-point literals[lex.fcon]") or [*binary-exponent-part*](#nt:binary-exponent-part "5.13.4Floating-point literals[lex.fcon]") is present,
the exponent e of the [*floating-point-literal*](#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]") is the result of interpreting
the sequence of an optional [*sign*](#nt:sign "5.13.4Floating-point literals[lex.fcon]") and the [*digit*](lex.name#nt:digit "5.11Identifiers[lex.name]")*s* as a base 10 integer[.](#lex.fcon-2.sentence-4)
Otherwise, the exponent e is 0[.](#lex.fcon-2.sentence-5)
The scaled value of the literal iss×10e for a [*decimal-floating-point-literal*](#nt:decimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]") ands×2e for a [*hexadecimal-floating-point-literal*](#nt:hexadecimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]")[.](#lex.fcon-2.sentence-6)
[*Example [1](#lex.fcon-example-1)*:
The [*floating-point-literal*](#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]")*s*49.625 and 0xC.68p+2 have the same value[.](#lex.fcon-2.sentence-7)
The [*floating-point-literal*](#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]")*s*1.602'176'565e-19 and 1.602176565e-19 have the same value[.](#lex.fcon-2.sentence-8)
— *end example*]
[3](#lex.fcon-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1786)
If the scaled value is not in the range of representable
values for its type, the program is ill-formed[.](#lex.fcon-3.sentence-1)
Otherwise, the value of a [*floating-point-literal*](#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]") is the scaled value if representable,
else the larger or smaller representable value nearest the scaled value,
chosen in an implementation-defined manner[.](#lex.fcon-3.sentence-2)
### [5.13.5](#lex.string) String literals [[lex.string]](lex.string)
[string-literal:](#nt:string-literal "5.13.5String literals[lex.string]")
[*encoding-prefix*](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]")opt " [*s-char-sequence*](#nt:s-char-sequence "5.13.5String literals[lex.string]")opt "
[*encoding-prefix*](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]")opt R [*raw-string*](#nt:raw-string "5.13.5String literals[lex.string]")
[s-char-sequence:](#nt:s-char-sequence "5.13.5String literals[lex.string]")
[*s-char*](#nt:s-char "5.13.5String literals[lex.string]") [*s-char-sequence*](#nt:s-char-sequence "5.13.5String literals[lex.string]")opt
[s-char:](#nt:s-char "5.13.5String literals[lex.string]")
[*basic-s-char*](#nt:basic-s-char "5.13.5String literals[lex.string]")
[*escape-sequence*](#nt:escape-sequence "5.13.3Character literals[lex.ccon]")
[*universal-character-name*](lex.universal.char#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]")
[basic-s-char:](#nt:basic-s-char "5.13.5String literals[lex.string]")
any member of the translation character set except the U+0022 quotation mark,
U+005c reverse solidus, or new-line character
[raw-string:](#nt:raw-string "5.13.5String literals[lex.string]")
" [*d-char-sequence*](#nt:d-char-sequence "5.13.5String literals[lex.string]")opt ( [*r-char-sequence*](#nt:r-char-sequence "5.13.5String literals[lex.string]")opt ) [*d-char-sequence*](#nt:d-char-sequence "5.13.5String literals[lex.string]")opt "
[r-char-sequence:](#nt:r-char-sequence "5.13.5String literals[lex.string]")
[*r-char*](#nt:r-char "5.13.5String literals[lex.string]") [*r-char-sequence*](#nt:r-char-sequence "5.13.5String literals[lex.string]")opt
[r-char:](#nt:r-char "5.13.5String literals[lex.string]")
any member of the translation character set, except a U+0029 right parenthesis followed by
the initial [*d-char-sequence*](#nt:d-char-sequence "5.13.5String literals[lex.string]") (which may be empty) followed by a U+0022 quotation mark
[d-char-sequence:](#nt:d-char-sequence "5.13.5String literals[lex.string]")
[*d-char*](#nt:d-char "5.13.5String literals[lex.string]") [*d-char-sequence*](#nt:d-char-sequence "5.13.5String literals[lex.string]")opt
[d-char:](#nt:d-char "5.13.5String literals[lex.string]")
any member of the basic character set except:
U+0020 space, U+0028 left parenthesis, U+0029 right parenthesis, U+005c reverse solidus,
U+0009 character tabulation, U+000b line tabulation, U+000c form feed, and new-line
[1](#lex.string-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1850)
The kind of a [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]"),
its type, and
its associated character encoding ([[lex.charset]](lex.charset "5.3.1Character sets"))
are determined by its encoding prefix and sequence of[*s-char*](#nt:s-char "5.13.5String literals[lex.string]")*s* or [*r-char*](#nt:r-char "5.13.5String literals[lex.string]")*s* as defined by Table [12](#tab:lex.string.literal "Table 12: String literals") where n is the number of encoded code units
that would result from an evaluation of the [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]") (see below)[.](#lex.string-1.sentence-1)
Table [12](#tab:lex.string.literal) — String literals [[tab:lex.string.literal]](./tab:lex.string.literal)
| [🔗](#tab:lex.string.literal-row-1)<br>**Enco-** | **Kind** | **Type** | **Associated** | **Examples** |
| --- | --- | --- | --- | --- |
| [🔗](#tab:lex.string.literal-row-2)<br>**ding** | | | **character** | |
| [🔗](#tab:lex.string.literal-row-3)<br>**prefix** | | | **encoding** | |
| [🔗](#tab:lex.string.literal-row-4)<br>none | [*ordinary string literal*](#def:literal,string,ordinary "5.13.5String literals[lex.string]") | array of n const char | ordinary literal encoding | "ordinary string" R"(ordinary raw string)" |
| [🔗](#tab:lex.string.literal-row-5)<br>L | [*wide string literal*](#def:literal,string,wide "5.13.5String literals[lex.string]") | array of n const wchar_t | wide literal encoding | L"wide string" LR"w(wide raw string)w" |
| [🔗](#tab:lex.string.literal-row-6)<br>u8 | [*UTF-8 string literal*](#def:literal,string,UTF-8 "5.13.5String literals[lex.string]") | array of n const char8_t | UTF-8 | u8"UTF-8 string" u8R"x(UTF-8 raw string)x" |
| [🔗](#tab:lex.string.literal-row-7)<br>u | [*UTF-16 string literal*](#def:literal,string,UTF-16 "5.13.5String literals[lex.string]") | array of n const char16_t | UTF-16 | u"UTF-16 string" uR"y(UTF-16 raw string)y" |
| [🔗](#tab:lex.string.literal-row-8)<br>U | [*UTF-32 string literal*](#def:literal,string,UTF-32 "5.13.5String literals[lex.string]") | array of n const char32_t | UTF-32 | U"UTF-32 string" UR"z(UTF-32 raw string)z" |
[2](#lex.string-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1909)
A [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]") that has an Rin the prefix is a [*raw string literal*](#def:raw_string_literal "5.13.5String literals[lex.string]")[.](#lex.string-2.sentence-1)
The[*d-char-sequence*](#nt:d-char-sequence "5.13.5String literals[lex.string]") serves as a delimiter[.](#lex.string-2.sentence-2)
The terminating[*d-char-sequence*](#nt:d-char-sequence "5.13.5String literals[lex.string]") of a [*raw-string*](#nt:raw-string "5.13.5String literals[lex.string]") is the same sequence of
characters as the initial [*d-char-sequence*](#nt:d-char-sequence "5.13.5String literals[lex.string]")[.](#lex.string-2.sentence-3)
A [*d-char-sequence*](#nt:d-char-sequence "5.13.5String literals[lex.string]") shall consist of at most 16 characters[.](#lex.string-2.sentence-4)
[3](#lex.string-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1919)
[*Note [1](#lex.string-note-1)*:
The characters '(' and ')' can appear in a[*raw-string*](#nt:raw-string "5.13.5String literals[lex.string]")[.](#lex.string-3.sentence-1)
Thus, R"delimiter((a|b))delimiter" is equivalent to"(a|b)"[.](#lex.string-3.sentence-2)
— *end note*]
[4](#lex.string-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1926)
[*Note [2](#lex.string-note-2)*:
A source-file new-line in a raw string literal results in a new-line in the
resulting execution string literal[.](#lex.string-4.sentence-1)
Assuming no
whitespace at the beginning of lines in the following example, the assert will succeed:const char* p = R"(a\
b
c)";
assert(std::strcmp(p, "a\\\nb\nc") == 0);
— *end note*]
[5](#lex.string-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1939)
[*Example [1](#lex.string-example-1)*:
The raw stringR"a(
)\
a"
)a" is equivalent to "\n)\\\na\"\n"[.](#lex.string-5.sentence-1)
The raw stringR"(x = "\"y\"")" is equivalent to "x = \"\\\"y\\\"\""[.](#lex.string-5.sentence-2)
— *end example*]
[6](#lex.string-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1955)
Ordinary string literals and UTF-8 string literals are
also referred to as [*narrow string literals*](#def:literal,string,narrow "5.13.5String literals[lex.string]")[.](#lex.string-6.sentence-1)
[7](#lex.string-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1960)
The [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")*s* in
any sequence of adjacent [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")*s* shall have at most one unique [*encoding-prefix*](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]") among them[.](#lex.string-7.sentence-1)
The common [*encoding-prefix*](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]") of the sequence is
that [*encoding-prefix*](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]"), if any[.](#lex.string-7.sentence-2)
[*Note [3](#lex.string-note-3)*:
A [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")'s rawness has
no effect on the determination of the common [*encoding-prefix*](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]")[.](#lex.string-7.sentence-3)
— *end note*]
[8](#lex.string-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1972)
In translation phase 6 ([[lex.phases]](lex.phases "5.2Phases of translation")),
adjacent [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")*s* are concatenated[.](#lex.string-8.sentence-1)
The lexical structure and grouping of
the contents of the individual [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")*s* is retained[.](#lex.string-8.sentence-2)
[*Example [2](#lex.string-example-2)*:
"\xA" "B" represents
the code unit '\xA' and the character 'B' after concatenation
(and not the single code unit '\xAB')[.](#lex.string-8.sentence-3)
Similarly,R"(\u00)" "41" represents six characters,
starting with a backslash and ending with the digit 1 (and not the single character 'A' specified by a [*universal-character-name*](lex.universal.char#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]"))[.](#lex.string-8.sentence-4)
Table [13](#tab:lex.string.concat "Table 13: String literal concatenations") has some examples of valid concatenations[.](#lex.string-8.sentence-5)
— *end example*]
Table [13](#tab:lex.string.concat) — String literal concatenations [[tab:lex.string.concat]](./tab:lex.string.concat)
| [🔗](#tab:lex.string.concat-row-1)<br>Source | | Means | Source | | Means | Source | | Means |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| [🔗](#tab:lex.string.concat-row-2)<br>u"a" | u"b" | u"ab" | U"a" | U"b" | U"ab" | L"a" | L"b" | L"ab" |
| [🔗](#tab:lex.string.concat-row-3)<br>u"a" | "b" | u"ab" | U"a" | "b" | U"ab" | L"a" | "b" | L"ab" |
| [🔗](#tab:lex.string.concat-row-4)<br>"a" | u"b" | u"ab" | "a" | U"b" | U"ab" | "a" | L"b" | L"ab" |
[9](#lex.string-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2017)
Evaluating a [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]") results in a string literal object
with static storage duration ([[basic.stc]](basic.stc "6.8.6Storage duration"))[.](#lex.string-9.sentence-1)
[*Note [4](#lex.string-note-4)*:
String literal objects are potentially non-unique ([[intro.object]](intro.object "6.8.2Object model"))[.](#lex.string-9.sentence-2)
Whether successive evaluations of a[*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]") yield the same or a different object is
unspecified[.](#lex.string-9.sentence-3)
— *end note*]
[*Note [5](#lex.string-note-5)*:
The effect of attempting to modify a string literal object is undefined[.](#lex.string-9.sentence-4)
— *end note*]
[10](#lex.string-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2031)
String literal objects are initialized with
the sequence of code unit values
corresponding to the [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")'s sequence of[*s-char*](#nt:s-char "5.13.5String literals[lex.string]")*s* (originally from non-raw string literals) and[*r-char*](#nt:r-char "5.13.5String literals[lex.string]")*s* (originally from raw string literals),
plus a terminating U+0000 null character,
in order as follows:
- [(10.1)](#lex.string-10.1)
The sequence of characters denoted by each contiguous sequence of[*basic-s-char*](#nt:basic-s-char "5.13.5String literals[lex.string]")*s*,[*r-char*](#nt:r-char "5.13.5String literals[lex.string]")*s*,[*simple-escape-sequence*](#nt:simple-escape-sequence "5.13.3Character literals[lex.ccon]")*s* ([[lex.ccon]](#lex.ccon "5.13.3Character literals")), and[*universal-character-name*](lex.universal.char#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]")*s* ([[lex.charset]](lex.charset "5.3.1Character sets"))
is encoded to a code unit sequence
using the [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")'s associated character encoding[.](#lex.string-10.1.sentence-1)
If a character lacks representation in the associated character encoding,
then the program is ill-formed[.](#lex.string-10.1.sentence-2)
[*Note [6](#lex.string-note-6)*:
No character lacks representation in any Unicode encoding form[.](#lex.string-10.1.sentence-3)
— *end note*]
When encoding a stateful character encoding,
implementations should encode the first such sequence
beginning with the initial encoding state and
encode subsequent sequences
beginning with the final encoding state of the prior sequence[.](#lex.string-10.1.sentence-4)
[*Note [7](#lex.string-note-7)*:
The encoded code unit sequence can differ from
the sequence of code units that would be obtained by
encoding each character independently[.](#lex.string-10.1.sentence-5)
— *end note*]
- [(10.2)](#lex.string-10.2)
Each [*numeric-escape-sequence*](#nt:numeric-escape-sequence "5.13.3Character literals[lex.ccon]") ([[lex.ccon]](#lex.ccon "5.13.3Character literals"))
contributes a single code unit with a value as follows:
* [(10.2.1)](#lex.string-10.2.1)
Let v be the integer value represented by
the octal number comprising
the sequence of [*octal-digit*](#nt:octal-digit "5.13.2Integer literals[lex.icon]")*s* in
an [*octal-escape-sequence*](#nt:octal-escape-sequence "5.13.3Character literals[lex.ccon]") or by
the hexadecimal number comprising
the sequence of [*hexadecimal-digit*](#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]")*s* in
a [*hexadecimal-escape-sequence*](#nt:hexadecimal-escape-sequence "5.13.3Character literals[lex.ccon]")[.](#lex.string-10.2.1.sentence-1)
* [(10.2.2)](#lex.string-10.2.2)
If v does not exceed the range of representable values of
the [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")'s array element type,
then the value is v[.](#lex.string-10.2.2.sentence-1)
* [(10.2.3)](#lex.string-10.2.3)
Otherwise,
if the [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")'s [*encoding-prefix*](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]") is absent or L, andv does not exceed the range of representable values of
the corresponding unsigned type for the underlying type of
the [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")'s array element type,
then the value is the unique value of
the [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")'s array element type T that is congruent to v modulo 2N, where N is the width of T[.](#lex.string-10.2.3.sentence-1)
* [(10.2.4)](#lex.string-10.2.4)
Otherwise, the program is ill-formed[.](#lex.string-10.2.4.sentence-1)
When encoding a stateful character encoding,
these sequences should have no effect on encoding state[.](#lex.string-10.2.sentence-2)
- [(10.3)](#lex.string-10.3)
Each [*conditional-escape-sequence*](#nt:conditional-escape-sequence "5.13.3Character literals[lex.ccon]") ([[lex.ccon]](#lex.ccon "5.13.3Character literals"))
contributes animplementation-defined
code unit sequence[.](#lex.string-10.3.sentence-1)
When encoding a stateful character encoding,
it isimplementation-defined
what effect these sequences have on encoding state[.](#lex.string-10.3.sentence-2)
### [5.13.6](#lex.string.uneval) Unevaluated strings [[lex.string.uneval]](lex.string.uneval)
[unevaluated-string:](#nt:unevaluated-string "5.13.6Unevaluated strings[lex.string.uneval]")
[*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")
[1](#lex.string.uneval-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2114)
An [*unevaluated-string*](#nt:unevaluated-string "5.13.6Unevaluated strings[lex.string.uneval]") shall have no [*encoding-prefix*](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]")[.](#lex.string.uneval-1.sentence-1)
[2](#lex.string.uneval-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2117)
Each [*universal-character-name*](lex.universal.char#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]") and each [*simple-escape-sequence*](#nt:simple-escape-sequence "5.13.3Character literals[lex.ccon]") in an [*unevaluated-string*](#nt:unevaluated-string "5.13.6Unevaluated strings[lex.string.uneval]") is
replaced by the member of the translation character set it denotes[.](#lex.string.uneval-2.sentence-1)
An [*unevaluated-string*](#nt:unevaluated-string "5.13.6Unevaluated strings[lex.string.uneval]") that contains
a [*numeric-escape-sequence*](#nt:numeric-escape-sequence "5.13.3Character literals[lex.ccon]") or
a [*conditional-escape-sequence*](#nt:conditional-escape-sequence "5.13.3Character literals[lex.ccon]") is ill-formed[.](#lex.string.uneval-2.sentence-2)
[3](#lex.string.uneval-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2125)
An [*unevaluated-string*](#nt:unevaluated-string "5.13.6Unevaluated strings[lex.string.uneval]") is never evaluated and
its interpretation depends on the context in which it appears[.](#lex.string.uneval-3.sentence-1)
### [5.13.7](#lex.bool) Boolean literals [[lex.bool]](lex.bool)
[boolean-literal:](#nt:boolean-literal "5.13.7Boolean literals[lex.bool]")
false
true
[1](#lex.bool-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2138)
The Boolean literals are the keywords false and true[.](#lex.bool-1.sentence-1)
Such literals have type bool[.](#lex.bool-1.sentence-2)
### [5.13.8](#lex.nullptr) Pointer literals [[lex.nullptr]](lex.nullptr)
[pointer-literal:](#nt:pointer-literal "5.13.8Pointer literals[lex.nullptr]")
nullptr
[1](#lex.nullptr-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2151)
The pointer literal is the keyword nullptr[.](#lex.nullptr-1.sentence-1)
It has typestd::nullptr_t[.](#lex.nullptr-1.sentence-2)
[*Note [1](#lex.nullptr-note-1)*:
std::nullptr_t is a distinct type that is neither a pointer type nor a pointer-to-member type;
rather, a prvalue of this type is a null pointer constant and can be
converted to a null pointer value or null member pointer value[.](#lex.nullptr-1.sentence-3)
See [[conv.ptr]](conv.ptr "7.3.12Pointer conversions") and [[conv.mem]](conv.mem "7.3.13Pointer-to-member conversions")[.](#lex.nullptr-1.sentence-4)
— *end note*]
### [5.13.9](#lex.ext) User-defined literals [[lex.ext]](lex.ext)
[user-defined-literal:](#nt:user-defined-literal "5.13.9User-defined literals[lex.ext]")
[*user-defined-integer-literal*](#nt:user-defined-integer-literal "5.13.9User-defined literals[lex.ext]")
[*user-defined-floating-point-literal*](#nt:user-defined-floating-point-literal "5.13.9User-defined literals[lex.ext]")
[*user-defined-string-literal*](#nt:user-defined-string-literal "5.13.9User-defined literals[lex.ext]")
[*user-defined-character-literal*](#nt:user-defined-character-literal "5.13.9User-defined literals[lex.ext]")
[user-defined-integer-literal:](#nt:user-defined-integer-literal "5.13.9User-defined literals[lex.ext]")
[*decimal-literal*](#nt:decimal-literal "5.13.2Integer literals[lex.icon]") [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[*octal-literal*](#nt:octal-literal "5.13.2Integer literals[lex.icon]") [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[*hexadecimal-literal*](#nt:hexadecimal-literal "5.13.2Integer literals[lex.icon]") [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[*binary-literal*](#nt:binary-literal "5.13.2Integer literals[lex.icon]") [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[user-defined-floating-point-literal:](#nt:user-defined-floating-point-literal "5.13.9User-defined literals[lex.ext]")
[*fractional-constant*](#nt:fractional-constant "5.13.4Floating-point literals[lex.fcon]") [*exponent-part*](#nt:exponent-part "5.13.4Floating-point literals[lex.fcon]")opt [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]") [*exponent-part*](#nt:exponent-part "5.13.4Floating-point literals[lex.fcon]") [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[*hexadecimal-prefix*](#nt:hexadecimal-prefix "5.13.2Integer literals[lex.icon]") [*hexadecimal-fractional-constant*](#nt:hexadecimal-fractional-constant "5.13.4Floating-point literals[lex.fcon]") [*binary-exponent-part*](#nt:binary-exponent-part "5.13.4Floating-point literals[lex.fcon]") [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[*hexadecimal-prefix*](#nt:hexadecimal-prefix "5.13.2Integer literals[lex.icon]") [*hexadecimal-digit-sequence*](#nt:hexadecimal-digit-sequence "5.13.2Integer literals[lex.icon]") [*binary-exponent-part*](#nt:binary-exponent-part "5.13.4Floating-point literals[lex.fcon]") [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[user-defined-string-literal:](#nt:user-defined-string-literal "5.13.9User-defined literals[lex.ext]")
[*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]") [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[user-defined-character-literal:](#nt:user-defined-character-literal "5.13.9User-defined literals[lex.ext]")
[*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]") [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[ud-suffix:](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[*identifier*](lex.name#nt:identifier "5.11Identifiers[lex.name]")
[1](#lex.ext-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2203)
If a token matches both [*user-defined-literal*](#nt:user-defined-literal "5.13.9User-defined literals[lex.ext]") and another [*literal*](#nt:literal "5.13.1Kinds of literals[lex.literal.kinds]") kind, it
is treated as the latter[.](#lex.ext-1.sentence-1)
[*Example [1](#lex.ext-example-1)*:
123_km is a [*user-defined-literal*](#nt:user-defined-literal "5.13.9User-defined literals[lex.ext]"), but 12LL is an[*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]")[.](#lex.ext-1.sentence-2)
— *end example*]
The syntactic non-terminal preceding the [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]") in a[*user-defined-literal*](#nt:user-defined-literal "5.13.9User-defined literals[lex.ext]") is taken to be the longest sequence of
characters that could match that non-terminal[.](#lex.ext-1.sentence-3)
[2](#lex.ext-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2215)
A [*user-defined-literal*](#nt:user-defined-literal "5.13.9User-defined literals[lex.ext]") is treated as a call to a literal operator or
literal operator template ([[over.literal]](over.literal "12.6User-defined literals"))[.](#lex.ext-2.sentence-1)
To determine the form of this call for
a given [*user-defined-literal*](#nt:user-defined-literal "5.13.9User-defined literals[lex.ext]") *L* with [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]") *X*,
first let *S* be the set of declarations
found by unqualified lookup for the [*literal-operator-id*](over.literal#nt:literal-operator-id "12.6User-defined literals[over.literal]") whose literal suffix identifier is *X* ([[basic.lookup.unqual]](basic.lookup.unqual "6.5.3Unqualified name lookup"))[.](#lex.ext-2.sentence-2)
*S* shall not be empty[.](#lex.ext-2.sentence-3)
[3](#lex.ext-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2226)
If *L* is a [*user-defined-integer-literal*](#nt:user-defined-integer-literal "5.13.9User-defined literals[lex.ext]"), let *n* be the literal
without its [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")[.](#lex.ext-3.sentence-1)
If *S* contains a literal operator with
parameter type unsigned long long, the literal *L* is treated as a call of
the formoperator ""*X*(*n*ULL)
Otherwise, *S* shall contain a raw literal operator
or a numeric literal operator template ([[over.literal]](over.literal "12.6User-defined literals")) but not both[.](#lex.ext-3.sentence-3)
If *S* contains a raw literal operator,
the literal *L* is treated as a call of the formoperator ""*X*("*n*")
Otherwise (*S* contains a numeric literal operator template),*L* is treated as a call of the formoperator ""*X*<'c1', 'c2', ... 'ck'>() where *n* is the source character sequence c1c2...ck[.](#lex.ext-3.sentence-5)
[*Note [1](#lex.ext-note-1)*:
The sequencec1c2...ck can only contain characters from the basic character set[.](#lex.ext-3.sentence-6)
— *end note*]
[4](#lex.ext-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2252)
If *L* is a [*user-defined-floating-point-literal*](#nt:user-defined-floating-point-literal "5.13.9User-defined literals[lex.ext]"), let *f* be the
literal without its [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")[.](#lex.ext-4.sentence-1)
If *S* contains a literal operator
with parameter type long double, the literal *L* is treated as a call of
the formoperator ""*X*(*f*L)
Otherwise, *S* shall contain a raw literal operator
or a numeric literal operator template ([[over.literal]](over.literal "12.6User-defined literals")) but not both[.](#lex.ext-4.sentence-3)
If *S* contains a raw literal operator,
the [*literal*](#nt:literal "5.13.1Kinds of literals[lex.literal.kinds]") *L* is treated as a call of the formoperator ""*X*("*f*")
Otherwise (*S* contains a numeric literal operator template),*L* is treated as a call of the formoperator ""*X*<'c1', 'c2', ... 'ck'>() where *f* is the source character sequence c1c2...ck[.](#lex.ext-4.sentence-5)
[*Note [2](#lex.ext-note-2)*:
The sequencec1c2...ck can only contain characters from the basic character set[.](#lex.ext-4.sentence-6)
— *end note*]
[5](#lex.ext-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2278)
If *L* is a [*user-defined-string-literal*](#nt:user-defined-string-literal "5.13.9User-defined literals[lex.ext]"),
let *str* be the literal without its [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]") and let *len* be the number of code units in *str* (i.e., its length excluding the terminating null character)[.](#lex.ext-5.sentence-1)
If *S* contains a literal operator template with
a constant template parameter for which *str* is
a well-formed [*template-argument*](temp.names#nt:template-argument "13.3Names of template specializations[temp.names]"),
the literal *L* is treated as a call of the formoperator ""*X*<*str*>()
Otherwise, the literal *L* is treated as a call of the formoperator ""*X*(*str*, *len*)
[6](#lex.ext-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2295)
If *L* is a [*user-defined-character-literal*](#nt:user-defined-character-literal "5.13.9User-defined literals[lex.ext]"), let *ch* be the
literal without its [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")[.](#lex.ext-6.sentence-1)
*S* shall contain a [literal operator](over.literal#def:literal,operator "12.6User-defined literals[over.literal]") whose only parameter has
the type of *ch* and the
literal *L* is treated as a call
of the formoperator ""*X*(*ch*)
[7](#lex.ext-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2306)
[*Example [2](#lex.ext-example-2)*: long double operator ""_w(long double);
std::string operator ""_w(const char16_t*, std::size_t);unsigned operator ""_w(const char*);int main() {1.2_w; // calls operator ""_w(1.2L)u"one"_w; // calls operator ""_w(u"one", 3)12_w; // calls operator ""_w("12")"two"_w; // error: no applicable literal operator} — *end example*]
[8](#lex.ext-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2321)
In translation phase 6 ([[lex.phases]](lex.phases "5.2Phases of translation")), adjacent [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")*s* are concatenated and[*user-defined-string-literal*](#nt:user-defined-string-literal "5.13.9User-defined literals[lex.ext]")*s* are considered [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")*s* for that
purpose[.](#lex.ext-8.sentence-1)
During concatenation, [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")es are removed and ignored and
the concatenation process occurs as described in [[lex.string]](#lex.string "5.13.5String literals")[.](#lex.ext-8.sentence-2)
At the end of phase
6, if a [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]") is the result of a concatenation involving at least one[*user-defined-string-literal*](#nt:user-defined-string-literal "5.13.9User-defined literals[lex.ext]"), all the participating[*user-defined-string-literal*](#nt:user-defined-string-literal "5.13.9User-defined literals[lex.ext]")*s* shall have the same [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]") and that suffix is applied to the result of the concatenation[.](#lex.ext-8.sentence-3)
[9](#lex.ext-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2331)
[*Example [3](#lex.ext-example-3)*: int main() {L"A" "B" "C"_x; // OK, same as L"ABC"_x"P"_x "Q" "R"_y; // error: two different [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")es} — *end example*]

View File

@@ -0,0 +1,34 @@
[lex.literal.kinds]
# 5 Lexical conventions [[lex]](./#lex)
## 5.13 Literals [[lex.literal]](lex.literal#kinds)
### 5.13.1 Kinds of literals [lex.literal.kinds]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1146)
There are several kinds of literals[.](#1.sentence-1)[14](#footnote-14 "The term “literal” generally designates, in this document, those tokens that are called “constants” in C.")
[literal:](#nt:literal "5.13.1Kinds of literals[lex.literal.kinds]")
[*integer-literal*](lex.icon#nt:integer-literal "5.13.2Integer literals[lex.icon]")
[*character-literal*](lex.ccon#nt:character-literal "5.13.3Character literals[lex.ccon]")
[*floating-point-literal*](lex.fcon#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]")
[*string-literal*](lex.string#nt:string-literal "5.13.5String literals[lex.string]")
[*boolean-literal*](lex.bool#nt:boolean-literal "5.13.7Boolean literals[lex.bool]")
[*pointer-literal*](lex.nullptr#nt:pointer-literal "5.13.8Pointer literals[lex.nullptr]")
[*user-defined-literal*](lex.ext#nt:user-defined-literal "5.13.9User-defined literals[lex.ext]")
[*Note [1](#note-1)*:
When appearing as an [*expression*](expr.comma#nt:expression "7.6.20Comma operator[expr.comma]"),
a literal has a type and a value category ([[expr.prim.literal]](expr.prim.literal "7.5.2Literals"))[.](#1.sentence-2)
— *end note*]
[14)](#footnote-14)[14)](#footnoteref-14)
The term “literal” generally designates, in this
document, those tokens that are called “constants” in C[.](#footnote-14.sentence-1)

116
cppdraft/lex/name.md Normal file
View File

@@ -0,0 +1,116 @@
[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)

28
cppdraft/lex/nullptr.md Normal file
View File

@@ -0,0 +1,28 @@
[lex.nullptr]
# 5 Lexical conventions [[lex]](./#lex)
## 5.13 Literals [[lex.literal]](lex.literal#lex.nullptr)
### 5.13.8 Pointer literals [lex.nullptr]
[pointer-literal:](#nt:pointer-literal "5.13.8Pointer literals[lex.nullptr]")
nullptr
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2151)
The pointer literal is the keyword nullptr[.](#1.sentence-1)
It has typestd::nullptr_t[.](#1.sentence-2)
[*Note [1](#note-1)*:
std::nullptr_t is a distinct type that is neither a pointer type nor a pointer-to-member type;
rather, a prvalue of this type is a null pointer constant and can be
converted to a null pointer value or null member pointer value[.](#1.sentence-3)
See [[conv.ptr]](conv.ptr "7.3.12Pointer conversions") and [[conv.mem]](conv.mem "7.3.13Pointer-to-member conversions")[.](#1.sentence-4)
— *end note*]

34
cppdraft/lex/operators.md Normal file
View File

@@ -0,0 +1,34 @@
[lex.operators]
# 5 Lexical conventions [[lex]](./#lex)
## 5.8 Operators and punctuators [lex.operators]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L774)
The lexical representation of C++ programs includes a number of
preprocessing tokens that are used in the syntax of the preprocessor or
are converted into tokens for operators and punctuators:
[preprocessing-op-or-punc:](#nt:preprocessing-op-or-punc "5.8Operators and punctuators[lex.operators]")
[*preprocessing-operator*](#nt:preprocessing-operator "5.8Operators and punctuators[lex.operators]")
[*operator-or-punctuator*](#nt:operator-or-punctuator "5.8Operators and punctuators[lex.operators]")
[preprocessing-operator:](#nt:preprocessing-operator "5.8Operators and punctuators[lex.operators]") one of
# ## %: %:%:
[operator-or-punctuator:](#nt:operator-or-punctuator "5.8Operators and punctuators[lex.operators]") one of
{ } [ ] ( ) [: :]
<% %> <: :> ; : ...
? :: . .* -> ->* ^^ ~
! + - * / % ^ & |
= += -= *= /= %= ^= &= |=
== != < > <= >= <=> && ||
<< >> <<= >>= ++ -- ,
and or xor not bitand bitor compl
and_eq or_eq xor_eq not_eq
Each [*operator-or-punctuator*](#nt:operator-or-punctuator "5.8Operators and punctuators[lex.operators]") is converted to a single token
in translation phase 7 ([[lex.phases]](lex.phases "5.2Phases of translation"))[.](#1.sentence-2)

44
cppdraft/lex/phases.md Normal file
View File

@@ -0,0 +1,44 @@
[lex.phases]
# 5 Lexical conventions [[lex]](./#lex)
## 5.2 Phases of translation [lex.phases]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L49)
The precedence among the syntax rules of translation is specified by the
following phases[.](#1.sentence-1)[7](#footnote-7 "Implementations behave as if these separate phases occur, although in practice different phases can be folded together.")
| [1.](#1.1) | An implementation shall support input files that are a sequence of UTF-8 code units (UTF-8 files)[.](#1.1.sentence-1)<br>It may also support an implementation-defined set of other kinds of input files, and, if so, the kind of an input file is determined in an implementation-defined manner that includes a means of designating input files as UTF-8 files, independent of their content[.](#1.1.sentence-2)<br>[*Note [1](#note-1)*:<br>In other words, recognizing the U+feff byte order mark is not sufficient[.](#1.1.sentence-3) — *end note*]<br> If an input file is determined to be a UTF-8 file, then it shall be a well-formed UTF-8 code unit sequence and it is decoded to produce a sequence of Unicode[8](#footnote-8 "Unicode®&nbsp;is a registered trademark of Unicode, Inc. This information is given for the convenience of users of this document and does not constitute an endorsement by ISO or IEC of this product.") scalar values[.](#1.1.sentence-4)<br>A sequence of translation character set elements ([[lex.charset]](lex.charset "5.3.1Character sets")) is then formed by mapping each Unicode scalar value to the corresponding translation character set element[.](#1.1.sentence-5)<br>In the resulting sequence, each pair of characters in the input sequence consisting of U+000d carriage return followed by U+000a line feed, as well as each U+000d carriage return not immediately followed by a U+000a line feed, is replaced by a single new-line character[.](#1.1.sentence-6)<br>For any other kind of input file supported by the implementation, characters are mapped, in an implementation-defined manner, to a sequence of translation character set elements, representing end-of-line indicators as new-line characters[.](#1.1.sentence-7) |
| --- | --- |
| [2.](#1.2) | If the first translation character is U+feff byte order mark, it is deleted[.](#1.2.sentence-1)<br>Each sequence of a backslash character (\) immediately followed by zero or more whitespace characters other than new-line followed by a new-line character is deleted, splicing physical source lines to form [*logical source lines*](#def:source_line,logical "5.2Phases of translation[lex.phases]")[.](#1.2.sentence-2)<br>Only the last backslash on any physical source line shall be eligible for being part of such a splice[.](#1.2.sentence-3)<br>[*Note [2](#note-2)*:<br>Line splicing can form a [*universal-character-name*](lex.universal.char#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]") ([[lex.charset]](lex.charset "5.3.1Character sets"))[.](#1.2.sentence-4) — *end note*]<br> A source file that is not empty and that (after splicing) does not end in a new-line character shall be processed as if an additional new-line character were appended to the file[.](#1.2.sentence-5) |
| [3.](#1.3) | The source file is decomposed into preprocessing tokens ([[lex.pptoken]](lex.pptoken "5.5Preprocessing tokens")) and sequences of whitespace characters (including comments)[.](#1.3.sentence-1)<br>A source file shall not end in a partial preprocessing token or in a partial comment[.](#1.3.sentence-2)[9](#footnote-9 "A partial preprocessing token would arise from a source file ending in the first portion of a multi-character token that requires a terminating sequence of characters, such as a header-name that is missing the closing &quot; or >. A partial comment would arise from a source file ending with an unclosed /* comment.")<br> Each comment ([[lex.comment]](lex.comment "5.4Comments")) is replaced by one U+0020 space character[.](#1.3.sentence-3)<br>New-line characters are retained[.](#1.3.sentence-4)<br>Whether each nonempty sequence of whitespace characters other than new-line is retained or replaced by one U+0020 space character is unspecified[.](#1.3.sentence-5)<br>As characters from the source file are consumed to form the next preprocessing token (i.e., not being consumed as part of a comment or other forms of whitespace), except when matching a [*c-char-sequence*](lex.ccon#nt:c-char-sequence "5.13.3Character literals[lex.ccon]"), [*s-char-sequence*](lex.string#nt:s-char-sequence "5.13.5String literals[lex.string]"), [*r-char-sequence*](lex.string#nt:r-char-sequence "5.13.5String literals[lex.string]"), [*h-char-sequence*](lex.header#nt:h-char-sequence "5.6Header names[lex.header]"), or [*q-char-sequence*](lex.header#nt:q-char-sequence "5.6Header names[lex.header]"), [*universal-character-name*](lex.universal.char#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]")*s* are recognized ([[lex.universal.char]](lex.universal.char "5.3.2Universal character names")) and replaced by the designated element of the translation character set ([[lex.charset]](lex.charset "5.3.1Character sets"))[.](#1.3.sentence-6)<br>The process of dividing a source file's characters into preprocessing tokens is context-dependent[.](#1.3.sentence-7)<br>[*Example [1](#example-1)*:<br>See the handling of < within a #include preprocessing directive ([[lex.header]](lex.header "5.6Header names"), [[cpp.include]](cpp.include "15.3Source file inclusion"))[.](#1.3.sentence-8) — *end example*] |
| [4.](#1.4) | The source file is analyzed as a [*preprocessing-file*](cpp.pre#nt:preprocessing-file "15.1Preamble[cpp.pre]") ([[cpp.pre]](cpp.pre "15.1Preamble"))[.](#1.4.sentence-1)<br>Preprocessing directives ([[cpp]](cpp "15Preprocessing directives")) are executed, macro invocations are expanded ([[cpp.replace]](cpp.replace "15.7Macro replacement")), and _Pragma unary operator expressions are executed ([[cpp.pragma.op]](cpp.pragma.op "15.13Pragma operator"))[.](#1.4.sentence-2)<br>A #include preprocessing directive ([[cpp.include]](cpp.include "15.3Source file inclusion")) causes the named header or source file to be processed from phase 1 through phase 4, recursively[.](#1.4.sentence-3)<br>All preprocessing directives are then deleted[.](#1.4.sentence-4) |
| [5.](#1.5) | For a sequence of two or more adjacent [*string-literal*](lex.string#nt:string-literal "5.13.5String literals[lex.string]") preprocessing tokens, a common [*encoding-prefix*](lex.ccon#nt:encoding-prefix "5.13.3Character literals[lex.ccon]") is determined as specified in [[lex.string]](lex.string "5.13.5String literals")[.](#1.5.sentence-1)<br>Each such [*string-literal*](lex.string#nt:string-literal "5.13.5String literals[lex.string]") preprocessing token is then considered to have that common [*encoding-prefix*](lex.ccon#nt:encoding-prefix "5.13.3Character literals[lex.ccon]")[.](#1.5.sentence-2) |
| [6.](#1.6) | Adjacent [*string-literal*](lex.string#nt:string-literal "5.13.5String literals[lex.string]") preprocessing tokens are concatenated ([[lex.string]](lex.string "5.13.5String literals"))[.](#1.6.sentence-1) |
| [7.](#1.7) | Each preprocessing token is converted into a token ([[lex.token]](lex.token "5.10Tokens"))[.](#1.7.sentence-1)<br>Whitespace characters separating tokens are no longer significant[.](#1.7.sentence-2)<br>The resulting tokens constitute a [*translation unit*](#def:translation_unit "5.2Phases of translation[lex.phases]") and are syntactically and semantically analyzed as a [*translation-unit*](basic.link#nt:translation-unit "6.7Program and linkage[basic.link]") ([[basic.link]](basic.link "6.7Program and linkage")) and translated[.](#1.7.sentence-3)<br>[*Note [3](#note-3)*:<br>The process of analyzing and translating the tokens can occasionally result in one token being replaced by a sequence of other tokens ([[temp.names]](temp.names "13.3Names of template specializations"))[.](#1.7.sentence-4) — *end note*]<br> It is implementation-defined whether the sources for module units and header units on which the current translation unit has an interface dependency ([[module.unit]](module.unit "10.1Module units and purviews"), [[module.import]](module.import "10.3Import declaration")) are required to be available[.](#1.7.sentence-5)<br>[*Note [4](#note-4)*:<br>Source files, translation units and translated translation units need not necessarily be stored as files, nor need there be any one-to-one correspondence between these entities and any external representation[.](#1.7.sentence-6)<br>The description is conceptual only, and does not specify any particular implementation[.](#1.7.sentence-7) — *end note*]<br>[*Note [5](#note-5)*:<br>Previously translated translation units can be preserved individually or in libraries[.](#1.7.sentence-8)<br>The separate translation units of a program communicate ([[basic.link]](basic.link "6.7Program and linkage")) by (for example) calls to functions whose names have external or module linkage, manipulation of variables whose names have external or module linkage, or manipulation of data files[.](#1.7.sentence-9) — *end note*]<br>While the tokens constituting translation units are being analyzed and translated, required instantiations are performed[.](#1.7.sentence-10)<br>[*Note [6](#note-6)*:<br>This can include instantiations which have been explicitly requested ([[temp.explicit]](temp.explicit "13.9.3Explicit instantiation"))[.](#1.7.sentence-11) — *end note*]<br>The contexts from which instantiations may be performed are determined by their respective points of instantiation ([[temp.point]](temp.point "13.8.4.1Point of instantiation"))[.](#1.7.sentence-12)<br>[*Note [7](#note-7)*:<br>Other requirements in this document can further constrain the context from which an instantiation can be performed[.](#1.7.sentence-13)<br>For example, a constexpr function template specialization might have a point of instantiation at the end of a translation unit, but its use in certain constant expressions could require that it be instantiated at an earlier point ([[temp.inst]](temp.inst "13.9.2Implicit instantiation"))[.](#1.7.sentence-14) — *end note*]<br>Each instantiation results in new program constructs[.](#1.7.sentence-15)<br>The program is ill-formed if any instantiation fails[.](#1.7.sentence-16)<br>During the analysis and translation of tokens, certain expressions are evaluated ([[expr.const]](expr.const "7.7Constant expressions"))[.](#1.7.sentence-17)<br>Constructs appearing at a program point P are analyzed in a context where each side effect of evaluating an expression E as a full-expression is complete if and only if <br> [(1.7.1)](#1.7.1)E is the expression corresponding to a [*consteval-block-declaration*](dcl.pre#nt:consteval-block-declaration "9.1Preamble[dcl.pre]") ([[dcl.pre]](dcl.pre "9.1Preamble")), and<br>[(1.7.2)](#1.7.2)either that [*consteval-block-declaration*](dcl.pre#nt:consteval-block-declaration "9.1Preamble[dcl.pre]") or the template definition from which it is instantiated is reachable from ([[module.reach]](module.reach "10.7Reachability")) <br><br>[(1.7.2.1)](#1.7.2.1)P, or<br>[(1.7.2.2)](#1.7.2.2)the point immediately following the [*class-specifier*](class.pre#nt:class-specifier "11.1Preamble[class.pre]") of the outermost class for which P is in a complete-class context ([[class.mem.general]](class.mem.general "11.4.1General"))[.](#1.7.sentence-18) <br>[*Example [2](#example-2)*: class S {class Incomplete; class Inner {void fn() {/* p1 */ Incomplete i; // OK}}; /* p2 */consteval { define_aggregate(^^Incomplete, {}); }}; /* p3 */<br> Constructs at p1 are analyzed in a context where the side effect of the call to define_aggregate is evaluated because <br> [(1.7.3)](#1.7.3)E is the expression corresponding to a consteval block, and<br>[(1.7.4)](#1.7.4)p1 is in a complete-class context of S and the consteval block is reachable from p3[.](#1.7.sentence-19) — *end example*] |
| [8.](#1.8) | Translated translation units are combined, and all external entity references are resolved[.](#1.8.sentence-1)<br>Library components are linked to satisfy external references to entities not defined in the current translation[.](#1.8.sentence-2)<br>All such translator output is collected into a program image which contains information needed for execution in its execution environment[.](#1.8.sentence-3) |
[7)](#footnote-7)[7)](#footnoteref-7)
Implementations behave as if these separate phases
occur, although in practice different phases can be folded together[.](#footnote-7.sentence-1)
[8)](#footnote-8)[8)](#footnoteref-8)
Unicode® is a registered trademark of Unicode, Inc[.](#footnote-8.sentence-1)
This information is given for the convenience of users of this document and
does not constitute an endorsement by ISO or IEC of this product[.](#footnote-8.sentence-2)
[9)](#footnote-9)[9)](#footnoteref-9)
A partial preprocessing
token would arise from a source file
ending in the first portion of a multi-character token that requires a
terminating sequence of characters, such as a [*header-name*](lex.header#nt:header-name "5.6Header names[lex.header]") that is missing the closing " or >[.](#footnote-9.sentence-1)
A partial comment
would arise from a source file ending with an unclosed /* comment[.](#footnote-9.sentence-2)

34
cppdraft/lex/ppnumber.md Normal file
View File

@@ -0,0 +1,34 @@
[lex.ppnumber]
# 5 Lexical conventions [[lex]](./#lex)
## 5.7 Preprocessing numbers [lex.ppnumber]
[pp-number:](#nt:pp-number "5.7Preprocessing numbers[lex.ppnumber]")
[*digit*](lex.name#nt:digit "5.11Identifiers[lex.name]")
. [*digit*](lex.name#nt:digit "5.11Identifiers[lex.name]")
[*pp-number*](#nt:pp-number "5.7Preprocessing numbers[lex.ppnumber]") [*identifier-continue*](lex.name#nt:identifier-continue "5.11Identifiers[lex.name]")
[*pp-number*](#nt:pp-number "5.7Preprocessing numbers[lex.ppnumber]") ' [*digit*](lex.name#nt:digit "5.11Identifiers[lex.name]")
[*pp-number*](#nt:pp-number "5.7Preprocessing numbers[lex.ppnumber]") ' [*nondigit*](lex.name#nt:nondigit "5.11Identifiers[lex.name]")
[*pp-number*](#nt:pp-number "5.7Preprocessing numbers[lex.ppnumber]") e [*sign*](lex.fcon#nt:sign "5.13.4Floating-point literals[lex.fcon]")
[*pp-number*](#nt:pp-number "5.7Preprocessing numbers[lex.ppnumber]") E [*sign*](lex.fcon#nt:sign "5.13.4Floating-point literals[lex.fcon]")
[*pp-number*](#nt:pp-number "5.7Preprocessing numbers[lex.ppnumber]") p [*sign*](lex.fcon#nt:sign "5.13.4Floating-point literals[lex.fcon]")
[*pp-number*](#nt:pp-number "5.7Preprocessing numbers[lex.ppnumber]") P [*sign*](lex.fcon#nt:sign "5.13.4Floating-point literals[lex.fcon]")
[*pp-number*](#nt:pp-number "5.7Preprocessing numbers[lex.ppnumber]") .
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L760)
Preprocessing number tokens lexically include
all [*integer-literal*](lex.icon#nt:integer-literal "5.13.2Integer literals[lex.icon]") tokens ([[lex.icon]](lex.icon "5.13.2Integer literals")) and
all [*floating-point-literal*](lex.fcon#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]") tokens ([[lex.fcon]](lex.fcon "5.13.4Floating-point literals"))[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L765)
A preprocessing number does not have a type or a value; it acquires both
after a successful conversion to
an [*integer-literal*](lex.icon#nt:integer-literal "5.13.2Integer literals[lex.icon]") token or
a [*floating-point-literal*](lex.fcon#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]") token[.](#2.sentence-1)

178
cppdraft/lex/pptoken.md Normal file
View File

@@ -0,0 +1,178 @@
[lex.pptoken]
# 5 Lexical conventions [[lex]](./#lex)
## 5.5 Preprocessing tokens [lex.pptoken]
[preprocessing-token:](#nt:preprocessing-token "5.5Preprocessing tokens[lex.pptoken]")
[*header-name*](lex.header#nt:header-name "5.6Header names[lex.header]")
import-keyword
module-keyword
export-keyword
[*identifier*](lex.name#nt:identifier "5.11Identifiers[lex.name]")
[*pp-number*](lex.ppnumber#nt:pp-number "5.7Preprocessing numbers[lex.ppnumber]")
[*character-literal*](lex.ccon#nt:character-literal "5.13.3Character literals[lex.ccon]")
[*user-defined-character-literal*](lex.ext#nt:user-defined-character-literal "5.13.9User-defined literals[lex.ext]")
[*string-literal*](lex.string#nt:string-literal "5.13.5String literals[lex.string]")
[*user-defined-string-literal*](lex.ext#nt:user-defined-string-literal "5.13.9User-defined literals[lex.ext]")
[*preprocessing-op-or-punc*](lex.operators#nt:preprocessing-op-or-punc "5.8Operators and punctuators[lex.operators]")
each non-whitespace character that cannot be one of the above
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L549)
A preprocessing token is the minimal lexical element of the language in translation
phases 3 through 6[.](#1.sentence-1)
In this document,
glyphs are used to identify
elements of the basic character set ([[lex.charset]](lex.charset "5.3.1Character sets"))[.](#1.sentence-2)
The categories of preprocessing token are: header names,
placeholder tokens produced by preprocessing import and module directives
(*import-keyword*, *module-keyword*, and *export-keyword*),
identifiers, preprocessing numbers, character literals (including user-defined character
literals), string literals (including user-defined string literals), preprocessing
operators and punctuators, and single non-whitespace characters that do not lexically
match the other preprocessing token categories[.](#1.sentence-3)
If a U+0027 apostrophe or a U+0022 quotation mark character
matches the last category, the program is ill-formed[.](#1.sentence-4)
If any character not in the basic character set matches the last category,
the program is ill-formed[.](#1.sentence-5)
Preprocessing tokens can be separated bywhitespace;this consists of comments ([[lex.comment]](lex.comment "5.4Comments")), or whitespace characters
(U+0020 space,U+0009 character tabulation,
new-line,U+000b line tabulation, andU+000c form feed), or both[.](#1.sentence-6)
As described in [[cpp]](cpp "15Preprocessing directives"), in certain
circumstances during translation phase 4, whitespace (or the absence
thereof) serves as more than preprocessing token separation[.](#1.sentence-7)
Whitespace
can appear within a preprocessing token only as part of a header name or
between the quotation characters in a character literal or
string literal[.](#1.sentence-8)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L583)
Each preprocessing token that is converted to a token ([[lex.token]](lex.token "5.10Tokens"))
shall have the lexical form of a keyword, an identifier, a literal,
or an operator or punctuator[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L588)
The *import-keyword* is produced
by processing an import directive ([[cpp.import]](cpp.import "15.6Header unit importation")),
the *module-keyword* is produced
by preprocessing a module directive ([[cpp.module]](cpp.module "15.5Module directive")), and
the *export-keyword* is produced
by preprocessing either of the previous two directives[.](#3.sentence-1)
[*Note [1](#note-1)*:
None has any observable spelling[.](#3.sentence-2)
— *end note*]
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L599)
If the input stream has been parsed into preprocessing tokens up to a
given character:
- [(4.1)](#4.1)
If the next character begins a sequence of characters that could be the prefix
and initial double quote of a raw string literal, such as R", the next preprocessing
token shall be a raw string literal[.](#4.1.sentence-1)
Between the initial and final
double quote characters of the raw string, any transformations performed in phase
2 (line splicing) are reverted; this reversion
shall apply before any [*d-char*](lex.string#nt:d-char "5.13.5String literals[lex.string]"), [*r-char*](lex.string#nt:r-char "5.13.5String literals[lex.string]"), or delimiting
parenthesis is identified[.](#4.1.sentence-2)
The raw string literal is defined as the shortest sequence
of characters that matches the raw-string pattern
[*encoding-prefix*](lex.ccon#nt:encoding-prefix "5.13.3Character literals[lex.ccon]")opt R [*raw-string*](lex.string#nt:raw-string "5.13.5String literals[lex.string]")
- [(4.2)](#4.2)
Otherwise, if the next three characters are <:: and the subsequent character
is neither : nor >, the < is treated as a preprocessing token by
itself and not as the first character of the alternative token <:[.](#4.2.sentence-1)
- [(4.3)](#4.3)
Otherwise, if the next three characters are [:: and
the subsequent character is not :, or
if the next three characters are [:>,
the [ is treated as a preprocessing token by itself and
not as the first character of the preprocessing token [:[.](#4.3.sentence-1)
[*Note [2](#note-2)*:
The tokens [: and :] cannot be composed from digraphs[.](#4.3.sentence-2)
— *end note*]
- [(4.4)](#4.4)
Otherwise,
the next preprocessing token is the longest sequence of
characters that could constitute a preprocessing token, even if that
would cause further lexical analysis to fail,
except that
* [(4.4.1)](#4.4.1)
a [*string-literal*](lex.string#nt:string-literal "5.13.5String literals[lex.string]") token is never formed
when a [*header-name*](lex.header#nt:header-name "5.6Header names[lex.header]") token can be formed, and
* [(4.4.2)](#4.4.2)
a [*header-name*](lex.header#nt:header-name "5.6Header names[lex.header]") ([[lex.header]](lex.header "5.6Header names")) is only formed
+
[(4.4.2.1)](#4.4.2.1)
immediately after the include, embed, or import preprocessing token in a#include ([[cpp.include]](cpp.include "15.3Source file inclusion")), #embed ([[cpp.embed]](cpp.embed "15.4Resource inclusion")), orimport ([[cpp.import]](cpp.import "15.6Header unit importation")) directive, respectively, or
+
[(4.4.2.2)](#4.4.2.2)
immediately after a preprocessing token sequence of __has_include or __has_embed immediately followed by ( in a #if, #elif, or #embed directive ([[cpp.cond]](cpp.cond "15.2Conditional inclusion"), [[cpp.embed]](cpp.embed "15.4Resource inclusion"))[.](#4.4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L655)
[*Example [1](#example-1)*: #define R "x"const char* s = R"y"; // ill-formed raw string, not "x" "y" — *end example*]
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L663)
[*Example [2](#example-2)*:
The program fragment 0xe+foo is parsed as a
preprocessing number token (one that is not a valid[*integer-literal*](lex.icon#nt:integer-literal "5.13.2Integer literals[lex.icon]") or [*floating-point-literal*](lex.fcon#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]") token),
even though a parse as three preprocessing tokens0xe, +, and foo can produce a valid expression (for example,
if foo is a macro defined as 1)[.](#6.sentence-1)
Similarly, the
program fragment 1E1 is parsed as a preprocessing number (one
that is a valid [*floating-point-literal*](lex.fcon#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]") token),
whether or not E is a macro name[.](#6.sentence-2)
— *end example*]
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L676)
[*Example [3](#example-3)*:
The program fragment x+++++y is parsed as x++ ++ + y, which, if x and y have integral types,
violates a constraint on increment operators, even though the parsex ++ + ++ y can yield a correct expression[.](#7.sentence-1)
— *end example*]

28
cppdraft/lex/separate.md Normal file
View File

@@ -0,0 +1,28 @@
[lex.separate]
# 5 Lexical conventions [[lex]](./#lex)
## 5.1 Separate translation [lex.separate]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L27)
The text of the program is kept in units called[*source files*](#def:source_file "5.1Separate translation[lex.separate]") in this document[.](#1.sentence-1)
A source file together with all the <headers> and source files [included](cpp.include "15.3Source file inclusion[cpp.include]") via the preprocessing
directive #include, less any source lines skipped by any of the
conditional inclusion ([[cpp.cond]](cpp.cond "15.2Conditional inclusion")) preprocessing directives,
as modified by the implementation-defined behavior of any
conditionally-supported-directives ([[cpp.pre]](cpp.pre "15.1Preamble")) and pragmas ([[cpp.pragma]](cpp.pragma "15.10Pragma directive")),
if any, is
called a [*preprocessing translation unit*](#def:translation_unit,preprocessing "5.1Separate translation[lex.separate]")[.](#1.sentence-2)
[*Note [1](#note-1)*:
A C++ program need not all be translated at the same time[.](#1.sentence-3)
Translation units can be separately translated and then later linked
to produce an executable program ([[basic.link]](basic.link "6.7Program and linkage"))[.](#1.sentence-4)
— *end note*]

273
cppdraft/lex/string.md Normal file
View File

@@ -0,0 +1,273 @@
[lex.string]
# 5 Lexical conventions [[lex]](./#lex)
## 5.13 Literals [[lex.literal]](lex.literal#lex.string)
### 5.13.5 String literals [lex.string]
[string-literal:](#nt:string-literal "5.13.5String literals[lex.string]")
[*encoding-prefix*](lex.ccon#nt:encoding-prefix "5.13.3Character literals[lex.ccon]")opt " [*s-char-sequence*](#nt:s-char-sequence "5.13.5String literals[lex.string]")opt "
[*encoding-prefix*](lex.ccon#nt:encoding-prefix "5.13.3Character literals[lex.ccon]")opt R [*raw-string*](#nt:raw-string "5.13.5String literals[lex.string]")
[s-char-sequence:](#nt:s-char-sequence "5.13.5String literals[lex.string]")
[*s-char*](#nt:s-char "5.13.5String literals[lex.string]") [*s-char-sequence*](#nt:s-char-sequence "5.13.5String literals[lex.string]")opt
[s-char:](#nt:s-char "5.13.5String literals[lex.string]")
[*basic-s-char*](#nt:basic-s-char "5.13.5String literals[lex.string]")
[*escape-sequence*](lex.ccon#nt:escape-sequence "5.13.3Character literals[lex.ccon]")
[*universal-character-name*](lex.universal.char#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]")
[basic-s-char:](#nt:basic-s-char "5.13.5String literals[lex.string]")
any member of the translation character set except the U+0022 quotation mark,
U+005c reverse solidus, or new-line character
[raw-string:](#nt:raw-string "5.13.5String literals[lex.string]")
" [*d-char-sequence*](#nt:d-char-sequence "5.13.5String literals[lex.string]")opt ( [*r-char-sequence*](#nt:r-char-sequence "5.13.5String literals[lex.string]")opt ) [*d-char-sequence*](#nt:d-char-sequence "5.13.5String literals[lex.string]")opt "
[r-char-sequence:](#nt:r-char-sequence "5.13.5String literals[lex.string]")
[*r-char*](#nt:r-char "5.13.5String literals[lex.string]") [*r-char-sequence*](#nt:r-char-sequence "5.13.5String literals[lex.string]")opt
[r-char:](#nt:r-char "5.13.5String literals[lex.string]")
any member of the translation character set, except a U+0029 right parenthesis followed by
the initial [*d-char-sequence*](#nt:d-char-sequence "5.13.5String literals[lex.string]") (which may be empty) followed by a U+0022 quotation mark
[d-char-sequence:](#nt:d-char-sequence "5.13.5String literals[lex.string]")
[*d-char*](#nt:d-char "5.13.5String literals[lex.string]") [*d-char-sequence*](#nt:d-char-sequence "5.13.5String literals[lex.string]")opt
[d-char:](#nt:d-char "5.13.5String literals[lex.string]")
any member of the basic character set except:
U+0020 space, U+0028 left parenthesis, U+0029 right parenthesis, U+005c reverse solidus,
U+0009 character tabulation, U+000b line tabulation, U+000c form feed, and new-line
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1850)
The kind of a [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]"),
its type, and
its associated character encoding ([[lex.charset]](lex.charset "5.3.1Character sets"))
are determined by its encoding prefix and sequence of[*s-char*](#nt:s-char "5.13.5String literals[lex.string]")*s* or [*r-char*](#nt:r-char "5.13.5String literals[lex.string]")*s* as defined by Table [12](#tab:lex.string.literal "Table 12: String literals") where n is the number of encoded code units
that would result from an evaluation of the [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]") (see below)[.](#1.sentence-1)
Table [12](#tab:lex.string.literal) — String literals [[tab:lex.string.literal]](./tab:lex.string.literal)
| [🔗](#tab:lex.string.literal-row-1)<br>**Enco-** | **Kind** | **Type** | **Associated** | **Examples** |
| --- | --- | --- | --- | --- |
| [🔗](#tab:lex.string.literal-row-2)<br>**ding** | | | **character** | |
| [🔗](#tab:lex.string.literal-row-3)<br>**prefix** | | | **encoding** | |
| [🔗](#tab:lex.string.literal-row-4)<br>none | [*ordinary string literal*](#def:literal,string,ordinary "5.13.5String literals[lex.string]") | array of n const char | ordinary literal encoding | "ordinary string" R"(ordinary raw string)" |
| [🔗](#tab:lex.string.literal-row-5)<br>L | [*wide string literal*](#def:literal,string,wide "5.13.5String literals[lex.string]") | array of n const wchar_t | wide literal encoding | L"wide string" LR"w(wide raw string)w" |
| [🔗](#tab:lex.string.literal-row-6)<br>u8 | [*UTF-8 string literal*](#def:literal,string,UTF-8 "5.13.5String literals[lex.string]") | array of n const char8_t | UTF-8 | u8"UTF-8 string" u8R"x(UTF-8 raw string)x" |
| [🔗](#tab:lex.string.literal-row-7)<br>u | [*UTF-16 string literal*](#def:literal,string,UTF-16 "5.13.5String literals[lex.string]") | array of n const char16_t | UTF-16 | u"UTF-16 string" uR"y(UTF-16 raw string)y" |
| [🔗](#tab:lex.string.literal-row-8)<br>U | [*UTF-32 string literal*](#def:literal,string,UTF-32 "5.13.5String literals[lex.string]") | array of n const char32_t | UTF-32 | U"UTF-32 string" UR"z(UTF-32 raw string)z" |
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1909)
A [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]") that has an Rin the prefix is a [*raw string literal*](#def:raw_string_literal "5.13.5String literals[lex.string]")[.](#2.sentence-1)
The[*d-char-sequence*](#nt:d-char-sequence "5.13.5String literals[lex.string]") serves as a delimiter[.](#2.sentence-2)
The terminating[*d-char-sequence*](#nt:d-char-sequence "5.13.5String literals[lex.string]") of a [*raw-string*](#nt:raw-string "5.13.5String literals[lex.string]") is the same sequence of
characters as the initial [*d-char-sequence*](#nt:d-char-sequence "5.13.5String literals[lex.string]")[.](#2.sentence-3)
A [*d-char-sequence*](#nt:d-char-sequence "5.13.5String literals[lex.string]") shall consist of at most 16 characters[.](#2.sentence-4)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1919)
[*Note [1](#note-1)*:
The characters '(' and ')' can appear in a[*raw-string*](#nt:raw-string "5.13.5String literals[lex.string]")[.](#3.sentence-1)
Thus, R"delimiter((a|b))delimiter" is equivalent to"(a|b)"[.](#3.sentence-2)
— *end note*]
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1926)
[*Note [2](#note-2)*:
A source-file new-line in a raw string literal results in a new-line in the
resulting execution string literal[.](#4.sentence-1)
Assuming no
whitespace at the beginning of lines in the following example, the assert will succeed:const char* p = R"(a\
b
c)";
assert(std::strcmp(p, "a\\\nb\nc") == 0);
— *end note*]
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1939)
[*Example [1](#example-1)*:
The raw stringR"a(
)\
a"
)a" is equivalent to "\n)\\\na\"\n"[.](#5.sentence-1)
The raw stringR"(x = "\"y\"")" is equivalent to "x = \"\\\"y\\\"\""[.](#5.sentence-2)
— *end example*]
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1955)
Ordinary string literals and UTF-8 string literals are
also referred to as [*narrow string literals*](#def:literal,string,narrow "5.13.5String literals[lex.string]")[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1960)
The [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")*s* in
any sequence of adjacent [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")*s* shall have at most one unique [*encoding-prefix*](lex.ccon#nt:encoding-prefix "5.13.3Character literals[lex.ccon]") among them[.](#7.sentence-1)
The common [*encoding-prefix*](lex.ccon#nt:encoding-prefix "5.13.3Character literals[lex.ccon]") of the sequence is
that [*encoding-prefix*](lex.ccon#nt:encoding-prefix "5.13.3Character literals[lex.ccon]"), if any[.](#7.sentence-2)
[*Note [3](#note-3)*:
A [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")'s rawness has
no effect on the determination of the common [*encoding-prefix*](lex.ccon#nt:encoding-prefix "5.13.3Character literals[lex.ccon]")[.](#7.sentence-3)
— *end note*]
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1972)
In translation phase 6 ([[lex.phases]](lex.phases "5.2Phases of translation")),
adjacent [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")*s* are concatenated[.](#8.sentence-1)
The lexical structure and grouping of
the contents of the individual [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")*s* is retained[.](#8.sentence-2)
[*Example [2](#example-2)*:
"\xA" "B" represents
the code unit '\xA' and the character 'B' after concatenation
(and not the single code unit '\xAB')[.](#8.sentence-3)
Similarly,R"(\u00)" "41" represents six characters,
starting with a backslash and ending with the digit 1 (and not the single character 'A' specified by a [*universal-character-name*](lex.universal.char#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]"))[.](#8.sentence-4)
Table [13](#tab:lex.string.concat "Table 13: String literal concatenations") has some examples of valid concatenations[.](#8.sentence-5)
— *end example*]
Table [13](#tab:lex.string.concat) — String literal concatenations [[tab:lex.string.concat]](./tab:lex.string.concat)
| [🔗](#tab:lex.string.concat-row-1)<br>Source | | Means | Source | | Means | Source | | Means |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| [🔗](#tab:lex.string.concat-row-2)<br>u"a" | u"b" | u"ab" | U"a" | U"b" | U"ab" | L"a" | L"b" | L"ab" |
| [🔗](#tab:lex.string.concat-row-3)<br>u"a" | "b" | u"ab" | U"a" | "b" | U"ab" | L"a" | "b" | L"ab" |
| [🔗](#tab:lex.string.concat-row-4)<br>"a" | u"b" | u"ab" | "a" | U"b" | U"ab" | "a" | L"b" | L"ab" |
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2017)
Evaluating a [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]") results in a string literal object
with static storage duration ([[basic.stc]](basic.stc "6.8.6Storage duration"))[.](#9.sentence-1)
[*Note [4](#note-4)*:
String literal objects are potentially non-unique ([[intro.object]](intro.object "6.8.2Object model"))[.](#9.sentence-2)
Whether successive evaluations of a[*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]") yield the same or a different object is
unspecified[.](#9.sentence-3)
— *end note*]
[*Note [5](#note-5)*:
The effect of attempting to modify a string literal object is undefined[.](#9.sentence-4)
— *end note*]
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2031)
String literal objects are initialized with
the sequence of code unit values
corresponding to the [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")'s sequence of[*s-char*](#nt:s-char "5.13.5String literals[lex.string]")*s* (originally from non-raw string literals) and[*r-char*](#nt:r-char "5.13.5String literals[lex.string]")*s* (originally from raw string literals),
plus a terminating U+0000 null character,
in order as follows:
- [(10.1)](#10.1)
The sequence of characters denoted by each contiguous sequence of[*basic-s-char*](#nt:basic-s-char "5.13.5String literals[lex.string]")*s*,[*r-char*](#nt:r-char "5.13.5String literals[lex.string]")*s*,[*simple-escape-sequence*](lex.ccon#nt:simple-escape-sequence "5.13.3Character literals[lex.ccon]")*s* ([[lex.ccon]](lex.ccon "5.13.3Character literals")), and[*universal-character-name*](lex.universal.char#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]")*s* ([[lex.charset]](lex.charset "5.3.1Character sets"))
is encoded to a code unit sequence
using the [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")'s associated character encoding[.](#10.1.sentence-1)
If a character lacks representation in the associated character encoding,
then the program is ill-formed[.](#10.1.sentence-2)
[*Note [6](#note-6)*:
No character lacks representation in any Unicode encoding form[.](#10.1.sentence-3)
— *end note*]
When encoding a stateful character encoding,
implementations should encode the first such sequence
beginning with the initial encoding state and
encode subsequent sequences
beginning with the final encoding state of the prior sequence[.](#10.1.sentence-4)
[*Note [7](#note-7)*:
The encoded code unit sequence can differ from
the sequence of code units that would be obtained by
encoding each character independently[.](#10.1.sentence-5)
— *end note*]
- [(10.2)](#10.2)
Each [*numeric-escape-sequence*](lex.ccon#nt:numeric-escape-sequence "5.13.3Character literals[lex.ccon]") ([[lex.ccon]](lex.ccon "5.13.3Character literals"))
contributes a single code unit with a value as follows:
* [(10.2.1)](#10.2.1)
Let v be the integer value represented by
the octal number comprising
the sequence of [*octal-digit*](lex.icon#nt:octal-digit "5.13.2Integer literals[lex.icon]")*s* in
an [*octal-escape-sequence*](lex.ccon#nt:octal-escape-sequence "5.13.3Character literals[lex.ccon]") or by
the hexadecimal number comprising
the sequence of [*hexadecimal-digit*](lex.icon#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]")*s* in
a [*hexadecimal-escape-sequence*](lex.ccon#nt:hexadecimal-escape-sequence "5.13.3Character literals[lex.ccon]")[.](#10.2.1.sentence-1)
* [(10.2.2)](#10.2.2)
If v does not exceed the range of representable values of
the [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")'s array element type,
then the value is v[.](#10.2.2.sentence-1)
* [(10.2.3)](#10.2.3)
Otherwise,
if the [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")'s [*encoding-prefix*](lex.ccon#nt:encoding-prefix "5.13.3Character literals[lex.ccon]") is absent or L, andv does not exceed the range of representable values of
the corresponding unsigned type for the underlying type of
the [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")'s array element type,
then the value is the unique value of
the [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")'s array element type T that is congruent to v modulo 2N, where N is the width of T[.](#10.2.3.sentence-1)
* [(10.2.4)](#10.2.4)
Otherwise, the program is ill-formed[.](#10.2.4.sentence-1)
When encoding a stateful character encoding,
these sequences should have no effect on encoding state[.](#10.2.sentence-2)
- [(10.3)](#10.3)
Each [*conditional-escape-sequence*](lex.ccon#nt:conditional-escape-sequence "5.13.3Character literals[lex.ccon]") ([[lex.ccon]](lex.ccon "5.13.3Character literals"))
contributes animplementation-defined
code unit sequence[.](#10.3.sentence-1)
When encoding a stateful character encoding,
it isimplementation-defined
what effect these sequences have on encoding state[.](#10.3.sentence-2)

View File

@@ -0,0 +1,34 @@
[lex.string.uneval]
# 5 Lexical conventions [[lex]](./#lex)
## 5.13 Literals [[lex.literal]](lex.literal#lex.string.uneval)
### 5.13.6 Unevaluated strings [lex.string.uneval]
[unevaluated-string:](#nt:unevaluated-string "5.13.6Unevaluated strings[lex.string.uneval]")
[*string-literal*](lex.string#nt:string-literal "5.13.5String literals[lex.string]")
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2114)
An [*unevaluated-string*](#nt:unevaluated-string "5.13.6Unevaluated strings[lex.string.uneval]") shall have no [*encoding-prefix*](lex.ccon#nt:encoding-prefix "5.13.3Character literals[lex.ccon]")[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2117)
Each [*universal-character-name*](lex.universal.char#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]") and each [*simple-escape-sequence*](lex.ccon#nt:simple-escape-sequence "5.13.3Character literals[lex.ccon]") in an [*unevaluated-string*](#nt:unevaluated-string "5.13.6Unevaluated strings[lex.string.uneval]") is
replaced by the member of the translation character set it denotes[.](#2.sentence-1)
An [*unevaluated-string*](#nt:unevaluated-string "5.13.6Unevaluated strings[lex.string.uneval]") that contains
a [*numeric-escape-sequence*](lex.ccon#nt:numeric-escape-sequence "5.13.3Character literals[lex.ccon]") or
a [*conditional-escape-sequence*](lex.ccon#nt:conditional-escape-sequence "5.13.3Character literals[lex.ccon]") is ill-formed[.](#2.sentence-2)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2125)
An [*unevaluated-string*](#nt:unevaluated-string "5.13.6Unevaluated strings[lex.string.uneval]") is never evaluated and
its interpretation depends on the context in which it appears[.](#3.sentence-1)

32
cppdraft/lex/token.md Normal file
View File

@@ -0,0 +1,32 @@
[lex.token]
# 5 Lexical conventions [[lex]](./#lex)
## 5.10 Tokens [lex.token]
[token:](#nt:token "5.10Tokens[lex.token]")
[*identifier*](lex.name#nt:identifier "5.11Identifiers[lex.name]")
[*keyword*](lex.key#nt:keyword "5.12Keywords[lex.key]")
[*literal*](lex.literal.kinds#nt:literal "5.13.1Kinds of literals[lex.literal.kinds]")
[*operator-or-punctuator*](lex.operators#nt:operator-or-punctuator "5.8Operators and punctuators[lex.operators]")
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L873)
There are five kinds of tokens: identifiers, keywords, literals,[12](#footnote-12 "Literals include strings and character and numeric literals.") operators, and other separators[.](#1.sentence-1)
Comments and the characters U+0020 space, U+0009 character tabulation,U+000b line tabulation, U+000c form feed, and new-line
(collectively, “whitespace”), as described below, are ignored except
as they serve to separate tokens[.](#1.sentence-2)
[*Note [1](#note-1)*:
Whitespace can separate otherwise adjacent identifiers, keywords, numeric
literals, and alternative tokens containing alphabetic characters[.](#1.sentence-3)
— *end note*]
[12)](#footnote-12)[12)](#footnoteref-12)
Literals include strings and character and numeric literals[.](#footnote-12.sentence-1)

View File

@@ -0,0 +1,77 @@
[lex.universal.char]
# 5 Lexical conventions [[lex]](./#lex)
## 5.3 Characters [[lex.char]](lex.char#lex.universal.char)
### 5.3.2 Universal character names [lex.universal.char]
[n-char:](#nt:n-char "5.3.2Universal character names[lex.universal.char]")
any member of the translation character set except the U+007d right curly bracket or new-line character
[n-char-sequence:](#nt:n-char-sequence "5.3.2Universal character names[lex.universal.char]")
[*n-char*](#nt:n-char "5.3.2Universal character names[lex.universal.char]") [*n-char-sequence*](#nt:n-char-sequence "5.3.2Universal character names[lex.universal.char]")opt
[named-universal-character:](#nt:named-universal-character "5.3.2Universal character names[lex.universal.char]")
\N{ [*n-char-sequence*](#nt:n-char-sequence "5.3.2Universal character names[lex.universal.char]") }
[hex-quad:](#nt:hex-quad "5.3.2Universal character names[lex.universal.char]")
[*hexadecimal-digit*](lex.icon#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]") [*hexadecimal-digit*](lex.icon#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]") [*hexadecimal-digit*](lex.icon#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]") [*hexadecimal-digit*](lex.icon#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]")
[simple-hexadecimal-digit-sequence:](#nt:simple-hexadecimal-digit-sequence "5.3.2Universal character names[lex.universal.char]")
[*hexadecimal-digit*](lex.icon#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]") [*simple-hexadecimal-digit-sequence*](#nt:simple-hexadecimal-digit-sequence "5.3.2Universal character names[lex.universal.char]")opt
[universal-character-name:](#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]")
\u [*hex-quad*](#nt:hex-quad "5.3.2Universal character names[lex.universal.char]")
\U [*hex-quad*](#nt:hex-quad "5.3.2Universal character names[lex.universal.char]") [*hex-quad*](#nt:hex-quad "5.3.2Universal character names[lex.universal.char]")
\u{ [*simple-hexadecimal-digit-sequence*](#nt:simple-hexadecimal-digit-sequence "5.3.2Universal character names[lex.universal.char]") }
[*named-universal-character*](#nt:named-universal-character "5.3.2Universal character names[lex.universal.char]")
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L467)
The [*universal-character-name*](#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]") construct provides a way to name any
element in the translation character set using just the basic character set[.](#1.sentence-1)
If a [*universal-character-name*](#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]") outside
the [*c-char-sequence*](lex.ccon#nt:c-char-sequence "5.13.3Character literals[lex.ccon]"), [*s-char-sequence*](lex.string#nt:s-char-sequence "5.13.5String literals[lex.string]"), or[*r-char-sequence*](lex.string#nt:r-char-sequence "5.13.5String literals[lex.string]") of a [*character-literal*](lex.ccon#nt:character-literal "5.13.3Character literals[lex.ccon]") or[*string-literal*](lex.string#nt:string-literal "5.13.5String literals[lex.string]") (in either case, including within a [*user-defined-literal*](lex.ext#nt:user-defined-literal "5.13.9User-defined literals[lex.ext]"))
corresponds to a control character or to a character in the basic character set,
the program is ill-formed[.](#1.sentence-2)
[*Note [1](#note-1)*:
A sequence of characters resembling a [*universal-character-name*](#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]") in an[*r-char-sequence*](lex.string#nt:r-char-sequence "5.13.5String literals[lex.string]") ([[lex.string]](lex.string "5.13.5String literals")) does not form a[*universal-character-name*](#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]")[.](#1.sentence-3)
— *end note*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L483)
A [*universal-character-name*](#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]") of the form \u [*hex-quad*](#nt:hex-quad "5.3.2Universal character names[lex.universal.char]"),\U [*hex-quad*](#nt:hex-quad "5.3.2Universal character names[lex.universal.char]") [*hex-quad*](#nt:hex-quad "5.3.2Universal character names[lex.universal.char]"), or\u{[*simple-hexadecimal-digit-sequence*](#nt:simple-hexadecimal-digit-sequence "5.3.2Universal character names[lex.universal.char]")} designates the character in the translation character set
whose Unicode scalar value is the hexadecimal number represented by
the sequence of [*hexadecimal-digit*](lex.icon#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]")*s* in the [*universal-character-name*](#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]")[.](#2.sentence-1)
The program is ill-formed if that number is not a Unicode scalar value[.](#2.sentence-2)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L494)
A [*universal-character-name*](#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]") that is a [*named-universal-character*](#nt:named-universal-character "5.3.2Universal character names[lex.universal.char]") designates the corresponding character
in the Unicode Standard (chapter 4.8 Name)
if the [*n-char-sequence*](#nt:n-char-sequence "5.3.2Universal character names[lex.universal.char]") is equal
to its character name or
to one of its character name aliases of
type “control”, “correction”, or “alternate”;
otherwise, the program is ill-formed[.](#3.sentence-1)
[*Note [2](#note-2)*:
These aliases are listed in
the Unicode Character Database's NameAliases.txt[.](#3.sentence-2)
None of these names or aliases have leading or trailing spaces[.](#3.sentence-3)
— *end note*]