|
300 | 300 | //! it would internally pass around this structure until it has been determined
|
301 | 301 | //! where output should go to.
|
302 | 302 | //!
|
303 |
| -//! # Syntax |
304 |
| -//! |
305 |
| -//! The syntax for the formatting language used is drawn from other languages, |
306 |
| -//! so it should not be too alien. Arguments are formatted with Python-like |
307 |
| -//! syntax, meaning that arguments are surrounded by `{}` instead of the C-like |
308 |
| -//! `%`. The actual grammar for the formatting syntax is: |
309 |
| -//! |
310 |
| -//! ```text |
311 |
| -//! format_string := <text> [ maybe-format <text> ] * |
312 |
| -//! maybe-format := '{' '{' | '}' '}' | <format> |
313 |
| -//! format := '{' [ argument ] [ ':' format_spec ] '}' |
314 |
| -//! argument := integer | identifier |
315 |
| -//! |
316 |
| -//! format_spec := [[fill]align][sign]['#']['0'][width]['.' precision][type] |
317 |
| -//! fill := character |
318 |
| -//! align := '<' | '^' | '>' |
319 |
| -//! sign := '+' | '-' |
320 |
| -//! width := count |
321 |
| -//! precision := count | '*' |
322 |
| -//! type := identifier | '?' | '' |
323 |
| -//! count := parameter | integer |
324 |
| -//! parameter := argument '$' |
325 |
| -//! ``` |
326 |
| -//! |
327 | 303 | //! # Formatting Parameters
|
328 | 304 | //!
|
329 | 305 | //! Each argument being formatted can be transformed by a number of formatting
|
|
479 | 455 | //! them with the same character. For example, the `{` character is escaped with
|
480 | 456 | //! `{{` and the `}` character is escaped with `}}`.
|
481 | 457 | //!
|
| 458 | +//! # Syntax |
| 459 | +//! |
| 460 | +//! Below, you can find the full grammar of format strings. |
| 461 | +//! The syntax for the formatting language used is drawn from other languages, |
| 462 | +//! so it should not be too alien. Arguments are formatted with Python-like |
| 463 | +//! syntax, meaning that arguments are surrounded by `{}` instead of the C-like |
| 464 | +//! `%`. The actual grammar for the formatting syntax is: |
| 465 | +//! |
| 466 | +//! ```text |
| 467 | +//! format_string := <text> [ maybe-format <text> ] * |
| 468 | +//! maybe-format := '{' '{' | '}' '}' | <format> |
| 469 | +//! format := '{' [ argument ] [ ':' format_spec ] '}' |
| 470 | +//! argument := integer | identifier |
| 471 | +//! |
| 472 | +//! format_spec := [[fill]align][sign]['#']['0'][width]['.' precision][type] |
| 473 | +//! fill := character |
| 474 | +//! align := '<' | '^' | '>' |
| 475 | +//! sign := '+' | '-' |
| 476 | +//! width := count |
| 477 | +//! precision := count | '*' |
| 478 | +//! type := identifier | '?' | '' |
| 479 | +//! count := parameter | integer |
| 480 | +//! parameter := argument '$' |
| 481 | +//! ``` |
| 482 | +//! |
482 | 483 | //! [`usize`]: ../../std/primitive.usize.html
|
483 | 484 | //! [`isize`]: ../../std/primitive.isize.html
|
484 | 485 | //! [`i8`]: ../../std/primitive.i8.html
|
|
0 commit comments