tmp/tmpx0mdzlyg/{from.md → to.md}
RENAMED
|
@@ -1,43 +1,57 @@
|
|
| 1 |
### Integer literals <a id="lex.icon">[[lex.icon]]</a>
|
| 2 |
|
| 3 |
``` bnf
|
| 4 |
integer-literal:
|
| 5 |
-
|
| 6 |
octal-literal integer-suffixₒₚₜ
|
|
|
|
| 7 |
hexadecimal-literal integer-suffixₒₚₜ
|
| 8 |
```
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
``` bnf
|
| 11 |
decimal-literal:
|
| 12 |
nonzero-digit
|
| 13 |
-
decimal-literal digit
|
| 14 |
-
```
|
| 15 |
-
|
| 16 |
-
``` bnf
|
| 17 |
-
octal-literal:
|
| 18 |
-
'0'
|
| 19 |
-
octal-literal octal-digit
|
| 20 |
```
|
| 21 |
|
| 22 |
``` bnf
|
| 23 |
hexadecimal-literal:
|
| 24 |
'0x' hexadecimal-digit
|
| 25 |
'0X' hexadecimal-digit
|
| 26 |
-
hexadecimal-literal hexadecimal-digit
|
| 27 |
```
|
| 28 |
|
| 29 |
``` bnf
|
| 30 |
-
|
| 31 |
-
'
|
|
|
|
| 32 |
```
|
| 33 |
|
| 34 |
``` bnf
|
| 35 |
octal-digit: one of
|
| 36 |
'0 1 2 3 4 5 6 7'
|
| 37 |
```
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
``` bnf
|
| 40 |
hexadecimal-digit: one of
|
| 41 |
'0 1 2 3 4 5 6 7 8 9'
|
| 42 |
'a b c d e f'
|
| 43 |
'A B C D E F'
|
|
@@ -65,27 +79,31 @@ long-suffix: one of
|
|
| 65 |
long-long-suffix: one of
|
| 66 |
'll LL'
|
| 67 |
```
|
| 68 |
|
| 69 |
An *integer literal* is a sequence of digits that has no period or
|
| 70 |
-
exponent part
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
The type of an integer literal is the first of the corresponding list in
|
| 83 |
-
Table [[tab:lex.type.integer.
|
| 84 |
represented.
|
| 85 |
|
| 86 |
-
**Table: Types of integer
|
| 87 |
|
| 88 |
| | | |
|
| 89 |
| ---------------- | ------------------------ | ------------------------ |
|
| 90 |
| none | `int` | `int` |
|
| 91 |
| | `long int` | `unsigned int` |
|
|
|
|
| 1 |
### Integer literals <a id="lex.icon">[[lex.icon]]</a>
|
| 2 |
|
| 3 |
``` bnf
|
| 4 |
integer-literal:
|
| 5 |
+
binary-literal integer-suffixₒₚₜ
|
| 6 |
octal-literal integer-suffixₒₚₜ
|
| 7 |
+
decimal-literal integer-suffixₒₚₜ
|
| 8 |
hexadecimal-literal integer-suffixₒₚₜ
|
| 9 |
```
|
| 10 |
|
| 11 |
+
``` bnf
|
| 12 |
+
binary-literal:
|
| 13 |
+
'0b' binary-digit
|
| 14 |
+
'0B' binary-digit
|
| 15 |
+
binary-literal '''ₒₚₜ binary-digit
|
| 16 |
+
```
|
| 17 |
+
|
| 18 |
+
``` bnf
|
| 19 |
+
octal-literal:
|
| 20 |
+
'0'
|
| 21 |
+
octal-literal '''ₒₚₜ octal-digit
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
``` bnf
|
| 25 |
decimal-literal:
|
| 26 |
nonzero-digit
|
| 27 |
+
decimal-literal '''ₒₚₜ digit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
```
|
| 29 |
|
| 30 |
``` bnf
|
| 31 |
hexadecimal-literal:
|
| 32 |
'0x' hexadecimal-digit
|
| 33 |
'0X' hexadecimal-digit
|
| 34 |
+
hexadecimal-literal '''ₒₚₜ hexadecimal-digit
|
| 35 |
```
|
| 36 |
|
| 37 |
``` bnf
|
| 38 |
+
binary-digit:
|
| 39 |
+
'0'
|
| 40 |
+
'1'
|
| 41 |
```
|
| 42 |
|
| 43 |
``` bnf
|
| 44 |
octal-digit: one of
|
| 45 |
'0 1 2 3 4 5 6 7'
|
| 46 |
```
|
| 47 |
|
| 48 |
+
``` bnf
|
| 49 |
+
nonzero-digit: one of
|
| 50 |
+
'1 2 3 4 5 6 7 8 9'
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
``` bnf
|
| 54 |
hexadecimal-digit: one of
|
| 55 |
'0 1 2 3 4 5 6 7 8 9'
|
| 56 |
'a b c d e f'
|
| 57 |
'A B C D E F'
|
|
|
|
| 79 |
long-long-suffix: one of
|
| 80 |
'll LL'
|
| 81 |
```
|
| 82 |
|
| 83 |
An *integer literal* is a sequence of digits that has no period or
|
| 84 |
+
exponent part, with optional separating single quotes that are ignored
|
| 85 |
+
when determining its value. An integer literal may have a prefix that
|
| 86 |
+
specifies its base and a suffix that specifies its type. The lexically
|
| 87 |
+
first digit of the sequence of digits is the most significant. A
|
| 88 |
+
*binary* integer literal (base two) begins with `0b` or `0B` and
|
| 89 |
+
consists of a sequence of binary digits. An *octal* integer literal
|
| 90 |
+
(base eight) begins with the digit `0` and consists of a sequence of
|
| 91 |
+
octal digits.[^12] A *decimal* integer literal (base ten) begins with a
|
| 92 |
+
digit other than `0` and consists of a sequence of decimal digits. A
|
| 93 |
+
*hexadecimal* integer literal (base sixteen) begins with `0x` or `0X`
|
| 94 |
+
and consists of a sequence of hexadecimal digits, which include the
|
| 95 |
+
decimal digits and the letters `a` through `f` and `A` through `F` with
|
| 96 |
+
decimal values ten through fifteen. The number twelve can be written
|
| 97 |
+
`12`, `014`, `0XC`, or `0b1100`. The literals `1048576`, `1'048'576`,
|
| 98 |
+
`0X100000`, `0x10'0000`, and `0'004'000'000` all have the same value.
|
| 99 |
|
| 100 |
The type of an integer literal is the first of the corresponding list in
|
| 101 |
+
Table [[tab:lex.type.integer.literal]] in which its value can be
|
| 102 |
represented.
|
| 103 |
|
| 104 |
+
**Table: Types of integer literals** <a id="tab:lex.type.integer.literal">[tab:lex.type.integer.literal]</a>
|
| 105 |
|
| 106 |
| | | |
|
| 107 |
| ---------------- | ------------------------ | ------------------------ |
|
| 108 |
| none | `int` | `int` |
|
| 109 |
| | `long int` | `unsigned int` |
|