diff --git a/doc/syntax.md b/doc/syntax.md index b70cf383..a06b8c3e 100644 --- a/doc/syntax.md +++ b/doc/syntax.md @@ -12,7 +12,8 @@ The grammar for a replacement field is as follows:
-replacement_field ::= "{" [arg_id] [":" (format_spec | chrono_format_spec)] "}"
+replacement_field ::= "{" [arg_id] [":" (format_spec | chrono_format_spec)] "}"
 arg_id            ::= integer | identifier
 integer           ::= digit+
 digit             ::= "0"..."9"
@@ -77,8 +78,10 @@ format_spec ::= [[fill]align][sign]["#"]["0"][width]["." precision]["L"][type]
 fill        ::= <a character other than '{' or '}'>
 align       ::= "<" | ">" | "^"
 sign        ::= "+" | "-" | " "
-width       ::= integer | "{" [arg_id] "}"
-precision   ::= integer | "{" [arg_id] "}"
+width       ::= integer | "{" [arg_id] "}"
+precision   ::= integer | "{" [arg_id] "}"
 type        ::= "a" | "A" | "b" | "B" | "c" | "d" | "e" | "E" | "f" | "F" |
                 "g" | "G" | "o" | "p" | "s" | "x" | "X" | "?"
 
@@ -92,13 +95,10 @@ the fill character and the alignment option are absent. The meaning of the various alignment options is as follows: - - - -
Option Meaning
'<' @@ -117,7 +117,6 @@ The meaning of the various alignment options is as follows: '^' Forces the field to be centered within the available space.
Note that unless a minimum field width is defined, the field width will @@ -127,11 +126,29 @@ option has no meaning in this case. The *sign* option is only valid for floating point and signed integer types, and can be one of the following: -| Option | Meaning | -|--------|-------------------------------------------------------------------------------------------------------------| -| `'+'` | indicates that a sign should be used for both nonnegative as well as negative numbers. | -| `'-'` | indicates that a sign should be used only for negative numbers (this is the default behavior). | -| space | indicates that a leading space should be used on nonnegative numbers, and a minus sign on negative numbers. | + + + + + + + + + + + + + +
OptionMeaning
'+' + Indicates that a sign should be used for both nonnegative as well as + negative numbers. + '-' + Indicates that a sign should be used only for negative numbers (this is the + default behavior). + space + Indicates that a leading space should be used on nonnegative numbers, and a + minus sign on negative numbers. +
The `'#'` option causes the "alternate form" to be used for the conversion. The alternate form is defined differently for different @@ -191,16 +208,58 @@ The available character presentation types are: The available integer presentation types are: -| Type | Meaning | -|-------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `'b'` | Binary format. Outputs the number in base 2. Using the `'#'` option with this type adds the prefix `"0b"` to the output value. | -| `'B'` | Binary format. Outputs the number in base 2. Using the `'#'` option with this type adds the prefix `"0B"` to the output value. | -| `'c'` | Character format. Outputs the number as a character. | -| `'d'` | Decimal integer. Outputs the number in base 10. | -| `'o'` | Octal format. Outputs the number in base 8. | -| `'x'` | Hex format. Outputs the number in base 16, using lower-case letters for the digits above 9. Using the `'#'` option with this type adds the prefix `"0x"` to the output value. | -| `'X'` | Hex format. Outputs the number in base 16, using upper-case letters for the digits above 9. Using the `'#'` option with this type adds the prefix `"0X"` to the output value. | -| none | The same as `'d'`. | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TypeMeaning
'b' + Binary format. Outputs the number in base 2. Using the '#' + option with this type adds the prefix "0b" to the output value. +
'B' + Binary format. Outputs the number in base 2. Using the '#' + option with this type adds the prefix "0B" to the output value. +
'c'Character format. Outputs the number as a character.
'd'Decimal integer. Outputs the number in base 10.
'o'Octal format. Outputs the number in base 8.
'x' + Hex format. Outputs the number in base 16, using lower-case letters for the + digits above 9. Using the '#' option with this type adds the + prefix "0x" to the output value. +
'X' + Hex format. Outputs the number in base 16, using upper-case letters for the + digits above 9. Using the '#' option with this type adds the + prefix "0X" to the output value. +
noneThe same as 'd'.
Integer presentation types can also be used with character and Boolean values with the only exception that `'c'` cannot be used with `bool`. Boolean values @@ -209,69 +268,77 @@ presentation type is not specified. The available presentation types for floating-point values are: - ---- - - - - +
TypeMeaning
+ + + - - - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + -
TypeMeaning
'a'Hexadecimal floating point format. Prints the number in base 16 with -prefix "0x" and lower-case letters for digits above 9. Uses -'p' to indicate the exponent.
'a' + Hexadecimal floating point format. Prints the number in base 16 with + prefix "0x" and lower-case letters for digits above 9. + Uses 'p' to indicate the exponent. +
'A'Same as 'a' except it uses upper-case letters for the -prefix, digits above 9 and to indicate the exponent.
'A' + Same as 'a' except it uses upper-case letters for the + prefix, digits above 9 and to indicate the exponent. +
'e'Exponent notation. Prints the number in scientific notation using -the letter 'e' to indicate the exponent.
'e' + Exponent notation. Prints the number in scientific notation using + the letter 'e' to indicate the exponent. +
'E'Exponent notation. Same as 'e' except it uses an -upper-case 'E' as the separator character.
'E' + Exponent notation. Same as 'e' except it uses an + upper-case 'E' as the separator character. +
'f'Fixed point. Displays the number as a fixed-point number.
'f'Fixed point. Displays the number as a fixed-point number.
'F'Fixed point. Same as 'f', but converts nan -to NAN and inf to INF.
'F' + Fixed point. Same as 'f', but converts nan + to NAN and inf to INF. +
'g'

