mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-30 02:17:16 +02:00
docs: formatting grammar language changed to EBNF
This commit is contained in:
@ -399,10 +399,10 @@ as text and, thus, are aligned to the left by default.
|
|||||||
|
|
||||||
### Dimension formatting
|
### Dimension formatting
|
||||||
|
|
||||||
```bnf
|
```ebnf
|
||||||
dimension-format-spec ::= [fill-and-align] [width] [dimension-spec]
|
dimension-format-spec = [fill-and-align], [width], [dimension-spec];
|
||||||
dimension-spec ::= [text-encoding]
|
dimension-spec = [text-encoding];
|
||||||
text-encoding ::= 'U' | 'A'
|
text-encoding = 'U' | 'A';
|
||||||
```
|
```
|
||||||
|
|
||||||
In the above grammar:
|
In the above grammar:
|
||||||
@ -429,16 +429,16 @@ std::println("{:A}", isq::power.dimension); // L^2MT^-3
|
|||||||
|
|
||||||
### Unit formatting
|
### Unit formatting
|
||||||
|
|
||||||
```bnf
|
```ebnf
|
||||||
unit-format-spec ::= [fill-and-align] [width] [unit-spec]
|
unit-format-spec = [fill-and-align], [width], [unit-spec];
|
||||||
unit-spec ::= [text-encoding] [unit-symbol-solidus] [unit-symbol-separator] [L]
|
unit-spec = [text-encoding], [unit-symbol-solidus], [unit-symbol-separator], [L]
|
||||||
[text-encoding] [unit-symbol-separator] [unit-symbol-solidus] [L]
|
| [text-encoding], [unit-symbol-separator], [unit-symbol-solidus], [L]
|
||||||
[unit-symbol-solidus] [text-encoding] [unit-symbol-separator] [L]
|
| [unit-symbol-solidus], [text-encoding], [unit-symbol-separator], [L]
|
||||||
[unit-symbol-solidus] [unit-symbol-separator] [text-encoding] [L]
|
| [unit-symbol-solidus], [unit-symbol-separator], [text-encoding], [L]
|
||||||
[unit-symbol-separator] [text-encoding] [unit-symbol-solidus] [L]
|
| [unit-symbol-separator], [text-encoding], [unit-symbol-solidus], [L]
|
||||||
[unit-symbol-separator] [unit-symbol-solidus] [text-encoding] [L]
|
| [unit-symbol-separator], [unit-symbol-solidus], [text-encoding], [L];
|
||||||
unit-symbol-solidus ::= '1' | 'a' | 'n'
|
unit-symbol-solidus = '1' | 'a' | 'n';
|
||||||
unit-symbol-separator ::= 's' | 'd'
|
unit-symbol-separator = 's' | 'd';
|
||||||
```
|
```
|
||||||
|
|
||||||
In the above grammar:
|
In the above grammar:
|
||||||
@ -528,20 +528,20 @@ std::println("{:d}", kg * m2 / s2); // kg⋅m²/s²
|
|||||||
|
|
||||||
### Quantity formatting
|
### Quantity formatting
|
||||||
|
|
||||||
```bnf
|
```ebnf
|
||||||
quantity-format-spec ::= [fill-and-align] [width] [quantity-specs] [defaults-specs]
|
quantity-format-spec = [fill-and-align], [width], [quantity-specs], [defaults-specs];
|
||||||
quantity-specs ::= conversion-spec
|
quantity-specs = conversion-spec;
|
||||||
quantity-specs conversion-spec
|
| quantity-specs, conversion-spec;
|
||||||
quantity-specs literal-char
|
| quantity-specs, literal-char;
|
||||||
literal-char ::= <any character other than '{', '}', or '%'>
|
literal-char = ? any character other than '{', '}', or '%' ?;
|
||||||
conversion-spec ::= '%' placement-type
|
conversion-spec = '%', placement-type;
|
||||||
placement-type ::= subentity-id | '?' | '%'
|
placement-type = subentity-id | '?' | '%';
|
||||||
defaults-specs ::= ':' default-spec-list
|
defaults-specs = ':', default-spec-list;
|
||||||
default-spec-list ::= default-spec
|
default-spec-list = default-spec;
|
||||||
default-spec-list default-spec
|
| default-spec-list, default-spec;
|
||||||
default-spec ::= subentity-id '[' format-spec ']'
|
default-spec = subentity-id, '[' format-spec ']';
|
||||||
subentity-id ::= 'N' | 'U' | 'D'
|
subentity-id = 'N' | 'U' | 'D';
|
||||||
format-spec ::= <as specified by the formatter for the argument type>
|
format-spec = ? as specified by the formatter for the argument type ?;
|
||||||
```
|
```
|
||||||
|
|
||||||
In the above grammar:
|
In the above grammar:
|
||||||
|
@ -94,9 +94,9 @@ OutputIt format_global_buffer(OutputIt out, const fill_align_width_format_specs<
|
|||||||
//
|
//
|
||||||
// Grammar
|
// Grammar
|
||||||
//
|
//
|
||||||
// dimension-format-spec ::= [fill-and-align] [width] [dimension-spec]
|
// dimension-format-spec = [fill-and-align], [width], [dimension-spec];
|
||||||
// dimension-spec ::= [text-encoding]
|
// dimension-spec = [text-encoding];
|
||||||
// text-encoding ::= 'U' | 'A'
|
// text-encoding = 'U' | 'A';
|
||||||
//
|
//
|
||||||
template<mp_units::Dimension D, typename Char>
|
template<mp_units::Dimension D, typename Char>
|
||||||
class MP_UNITS_STD_FMT::formatter<D, Char> {
|
class MP_UNITS_STD_FMT::formatter<D, Char> {
|
||||||
@ -159,15 +159,15 @@ public:
|
|||||||
//
|
//
|
||||||
// Grammar
|
// Grammar
|
||||||
//
|
//
|
||||||
// unit-format-spec ::= [fill-and-align] [width] [unit-spec]
|
// unit-format-spec = [fill-and-align], [width], [unit-spec];
|
||||||
// unit-spec ::= [text-encoding] [unit-symbol-solidus] [unit-symbol-separator] [L]
|
// unit-spec = [text-encoding], [unit-symbol-solidus], [unit-symbol-separator], [L]
|
||||||
// [text-encoding] [unit-symbol-separator] [unit-symbol-solidus] [L]
|
// | [text-encoding], [unit-symbol-separator], [unit-symbol-solidus], [L]
|
||||||
// [unit-symbol-solidus] [text-encoding] [unit-symbol-separator] [L]
|
// | [unit-symbol-solidus], [text-encoding], [unit-symbol-separator], [L]
|
||||||
// [unit-symbol-solidus] [unit-symbol-separator] [text-encoding] [L]
|
// | [unit-symbol-solidus], [unit-symbol-separator], [text-encoding], [L]
|
||||||
// [unit-symbol-separator] [text-encoding] [unit-symbol-solidus] [L]
|
// | [unit-symbol-separator], [text-encoding], [unit-symbol-solidus], [L]
|
||||||
// [unit-symbol-separator] [unit-symbol-solidus] [text-encoding] [L]
|
// | [unit-symbol-separator], [unit-symbol-solidus], [text-encoding], [L];
|
||||||
// unit-symbol-solidus ::= '1' | 'a' | 'n'1
|
// unit-symbol-solidus = '1' | 'a' | 'n';
|
||||||
// unit-symbol-separator ::= 's' | 'd'
|
// unit-symbol-separator = 's' | 'd';
|
||||||
//
|
//
|
||||||
template<mp_units::Unit U, typename Char>
|
template<mp_units::Unit U, typename Char>
|
||||||
class MP_UNITS_STD_FMT::formatter<U, Char> {
|
class MP_UNITS_STD_FMT::formatter<U, Char> {
|
||||||
@ -249,19 +249,19 @@ public:
|
|||||||
//
|
//
|
||||||
// Grammar
|
// Grammar
|
||||||
//
|
//
|
||||||
// quantity-format-spec ::= [fill-and-align] [width] [quantity-specs] [defaults-specs]
|
// quantity-format-spec = [fill-and-align], [width], [quantity-specs], [defaults-specs];
|
||||||
// quantity-specs ::= conversion-spec
|
// quantity-specs = conversion-spec;
|
||||||
// quantity-specs conversion-spec
|
// | quantity-specs, conversion-spec;
|
||||||
// quantity-specs literal-char
|
// | quantity-specs, literal-char;
|
||||||
// literal-char ::= <any character other than '{', '}', or '%'>
|
// literal-char = ? any character other than '{', '}', or '%' ?;
|
||||||
// conversion-spec ::= '%' placement-type
|
// conversion-spec = '%', placement-type;
|
||||||
// placement-type ::= subentity-id | '?' | '%'
|
// placement-type = subentity-id | '?' | '%';
|
||||||
// defaults-specs ::= ':' default-spec-list
|
// defaults-specs = ':', default-spec-list;
|
||||||
// default-spec-list ::= default-spec
|
// default-spec-list = default-spec;
|
||||||
// default-spec-list default-spec
|
// | default-spec-list, default-spec;
|
||||||
// default-spec ::= subentity-id '[' format-spec ']'
|
// default-spec = subentity-id, '[' format-spec ']';
|
||||||
// subentity-id ::= 'N' | 'U' | 'D'
|
// subentity-id = 'N' | 'U' | 'D';
|
||||||
// format-spec ::= <as specified by the formatter for the argument type>
|
// format-spec = ? as specified by the formatter for the argument type ?;
|
||||||
//
|
//
|
||||||
#if __cpp_lib_format_ranges && !MP_UNITS_USE_FMTLIB
|
#if __cpp_lib_format_ranges && !MP_UNITS_USE_FMTLIB
|
||||||
template<auto Reference, typename Char, std::formattable<Char> Rep>
|
template<auto Reference, typename Char, std::formattable<Char> Rep>
|
||||||
|
Reference in New Issue
Block a user