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

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 <: 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)