Files
2025-10-25 03:02:53 +03:00

51 lines
2.8 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

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

[lex.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)