Skip to content

Commit 66ed411

Browse files
authored
Merge pull request #240 from matthewjasper/token-fixes
Tokens
2 parents 020dcab + 8e79044 commit 66ed411

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

src/notation.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ productions.
1010

1111
## String table productions
1212

13-
Some rules in the grammar — notably [unary operators], [binary operators],
14-
and [keywords] — are given in a simplified form: as a listing of a table
15-
of unquoted, printable whitespace-separated strings. These cases form a subset
16-
of the rules regarding the [token][tokens] rule, and are assumed to be the
17-
result of a lexical-analysis phase feeding the parser, driven by a
18-
<abbr title="Deterministic Finite Automaton">DFA</abbr>, operating over the
19-
disjunction of all such string table entries.
13+
Some rules in the grammar &mdash; notably [unary operators], [binary
14+
operators], and [keywords] &mdash; are given in a simplified form: as a listing
15+
of printable strings. These cases form a subset of the rules regarding the
16+
[token][tokens] rule, and are assumed to be the result of a lexical-analysis
17+
phase feeding the parser, driven by a <abbr title="Deterministic Finite
18+
Automaton">DFA</abbr>, operating over the disjunction of all such string table
19+
entries.
2020

21-
When such a string enclosed in double-quotes (`"`) occurs inside the grammar,
21+
When such a string in `monospace` font occurs inside the grammar,
2222
it is an implicit reference to a single member of such a string table
2323
production. See [tokens] for more information.
2424

src/tokens.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Tokens are primitive productions in the grammar defined by regular
44
(non-recursive) languages. "Simple" tokens are given in [string table
55
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.
77

88
[string table production]: notation.html#string-table-productions
99

@@ -227,8 +227,7 @@ preceded by the characters `U+0062` (`b`) and `U+0022` (double-quote), and
227227
followed by the character `U+0022`. If the character `U+0022` is present within
228228
the literal, it must be _escaped_ by a preceding `U+005C` (`\`) character.
229229
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]`.
232231

233232
Some additional _escapes_ are available in either byte or non-raw byte string
234233
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.
295294
> INTEGER_LITERAL :
296295
> &nbsp;&nbsp; ( DEC_LITERAL | BIN_LITERAL | OCT_LITERAL | HEX_LITERAL )
297296
> INTEGER_SUFFIX<sup>?</sup>
298-
>
297+
>
299298
> DEC_LITERAL :
300299
> &nbsp;&nbsp; DEC_DIGIT (DEC_DIGIT|`_`)<sup>\*</sup>
301300
>
301+
> TUPLE_INDEX :
302+
> &nbsp;&nbsp; &nbsp;&nbsp; `0`
303+
> &nbsp;&nbsp; | NON_ZERO_DEC_DIGIT DEC_DIGIT<sup>\*</sup>
304+
>
302305
> BIN_LITERAL :
303306
> &nbsp;&nbsp; `0b` (BIN_DIGIT|`_`)<sup>\*</sup> BIN_DIGIT (BIN_DIGIT|`_`)<sup>\*</sup>
304307
>
@@ -314,19 +317,23 @@ literal_. The grammar for recognizing the two kinds of literals is mixed.
314317
>
315318
> DEC_DIGIT : [`0`-`9`]
316319
>
320+
> NON_ZERO_DEC_DIGIT : [`1`-`9`]
321+
>
317322
> HEX_DIGIT : [`0`-`9` `a`-`f` `A`-`F`]
318323
>
319324
> INTEGER_SUFFIX :
320325
> &nbsp;&nbsp; &nbsp;&nbsp; `u8` | `u16` | `u32` | `u64` | `usize`
321326
> &nbsp;&nbsp; | `i8` | `i16` | `i32` | `i64` | `isize`
322327
323-
<!-- FIXME: separate the DECIMAL_LITERAL with no prefix or suffix (used on tuple indexing and float_literal -->
324328
<!-- FIXME: u128 and i128 -->
325329

326330
An _integer literal_ has one of four forms:
327331

328332
* A _decimal literal_ starts with a *decimal digit* and continues with any
329333
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].
330337
* A _hex literal_ starts with the character sequence `U+0030` `U+0078`
331338
(`0x`) and continues as any mixture (with at least one digit) of hex digits
332339
and underscores.
@@ -501,3 +508,6 @@ They are catalogued in [the Symbols section][symbols] of the Grammar document.
501508
[symbols]: ../grammar.html#symbols
502509
[keywords]: keywords.html
503510
[identifier]: identifiers.html
511+
[tuples]: types.html#tuple-types
512+
[tuple structs]: items/structs.html
513+
[tuple variants]: items/enumerations.html

0 commit comments

Comments
 (0)