You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/tokens.md
+43-8Lines changed: 43 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -497,7 +497,7 @@ Note that `-1.0`, for example, is analyzed as two tokens: `-` followed by `1.0`.
497
497
> NUMBER_PSEUDOLITERAL_SUFFIX_NO_E :\
498
498
> NUMBER_PSEUDOLITERAL_SUFFIX <sub>_not beginning with `e` or `E`_</sub>
499
499
500
-
As described [above](#suffixes), tokens with the same form as numeric literals other than in the content of their suffix are accepted by the lexer, with the exception of some cases in which the suffix begins with `e` or `E`.
500
+
As described [above](#suffixes), tokens with the same form as numeric literals other than in the content of their suffix are accepted by the lexer (with the exception of some reserved forms described below).
> | `0b``_`<sup>\*</sup> _end of input or not BIN_DIGIT_\
524
+
> | `0o``_`<sup>\*</sup> _end of input or not OCT_DIGIT_\
525
+
> | `0x``_`<sup>\*</sup> _end of input or not HEX_DIGIT_\
526
+
> | DEC_LITERAL ( . DEC_LITERAL)? (`e`|`E`) (`+`|`-`)? _end of input or not DEC_DIGIT_
527
+
528
+
The following lexical forms similar to number literals are _reserved forms_:
529
+
530
+
* An unsuffixed binary or octal literal followed, without intervening whitespace, by a decimal digit out of the range for its radix.
531
+
532
+
* An unsuffixed binary, octal, or hexadecimal literal followed, without intervening whitespace, by a period character (with the same restrictions on what follows the period as for floating-point literals).
512
533
513
-
// Lexer errors:
514
-
2e;
515
-
2.0e;
516
-
0b101e;
517
-
2em;
518
-
2.0em;
519
-
0b101em;
534
+
* An unsuffixed binary or octal literal followed, without intervening whitespace, by the character `e`.
535
+
536
+
* Input which begins with one of the radix prefixes but is not a valid binary, octal, or hexadecimal literal (because it contains no digits).
537
+
538
+
* Input which has the form of a floating-point literal with no digits in the exponent.
539
+
540
+
Any input containing one of these reserved forms is reported as an error by the lexer.
541
+
542
+
Examples of reserved forms:
543
+
544
+
```rust,compile_fail
545
+
0b0102; // this is not `0b010` followed by `2`
546
+
0o1279; // this is not `0o127` followed by `9`
547
+
0x80.0; // this is not `0x80` followed by `.` and `0`
548
+
0b101e; // this is not a pseudoliteral, or `0b101` followed by `e`
549
+
0b; // this is not a pseudoliteral, or `0` followed by `b`
550
+
0b_; // this is not a pseudoliteral, or `0` followed by `b_`
551
+
2e; // this is not a pseudoliteral, or `2` followed by `e`
552
+
2.0e; // this is not a pseudoliteral, or `2.0` followed by `e`
553
+
2em; // this is not a pseudoliteral, or `2` followed by `em`
554
+
2.0em; // this is not a pseudoliteral, or `2.0` followed by `em`
0 commit comments