@@ -556,7 +556,7 @@ Users of `rustc` can define new syntax extensions in two ways:
556
556
## Macros
557
557
558
558
` macro_rules ` allows users to define syntax extensions in a declarative way.
559
- We call such extensions "macros by example " or simply "macros" — to be
559
+ We call such extensions "` macro_rules! ` macros " or simply "macros" — to be
560
560
distinguished from the "procedural macros" defined in [ compiler plugins] [ plugin ] .
561
561
562
562
As shown below, the body of a ` macro_rules ` macro consists of one or more
@@ -585,7 +585,7 @@ arm in turn. It transcribes the first successful match. Matching and
585
585
transcription are closely related to each other, and we will describe them
586
586
together.
587
587
588
- ### Macros By Example
588
+ ### Macro By Example
589
589
590
590
The macro expander matches and transcribes every token that does not begin with
591
591
a ` $ ` literally, including delimiters. For parsing reasons, delimiters must be
@@ -619,13 +619,13 @@ matches, in a structure that mimics the structure of the repetition encountered
619
619
on a successful match. The job of the transcriber is to sort that structure
620
620
out.
621
621
622
- The rules for transcription of these repetitions are called "Macros By Example".
622
+ The rules for transcription of these repetitions are called "Macro By Example".
623
623
Essentially, one "layer" of repetition is discharged at a time, and all of them
624
624
must be discharged by the time a name is transcribed. Therefore, `( $( $i: ident
625
625
),* ) => ( $i )` is an invalid macro, but ` ( $( $i: ident ),* ) => ( $( $i ),* )`
626
626
is acceptable (though trivial).
627
627
628
- When Macros By Example encounters a repetition, it examines all of the ` $ `
628
+ When Macro By Example encounters a repetition, it examines all of the ` $ `
629
629
_ name_ s that occur in its body. At the "current layer", they all must repeat
630
630
the same number of times, so ` ( $( $i: ident ),* ; $( $j: ident ),* ) => ( $(
631
631
($i,$j) ),* )` is valid if given the argument ` (a,b,c ; d,e,f)`, but not
0 commit comments