@@ -12,6 +12,8 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
1212
1313- [ Overview] ( #overview )
1414- [ Keywords] ( #keywords )
15+ - [ Type literals] ( #type-literals )
16+ - [ Identifiers] ( #identifiers )
1517 - [ Raw identifiers] ( #raw-identifiers )
1618- [ Alternatives considered] ( #alternatives-considered )
1719- [ References] ( #references )
@@ -21,7 +23,7 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2123## Overview
2224
2325A _ word_ is a lexical element formed from a sequence of letters or letter-like
24- characters, such as ` fn ` or ` Foo ` or ` Int ` .
26+ characters, such as ` fn ` or ` Foo ` or ` Int ` , optionally preceded by ` r# ` .
2527
2628The exact lexical form of words has not yet been settled. However, Carbon will
2729follow lexical conventions for identifiers based on
@@ -98,20 +100,47 @@ The following words are interpreted as keywords:
98100- ` where `
99101- ` while `
100102
103+ ### Type literals
104+
105+ A word starting with ` i ` , ` u ` , or ` f ` , followed by a decimal integer, is a
106+ [ _ numeric type literal_ ] ( /docs/design/expressions/literals.md#numeric-type-literals ) .
107+
108+ ### Identifiers
109+
110+ A word is interpreted as an _ identifier_ if it is neither a keyword nor a type
111+ literal.
112+
101113### Raw identifiers
102114
103- A raw identifier looks like ` r#<identifier> ` . This can be used for identifiers
104- which have the same spelling as keywords; for example, ` r#impl ` . It can help
105- when using C++ code with identifiers that are keywords in Carbon.
115+ A _ raw identifier_ is a word starting with ` r# ` . A raw identifier is equivalent
116+ to the word following the ` r# ` prefix, except that it is always interpreted as
117+ an identifier, even if it would otherwise be a keyword or type literal.
118+
119+ Raw identifiers can be used to specify identifiers which have the same spelling
120+ as keywords; for example, ` r#impl ` . This can be useful when interoperating with
121+ C++ code that uses identifiers that are keywords in Carbon, and when migrating
122+ between versions of Carbon.
106123
107- The identifier doesn't need to be a keyword, in order to support forwards
108- compatibility when a keyword is planned to be added. When ` <identifier> ` is not
109- a keyword, it will refer to the same entity as ` r#<identifier> ` .
124+ The word doesn't need to be a keyword, in order to support forwards
125+ compatibility when a keyword is planned to be added. If ` word ` is an identifier,
126+ then ` word ` and ` r#word ` have the same meaning .
110127
111128## Alternatives considered
112129
130+ Overview:
131+
113132- [ Character encoding: We could restrict words to ASCII.] ( /proposals/p0142.md#character-encoding-1 )
114133- [ Normalization form alternatives considered] ( /proposals/p0142.md#normalization-forms )
134+
135+ Type literals:
136+
137+ - [ Use C++ type keywords with LP64 convention] ( /proposals/p2015.md#c-lp64-convention )
138+ - [ Use full type name with length suffix] ( /proposals/p2015.md#type-name-with-length-suffix )
139+ - [ Use uppercase for type names] ( /proposals/p2015.md#uppercase-suffixes )
140+ - [ Support additional bit widths] ( /proposals/p2015.md#additional-bit-sizes )
141+
142+ Raw identifiers:
143+
115144- [ Other raw identifier syntaxes] ( /proposals/p3797.md#other-raw-identifier-syntaxes )
116145- [ Restrict raw identifier syntax to current and future keywords] ( /proposals/p3797.md#restrict-raw-identifier-syntax-to-current-and-future-keywords )
117146- [ Don't require syntax for references to raw identifiers] ( /proposals/p3797.md#dont-require-syntax-for-references-to-raw-identifiers )
@@ -121,5 +150,7 @@ a keyword, it will refer to the same entity as `r#<identifier>`.
121150
122151- Proposal
123152 [ #142 : Unicode source files] ( https://github.com/carbon-language/carbon-lang/pull/142 )
153+ - Proposal
154+ [ #2015 : Numeric type literal syntax] ( https://github.com/carbon-language/carbon-lang/pull/2015 )
124155- Proposal
125156 [ #3797 : Raw identifier syntax] ( https://github.com/carbon-language/carbon-lang/pull/3797 )
0 commit comments