Skip to content

Commit

Permalink
docs: formatting grammar language changed to EBNF
Browse files Browse the repository at this point in the history
  • Loading branch information
mpusz committed May 5, 2024
1 parent 79a1d61 commit 901b5e5
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 53 deletions.
56 changes: 28 additions & 28 deletions docs/users_guide/framework_basics/text_output.md
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,10 @@ as text and, thus, are aligned to the left by default.
### Dimension formatting
```bnf
dimension-format-spec ::= [fill-and-align] [width] [dimension-spec]
dimension-spec ::= [text-encoding]
text-encoding ::= 'U' | 'A'
```ebnf
dimension-format-spec = [fill-and-align], [width], [dimension-spec];
dimension-spec = [text-encoding];
text-encoding = 'U' | 'A';
```

In the above grammar:
Expand All @@ -429,16 +429,16 @@ std::println("{:A}", isq::power.dimension); // L^2MT^-3
### Unit formatting
```bnf
unit-format-spec ::= [fill-and-align] [width] [unit-spec]
unit-spec ::= [text-encoding] [unit-symbol-solidus] [unit-symbol-separator] [L]
[text-encoding] [unit-symbol-separator] [unit-symbol-solidus] [L]
[unit-symbol-solidus] [text-encoding] [unit-symbol-separator] [L]
[unit-symbol-solidus] [unit-symbol-separator] [text-encoding] [L]
[unit-symbol-separator] [text-encoding] [unit-symbol-solidus] [L]
[unit-symbol-separator] [unit-symbol-solidus] [text-encoding] [L]
unit-symbol-solidus ::= '1' | 'a' | 'n'
unit-symbol-separator ::= 's' | 'd'
```ebnf
unit-format-spec = [fill-and-align], [width], [unit-spec];
unit-spec = [text-encoding], [unit-symbol-solidus], [unit-symbol-separator], [L]
| [text-encoding], [unit-symbol-separator], [unit-symbol-solidus], [L]
| [unit-symbol-solidus], [text-encoding], [unit-symbol-separator], [L]
| [unit-symbol-solidus], [unit-symbol-separator], [text-encoding], [L]
| [unit-symbol-separator], [text-encoding], [unit-symbol-solidus], [L]
| [unit-symbol-separator], [unit-symbol-solidus], [text-encoding], [L];
unit-symbol-solidus = '1' | 'a' | 'n';
unit-symbol-separator = 's' | 'd';
```

