|
1 | 1 | # Tokens
|
2 | 2 |
|
3 | 3 | Tokens are primitive productions in the grammar defined by regular
|
4 |
| -(non-recursive) languages. "Simple" tokens are given in [string table |
5 |
| -production] form, and occur in the rest of the |
6 |
| -grammar in `monospace` font. Other tokens have exact rules given. |
| 4 | +(non-recursive) languages. Rust source input can be broken down |
| 5 | +into the following kinds of tokens: |
| 6 | + |
| 7 | +* [Keywords] |
| 8 | +* [Identifiers][identifier] |
| 9 | +* [Literals](#literals) |
| 10 | +* [Lifetimes](#lifetimes-and-loop-labels) |
| 11 | +* [Punctuation](#punctuation) |
| 12 | +* [Delimiters](#delimiters) |
| 13 | + |
| 14 | +Within this documentation's grammar, "simple" tokens are given in [string |
| 15 | +table production] form, and appear in `monospace` font. |
7 | 16 |
|
8 | 17 | [string table production]: notation.html#string-table-productions
|
9 | 18 |
|
@@ -501,21 +510,104 @@ macros.
|
501 | 510 |
|
502 | 511 | [loop labels]: expressions/loop-expr.html
|
503 | 512 |
|
504 |
| -## Symbols |
505 |
| - |
506 |
| -Symbols are a general class of printable [tokens] that play structural |
507 |
| -roles in a variety of grammar productions. They are a |
508 |
| -set of remaining miscellaneous printable tokens that do not |
509 |
| -otherwise appear as [unary operators], [binary |
510 |
| -operators], or [keywords]. |
511 |
| -They are catalogued in [the Symbols section][symbols] of the Grammar document. |
512 |
| - |
513 |
| -[unary operators]: expressions/operator-expr.html#borrow-operators |
514 |
| -[binary operators]: expressions/operator-expr.html#arithmetic-and-logical-binary-operators |
| 513 | +## Punctuation |
| 514 | + |
| 515 | +Punctuation symbol tokens are listed here for completeness. Their individual |
| 516 | +usages and meanings are defined in the linked pages. |
| 517 | + |
| 518 | +| Symbol | Name | Usage | |
| 519 | +|--------|-------------|-------| |
| 520 | +| `+` | Plus | [Addition][arith], [Trait Bounds], [Macro Kleene Matcher][macros] |
| 521 | +| `-` | Minus | [Subtraction][arith], [Negation] |
| 522 | +| `*` | Star | [Multiplication][arith], [Dereference], [Raw Pointers], [Macro Kleene Matcher][macros] |
| 523 | +| `/` | Slash | [Division][arith] |
| 524 | +| `%` | Percent | [Remainder][arith] |
| 525 | +| `^` | Caret | [Bitwise and Logical XOR][arith] |
| 526 | +| `!` | Not | [Bitwise and Logical NOT][negation], [Macro Calls][macros], [Inner Attributes][attributes], [Never Type] |
| 527 | +| `&` | And | [Bitwise and Logcal AND][arith], [Borrow], [References] |
| 528 | +| <code>\|</code> | Or | [Bitwise and Logical OR][arith], [Closures], [Match] |
| 529 | +| `&&` | AndAnd | [Lazy AND][lazy-bool], [Borrow], [References] |
| 530 | +| <code>\|\|</code> | OrOr | [Lazy OR][lazy-bool], [Closures] |
| 531 | +| `<<` | Shl | [Shift Left][arith], [Nested Generics][generics] |
| 532 | +| `>>` | Shr | [Shift Right][arith], [Nested Generics][generics] |
| 533 | +| `+=` | PlusEq | [Addition assignment][compound] |
| 534 | +| `-=` | MinusEq | [Subtraction assignment][compound] |
| 535 | +| `*=` | StarEq | [Multiplication assignment][compound] |
| 536 | +| `/=` | SlashEq | [Division assignment][compound] |
| 537 | +| `%=` | PercentEq | [Remainder assignment][compound] |
| 538 | +| `^=` | CaretEq | [Bitwise XOR assignment][compound] |
| 539 | +| `&=` | AndEq | [Bitwise And assignment][compound] |
| 540 | +| <code>\|=</code> | OrEq | [Bitwise Or assignment][compound] |
| 541 | +| `<<=` | ShlEq | [Shift Left assignment][compound] |
| 542 | +| `>>=` | ShrEq | [Shift Right assignment][compound], [Nested Generics][generics] |
| 543 | +| `=` | Eq | [Assignment], [Attributes], Various type definitions |
| 544 | +| `==` | EqEq | [Equal][comparison] |
| 545 | +| `!=` | Ne | [Not Equal][comparison] |
| 546 | +| `>` | Gt | [Greater than][comparison], [Generics], [Paths] |
| 547 | +| `<` | Lt | [Less than][comparison], [Generics], [Paths] |
| 548 | +| `>=` | Ge | [Greater than or equal to][comparison], [Generics] |
| 549 | +| `<=` | Le | [Less than or equal to][comparison] |
| 550 | +| `@` | At | [Subpattern binding][match] |
| 551 | +| `_` | Underscore | [Placeholder patterns][match], Inferred types |
| 552 | +| `.` | Dot | [Field access][field], [Tuple index] |
| 553 | +| `..` | DotDot | [Range][range], [Struct expressions], [Wildcard patterns][match] |
| 554 | +| `...` | DotDotDot | [Variadic functions][extern] |
| 555 | +| `..=` | DotDotEq | [Inclusive Range][range] |
| 556 | +| `,` | Comma | Various separators |
| 557 | +| `;` | Semi | Terminator for various items and statements, [Array types] |
| 558 | +| `:` | Colon | Various separators |
| 559 | +| `::` | PathSep | [Path separator][paths] |
| 560 | +| `->` | RArrow | [Function return type][functions], [Closure return type][closures] |
| 561 | +| `=>` | FatArrow | [Match arms][match], [Macros] |
| 562 | +| `#` | Pound | [Attributes] |
| 563 | +| `$` | Dollar | [Macros] |
| 564 | +| `?` | Question | [Question mark operator][question], [Questionably sized][sized] |
| 565 | + |
| 566 | +## Delimiters |
| 567 | + |
| 568 | +Bracket punctuation is used in various parts of the grammar. An open bracket |
| 569 | +must always be paired with a close bracket. Brackets and the tokens within |
| 570 | +them are referred to as "token trees" in [macros]. The three types of brackets are: |
| 571 | + |
| 572 | +| Bracket | Type | |
| 573 | +|---------|-----------------| |
| 574 | +| `{` `}` | Curly braces | |
| 575 | +| `[` `]` | Square brackets | |
| 576 | +| `(` `)` | Parentheses | |
| 577 | + |
| 578 | + |
| 579 | +[Operator expressions]: expressions/operator-expr.html |
515 | 580 | [tokens]: #tokens
|
516 |
| -[symbols]: ../grammar.html#symbols |
517 | 581 | [keywords]: keywords.html
|
518 | 582 | [identifier]: identifiers.html
|
519 | 583 | [tuples]: types.html#tuple-types
|
520 | 584 | [tuple structs]: items/structs.html
|
521 | 585 | [tuple variants]: items/enumerations.html
|
| 586 | +[arith]: expressions/operator-expr.html#arithmetic-and-logical-binary-operators |
| 587 | +[negation]: expressions/operator-expr.html#negation-operators |
| 588 | +[lazy-bool]: expressions/operator-expr.html#lazy-boolean-operators |
| 589 | +[compound]: /expressions/operator-expr.html#compound-assignment-expressions |
| 590 | +[comparison]: expressions/operator-expr.html#comparison-operators |
| 591 | +[match]: expressions/match-expr.html |
| 592 | +[field]: expressions/field-expr.html |
| 593 | +[range]: expressions/range-expr.html |
| 594 | +[trait bounds]: trait-bounds.html |
| 595 | +[dereference]: expressions/operator-expr.html#the-dereference-operator |
| 596 | +[raw pointers]: types.html#raw-pointers-const-and-mut |
| 597 | +[macros]: macros-by-example.html |
| 598 | +[attributes]: attributes.html |
| 599 | +[never type]: types.html#never-type |
| 600 | +[borrow]: expressions/operator-expr.html#borrow-operators |
| 601 | +[references]: types.html#pointer-types |
| 602 | +[closures]: expressions/closure-expr.html |
| 603 | +[assignment]: expressions/operator-expr.html#assignment-expressions |
| 604 | +[constant items]: items/constant-items.html |
| 605 | +[generics]: items/generics.html |
| 606 | +[paths]: paths.html |
| 607 | +[array types]: types.html#array-and-slice-types |
| 608 | +[functions]: items/functions.html |
| 609 | +[question]: expressions/operator-expr.html#the-question-mark-operator |
| 610 | +[sized]: trait-bounds.html#sized |
| 611 | +[extern]: items/external-blocks.html |
| 612 | +[struct expressions]: expressions/struct-expr.html |
| 613 | +[tuple index]: expressions/tuple-expr.html#tuple-indexing-expressions |
0 commit comments