@@ -51,17 +51,23 @@ designator is already known, and so only the name of a matched nonterminal comes
51
51
after the dollar sign.
52
52
53
53
In both the matcher and transcriber, the Kleene star-like operator indicates
54
- repetition. The Kleene star operator consists of ` $ ` and parentheses, optionally
55
- followed by a separator token, followed by ` * ` or ` + ` . ` * ` means zero or more
56
- repetitions, ` + ` means at least one repetition. The parentheses are not matched or
57
- transcribed. On the matcher side, a name is bound to _ all_ of the names it
58
- matches, in a structure that mimics the structure of the repetition encountered
59
- on a successful match. The job of the transcriber is to sort that structure
60
- out.
61
-
62
- > ** Edition Differences** : In the 2018 edition, a new Kleene operator was
63
- > added: ` ? ` means "at most once". This operator only works in edition 2018 and
64
- > onward. ` ? ` does not accept a repetition separator, unlike ` + ` and ` * ` .
54
+ repetition. The Kleene star operator consists of ` $ ` and parentheses,
55
+ optionally followed by a separator token, followed by ` * ` , ` + ` , or ` ? ` . ` * `
56
+ means zero or more repetitions; ` + ` means _ at least_ one repetition; ` ? ` means
57
+ at most one repetition. The parentheses are not matched or transcribed. On the
58
+ matcher side, a name is bound to _ all_ of the names it matches, in a structure
59
+ that mimics the structure of the repetition encountered on a successful match.
60
+ The job of the transcriber is to sort that structure out. Also, ` ? ` , unlike ` * `
61
+ and ` + ` , does _ not_ allow a separator, since one could never match against it
62
+ anyway.
63
+
64
+ > ** Edition Differences** : The ` ? ` Kleene operator did not exist before the
65
+ > 2018 edition.
66
+
67
+ > ** Edition Differences** : Prior to the 2018 Edition, ` ? ` was an allowed
68
+ > separator token, rather than a Kleene operator. It is no longer allowed as a
69
+ > separator as of the 2018 edition. This avoids ambiguity with the ` ? ` Kleene
70
+ > operator.
65
71
66
72
The rules for transcription of these repetitions are called "Macro By Example".
67
73
Essentially, one "layer" of repetition is discharged at a time, and all of them
@@ -93,8 +99,4 @@ Rust syntax is restricted in two ways:
93
99
pairs when they occur at the beginning of, or immediately after, a ` $(...)* ` ;
94
100
requiring a distinctive token in front can solve the problem.
95
101
96
- > ** Edition Differences** : As of the 2018 edition, ` ? ` is not allowed as a
97
- > repetition separator. This is to remove ambiguity with the new ` ? ` Kleene
98
- > operator.
99
-
100
102
[ RFC 550 ] : https://github.com/rust-lang/rfcs/blob/master/text/0550-macro-future-proofing.md
0 commit comments