In the above grammar:
Expand Down Expand Up @@ -528,20 +528,20 @@ std::println("{:d}", kg * m2 / s2); // kg⋅m²/s²
### Quantity formatting
```bnf
quantity-format-spec ::= [fill-and-align] [width] [quantity-specs] [defaults-specs]
quantity-specs ::= conversion-spec
quantity-specs conversion-spec
quantity-specs literal-char
literal-char ::= <any character other than '{', '}', or '%'>
conversion-spec ::= '%' placement-type
placement-type ::= subentity-id | '?' | '%'
defaults-specs ::= ':' default-spec-list
default-spec-list ::= default-spec
default-spec-list default-spec
default-spec ::= subentity-id '[' format-spec ']'
subentity-id ::= 'N' | 'U' | 'D'
format-spec ::= <as specified by the formatter for the argument type>
```ebnf
quantity-format-spec = [fill-and-align], [width], [quantity-specs], [defaults-specs];
quantity-specs = conversion-spec;
| quantity-specs, conversion-spec;
| quantity-specs, literal-char;
literal-char = ? any character other than '{', '}', or '%' ?;
conversion-spec = '%', placement-type;
placement-type = subentity-id | '?' | '%';
defaults-specs = ':', default-spec-list;
default-spec-list = default-spec;
| default-spec-list, default-spec;
default-spec = subentity-id, '[' format-spec ']';
subentity-id = 'N' | 'U' | 'D';
format-spec = ? as specified by the formatter for the argument type ?;
```

In the above grammar:
Expand Down
50 changes: 25 additions & 25 deletions src/core/include/mp-units/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ OutputIt format_global_buffer(OutputIt out, const fill_align_width_format_specs<
//
// Grammar
//
// dimension-format-spec ::= [fill-and-align] [width] [dimension-spec]
// dimension-spec ::= [text-encoding]
// text-encoding ::= 'U' | 'A'
// dimension-format-spec = [fill-and-align], [width], [dimension-spec];
// dimension-spec = [text-encoding];
// text-encoding = 'U' | 'A';
//
template<mp_units::Dimension D, typename Char>
class MP_UNITS_STD_FMT::formatter<D, Char> {
Expand Down Expand Up @@ -159,15 +159,15 @@ class MP_UNITS_STD_FMT::formatter<D, Char> {
//
// Grammar
//
// unit-format-spec ::= [fill-and-align] [width] [unit-spec]
// unit-spec ::= [text-encoding] [unit-symbol-solidus] [unit-symbol-separator] [L]
// [text-encoding] [unit-symbol-separator] [unit-symbol-solidus] [L]
// [unit-symbol-solidus] [text-encoding] [unit-symbol-separator] [L]
// [unit-symbol-solidus] [unit-symbol-separator] [text-encoding] [L]
// [unit-symbol-separator] [text-encoding] [unit-symbol-solidus] [L]
// [unit-symbol-separator] [unit-symbol-solidus] [text-encoding] [L]
// unit-symbol-solidus ::= '1' | 'a' | 'n'1
// unit-symbol-separator ::= 's' | 'd'
// unit-format-spec = [fill-and-align], [width], [unit-spec];
// unit-spec = [text-encoding], [unit-symbol-solidus], [unit-symbol-separator], [L]
// | [text-encoding], [unit-symbol-separator], [unit-symbol-solidus], [L]
// | [unit-symbol-solidus], [text-encoding], [unit-symbol-separator], [L]
// | [unit-symbol-solidus], [unit-symbol-separator], [text-encoding], [L]
// | [unit-symbol-separator], [text-encoding], [unit-symbol-solidus], [L]
// | [unit-symbol-separator], [unit-symbol-solidus], [text-encoding], [L];
// unit-symbol-solidus = '1' | 'a' | 'n';
// unit-symbol-separator = 's' | 'd';
//
template<mp_units::Unit U, typename Char>
class MP_UNITS_STD_FMT::formatter<U, Char> {
Expand Down Expand Up @@ -249,19 +249,19 @@ class MP_UNITS_STD_FMT::formatter<U, Char> {
//
// Grammar
//
// quantity-format-spec ::= [fill-and-align] [width] [quantity-specs] [defaults-specs]
// quantity-specs ::= conversion-spec
// quantity-specs conversion-spec
// quantity-specs literal-char
// literal-char ::= <any character other than '{', '}', or '%'>
// conversion-spec ::= '%' placement-type
// placement-type ::= subentity-id | '?' | '%'
// defaults-specs ::= ':' default-spec-list
// default-spec-list ::= default-spec
// default-spec-list default-spec
// default-spec ::= subentity-id '[' format-spec ']'
// subentity-id ::= 'N' | 'U' | 'D'
// format-spec ::= <as specified by the formatter for the argument type>
// quantity-format-spec = [fill-and-align], [width], [quantity-specs], [defaults-specs];
// quantity-specs = conversion-spec;
// | quantity-specs, conversion-spec;
// | quantity-specs, literal-char;
// literal-char = ? any character other than '{', '}', or '%' ?;
// conversion-spec = '%', placement-type;
// placement-type = subentity-id | '?' | '%';
// defaults-specs = ':', default-spec-list;
// default-spec-list = default-spec;
// | default-spec-list, default-spec;
// default-spec = subentity-id, '[' format-spec ']';
// subentity-id = 'N' | 'U' | 'D';
// format-spec = ? as specified by the formatter for the argument type ?;
//
#if __cpp_lib_format_ranges && !MP_UNITS_USE_FMTLIB
template<auto Reference, typename Char, std::formattable<Char> Rep>
Expand Down

0 comments on commit 901b5e5

Please sign in to comment.