Skip to content

Commit bb4dd06

Browse files
committed
manual: Lightly copyedit the macros section
1 parent 140d16a commit bb4dd06

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

doc/rust.md

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -501,14 +501,13 @@ only be invoked in expression position.
501501
any token other than a delimiter or `$`.)
502502

503503
Macro invocations are looked up by name, and each macro rule is tried in turn;
504-
the first successful match is transcribed. The matching and transcribing
504+
the first successful match is transcribed. The matching and transcription
505505
processes are closely related, and will be described together:
506506

507507
### Macro By Example
508508

509-
Everything that does not begin with a `$` is matched and transcirbed
510-
literally, including delimiters. For parsing reasons, they must be matched,
511-
but they are otherwise not special.
509+
The macro expander matches and transcribes every token that does not begin with a `$` literally, including delimiters.
510+
For parsing reasons, delimiters must be balanced, but they are otherwise not special.
512511

513512
In the matcher, `$` _name_ `:` _designator_ matches the nonterminal in the
514513
Rust syntax named by _designator_. Valid designators are `item`, `block`,
@@ -517,11 +516,11 @@ are the right-hand side and the left-hand side respectively of the `=>` in
517516
macro rules. In the transcriber, the designator is already known, and so only
518517
the name of a matched nonterminal comes after the dollar sign.
519518

520-
In bothe the matcher and transcriber, the Kleene star-like operator,
521-
consisting of `$` and parens, optionally followed by a separator token,
522-
followed by `*` or `+`, indicates repetition. (`*` means zero or more
523-
repetitions, `+` means at least one repetition. The parens are not matched or
524-
transcribed). On the matcher side, a name is bound to _all_ of the names it
519+
In both the matcher and transcriber, the Kleene star-like operator indicates repetition.
520+
The Kleene star operator consists of `$` and parens, optionally followed by a separator token, followed by `*` or `+`.
521+
`*` means zero or more repetitions, `+` means at least one repetition.
522+
The parens are not matched or transcribed.
523+
On the matcher side, a name is bound to _all_ of the names it
525524
matches, in a structure that mimics the structure of the repetition
526525
encountered on a successful match. The job of the transcriber is to sort that
527526
structure out.
@@ -550,19 +549,16 @@ Rust syntax is restricted in two ways:
550549
1. The parser will always parse as much as possible. If it attempts to match
551550
`$i:expr [ , ]` against `8 [ , ]`, it will attempt to parse `i` as an array
552551
index operation and fail. Adding a separator can solve this problem.
553-
2. The parser must have eliminated all ambiguity by the time it reaches a
554-
`$` _name_ `:` _designator_. This most often affects them when they occur in
555-
the beginning of, or immediately after, a `$(...)*`; requiring a distinctive
556-
token in front can solve the problem.
552+
2. The parser must have eliminated all ambiguity by the time it reaches a `$` _name_ `:` _designator_.
553+
This requirement most often affects name-designator pairs when they occur at the beginning of, or immediately after, a `$(...)*`; requiring a distinctive token in front can solve the problem.
557554

558555

559556
## Syntax extensions useful for the macro author
560557

561558
* `log_syntax!` : print out the arguments at compile time
562-
* `trace_macros!` : supply `true` or `false` to enable or disable printing
563-
of the macro expansion process.
564-
* `ident_to_str!` : turns the identifier argument into a string literal
565-
* `concat_idents!` : creates a new identifier by concatenating its arguments
559+
* `trace_macros!` : supply `true` or `false` to enable or disable printing of the macro expansion process.
560+
* `ident_to_str!` : turn the identifier argument into a string literal
561+
* `concat_idents!` : create a new identifier by concatenating the arguments
566562

567563

568564

0 commit comments

Comments
 (0)