General format. For a given precision p >= 1, -this rounds the number to p significant digits and then -formats the result in either fixed-point format or in scientific -notation, depending on its magnitude.

-

A precision of 0 is treated as equivalent to a precision -of 1.

'g' +

General format. For a given precision p >= 1, + this rounds the number to p significant digits and then + formats the result in either fixed-point format or in scientific + notation, depending on its magnitude.

+

A precision of 0 is treated as equivalent to a precision + of 1.

+
'G'General format. Same as 'g' except switches to -'E' if the number gets too large. The representations of -infinity and NaN are uppercased, too.
'G' + General format. Same as 'g' except switches to + 'E' if the number gets too large. The representations of + infinity and NaN are uppercased, too. +
noneSimilar to 'g', except that the default precision is as -high as needed to represent the particular value.
none + Similar to 'g', except that the default precision is as + high as needed to represent the particular value. +
The available presentation types for pointers are: @@ -288,7 +355,9 @@ as `std::tm` have the following syntax:
-chrono_format_spec ::= [[fill]align][width]["." precision][chrono_specs]
+chrono_format_spec ::= [[fill]align][width]["." precision][chrono_specs]
 chrono_specs       ::= [chrono_specs] conversion_spec | chrono_specs literal_char
 conversion_spec    ::= "%" [padding_modifier] [locale_modifier] chrono_type
 literal_char       ::= <a character other than '{', '}' or '%'>
@@ -359,8 +428,8 @@ The available padding modifiers (*padding_modifier*) are:
 | `'_'` | Do not pad a numeric result string.                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
 | `'0'` | Pad a numeric result string with zeros.                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
 
-Currently, these modifiers are only supported for the ``'H', 'I', 'M', 'S', 'U', 'V'``
-and ``'W'`` presentation types.
+Currently, these modifiers are only supported for the `'H'`, `'I'`, `'M'`,
+`'S'`, `'U'`, `'V'` and `'W'` presentation types.
 
 ## Range Format Specifications