3
3
Tokens are primitive productions in the grammar defined by regular
4
4
(non-recursive) languages. "Simple" tokens are given in [ string table
5
5
production] form, and occur in the rest of the
6
- grammar as double-quoted strings . Other tokens have exact rules given.
6
+ grammar in ` monospace ` font . Other tokens have exact rules given.
7
7
8
8
[ string table production ] : notation.html#string-table-productions
9
9
@@ -227,8 +227,7 @@ preceded by the characters `U+0062` (`b`) and `U+0022` (double-quote), and
227
227
followed by the character ` U+0022 ` . If the character ` U+0022 ` is present within
228
228
the literal, it must be _ escaped_ by a preceding ` U+005C ` (` \ ` ) character.
229
229
Alternatively, a byte string literal can be a _ raw byte string literal_ , defined
230
- below. A byte string literal of length ` n ` is equivalent to a ` &'static [u8; n] ` borrowed fixed-sized array
231
- of unsigned 8-bit integers.
230
+ below. The type of a byte string literal of length ` n ` is ` &'static [u8; n] ` .
232
231
233
232
Some additional _ escapes_ are available in either byte or non-raw byte string
234
233
literals. An escape starts with a ` U+005C ` (` \ ` ) and continues with one of the
@@ -295,10 +294,14 @@ literal_. The grammar for recognizing the two kinds of literals is mixed.
295
294
> INTEGER_LITERAL :
296
295
>   ;  ; ( DEC_LITERAL | BIN_LITERAL | OCT_LITERAL | HEX_LITERAL )
297
296
> INTEGER_SUFFIX<sup >?</sup >
298
- >
297
+ >
299
298
> DEC_LITERAL :
300
299
>   ;  ; DEC_DIGIT (DEC_DIGIT|` _ ` )<sup >\* </sup >
301
300
>
301
+ > TUPLE_INDEX :
302
+ >   ;  ;   ;  ; ` 0 `
303
+ >   ;  ; | NON_ZERO_DEC_DIGIT DEC_DIGIT<sup >\* </sup >
304
+ >
302
305
> BIN_LITERAL :
303
306
>   ;  ; ` 0b ` (BIN_DIGIT|` _ ` )<sup >\* </sup > BIN_DIGIT (BIN_DIGIT|` _ ` )<sup >\* </sup >
304
307
>
@@ -314,19 +317,23 @@ literal_. The grammar for recognizing the two kinds of literals is mixed.
314
317
>
315
318
> DEC_DIGIT : [ ` 0 ` -` 9 ` ]
316
319
>
320
+ > NON_ZERO_DEC_DIGIT : [ ` 1 ` -` 9 ` ]
321
+ >
317
322
> HEX_DIGIT : [ ` 0 ` -` 9 ` ` a ` -` f ` ` A ` -` F ` ]
318
323
>
319
324
> INTEGER_SUFFIX :
320
325
>   ;  ;   ;  ; ` u8 ` | ` u16 ` | ` u32 ` | ` u64 ` | ` usize `
321
326
>   ;  ; | ` i8 ` | ` i16 ` | ` i32 ` | ` i64 ` | ` isize `
322
327
323
- <!-- FIXME: separate the DECIMAL_LITERAL with no prefix or suffix (used on tuple indexing and float_literal -->
324
328
<!-- FIXME: u128 and i128 -->
325
329
326
330
An _ integer literal_ has one of four forms:
327
331
328
332
* A _ decimal literal_ starts with a * decimal digit* and continues with any
329
333
mixture of * decimal digits* and _ underscores_ .
334
+ * A _ tuple index_ is either ` 0 ` , or starts with a * non-zero decimal digit* and
335
+ continues with zero or more decimal digits. Tuple indexes are used to refer
336
+ to the fields of [ tuples] , [ tuple structs] and [ tuple variants] .
330
337
* A _ hex literal_ starts with the character sequence ` U+0030 ` ` U+0078 `
331
338
(` 0x ` ) and continues as any mixture (with at least one digit) of hex digits
332
339
and underscores.
@@ -501,3 +508,6 @@ They are catalogued in [the Symbols section][symbols] of the Grammar document.
501
508
[ symbols ] : ../grammar.html#symbols
502
509
[ keywords ] : keywords.html
503
510
[ identifier ] : identifiers.html
511
+ [ tuples ] : types.html#tuple-types
512
+ [ tuple structs ] : items/structs.html
513
+ [ tuple variants ] : items/enumerations.html
0 commit comments