@@ -20,7 +20,7 @@ of this text is copied, and expanded upon in subsequent RFCs.
20
20
character.
21
21
- ` simple NT ` : a "meta-variable" non-terminal (further discussion below).
22
22
- ` complex NT ` : a repetition matching non-terminal, specified via repetition
23
- operators (` \ *` , ` + ` , ` ? ` ).
23
+ operators (` * ` , ` + ` , ` ? ` ).
24
24
- ` token ` : an atomic element of a matcher; i.e. identifiers, operators,
25
25
open/close delimiters, * and* simple NT's.
26
26
- ` token tree ` : a tree structure formed from tokens (the leaves), complex
@@ -46,12 +46,12 @@ macro_rules! i_am_an_mbe {
46
46
}
47
47
```
48
48
49
- ` (start $foo:expr $($i:ident),\ * end) ` is a matcher. The whole matcher is a
49
+ ` (start $foo:expr $($i:ident),* end) ` is a matcher. The whole matcher is a
50
50
delimited sequence (with open- and close-delimiters ` ( ` and ` ) ` ), and ` $foo `
51
51
and ` $i ` are simple NT's with ` expr ` and ` ident ` as their respective fragment
52
52
specifiers.
53
53
54
- ` $(i:ident),\ * ` is * also* an NT; it is a complex NT that matches a
54
+ ` $(i:ident),* ` is * also* an NT; it is a complex NT that matches a
55
55
comma-separated repetition of identifiers. The ` , ` is the separator token for
56
56
the complex NT; it occurs in between each pair of elements (if any) of the
57
57
matched fragment.
@@ -72,7 +72,7 @@ its additional role as a fragment specifier; but it will be clear from context
72
72
which interpretation is meant.)
73
73
74
74
"SEP" will range over separator tokens, "OP" over the repetition operators
75
- ` \ *` , ` + ` , and ` ? ` , "OPEN"/"CLOSE" over matching token pairs surrounding a
75
+ ` * ` , ` + ` , and ` ? ` , "OPEN"/"CLOSE" over matching token pairs surrounding a
76
76
delimited sequence (e.g. ` [ ` and ` ] ` ).
77
77
78
78
Greek letters "α" "β" "γ" "δ" stand for potentially empty token-tree sequences.
@@ -110,7 +110,7 @@ of FIRST and FOLLOW are described later.
110
110
1 . For any separated complex NT in a matcher, ` M = ... $(tt ...) SEP OP ... ` ,
111
111
we must have ` SEP ` ∈ FOLLOW(` tt ... ` ).
112
112
1 . For an unseparated complex NT in a matcher, ` M = ... $(tt ...) OP ... ` , if
113
- OP = ` \ *` or ` + ` , we must have FOLLOW(` tt ... ` ) ⊇ FIRST(` tt ... ` ).
113
+ OP = ` * ` or ` + ` , we must have FOLLOW(` tt ... ` ) ⊇ FIRST(` tt ... ` ).
114
114
115
115
The first invariant says that whatever actual token that comes after a matcher,
116
116
if any, must be somewhere in the predetermined follow set. This ensures that a
@@ -202,7 +202,7 @@ first token-tree (if any):
202
202
* Let SEP\_ SET(M) = { SEP } if SEP is present and ε ∈ FIRST(` tt ... ` );
203
203
otherwise SEP\_ SET(M) = {}.
204
204
205
- * Let ALPHA\_ SET(M) = FIRST(` α ` ) if OP = ` \ *` or ` ? ` and ALPHA\_ SET(M) = {} if
205
+ * Let ALPHA\_ SET(M) = FIRST(` α ` ) if OP = ` * ` or ` ? ` and ALPHA\_ SET(M) = {} if
206
206
OP = ` + ` .
207
207
* FIRST(M) = (FIRST(` tt ... ` ) \\ {ε}) ∪ SEP\_ SET(M) ∪ ALPHA\_ SET(M).
208
208
@@ -211,7 +211,7 @@ the possibility that the separator could be a valid first token for M, which
211
211
happens when there is a separator defined and the repeated fragment could be
212
212
empty. ALPHA\_ SET(M) defines the possibility that the complex NT could be empty,
213
213
meaning that M's valid first tokens are those of the following token-tree
214
- sequences ` α ` . This occurs when either ` \ *` or ` ? ` is used, in which case there
214
+ sequences ` α ` . This occurs when either ` * ` or ` ? ` is used, in which case there
215
215
could be zero repetitions. In theory, this could also occur if ` + ` was used with
216
216
a potentially-empty repeating fragment, but this is forbidden by the third
217
217
invariant.
@@ -339,17 +339,17 @@ represent simple nonterminals with the given fragment specifier.
339
339
* FOLLOW(M), for any other M, is defined as the intersection, as t ranges over
340
340
(LAST(M) \ {ε}), of FOLLOW(t).
341
341
342
- The tokens that can begin a type are, as of this writing, {` ( ` , ` [ ` , ` ! ` , ` \ *` ,
342
+ The tokens that can begin a type are, as of this writing, {` ( ` , ` [ ` , ` ! ` , ` * ` ,
343
343
` & ` , ` && ` , ` ? ` , lifetimes, ` > ` , ` >> ` , ` :: ` , any non-keyword identifier, ` super ` ,
344
344
` self ` , ` Self ` , ` extern ` , ` crate ` , ` $crate ` , ` _ ` , ` for ` , ` impl ` , ` fn ` , ` unsafe ` ,
345
345
` typeof ` , ` dyn ` }, although this list may not be complete because people won't
346
346
always remember to update the appendix when new ones are added.
347
347
348
348
Examples of FOLLOW for complex M:
349
349
350
- * FOLLOW(` $( $d:ident $e:expr )\ * ` ) = FOLLOW(` $e:expr ` )
351
- * FOLLOW(` $( $d:ident $e:expr )\ * $(;)\ * ` ) = FOLLOW(` $e:expr ` ) ∩ ANYTOKEN = FOLLOW(` $e:expr ` )
352
- * FOLLOW(` $( $d:ident $e:expr )\ * $(;)\ * $( f |)+ ` ) = ANYTOKEN
350
+ * FOLLOW(` $( $d:ident $e:expr )* ` ) = FOLLOW(` $e:expr ` )
351
+ * FOLLOW(` $( $d:ident $e:expr )* $(;)* ` ) = FOLLOW(` $e:expr ` ) ∩ ANYTOKEN = FOLLOW(` $e:expr ` )
352
+ * FOLLOW(` $( $d:ident $e:expr )* $(;)* $( f |)+ ` ) = ANYTOKEN
353
353
354
354
### Examples of valid and invalid matchers
355
355
0 commit comments