Skip to content

Commit 68ecb34

Browse files
committed
Minor fixes, adjustments to FOLLOW sets
1 parent 5ef6de5 commit 68ecb34

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

text/0000-macro-future-proofing.md

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
- RFC PR: (leave this empty)
33
- Rust Issue: (leave this empty)
44

5-
**NOTE**: Draft, not finalized.
6-
75
# Key Terminology
86

97
- `macro`: anything invokable as `foo!(...)` in source code.
@@ -87,9 +85,9 @@ allowed tokens for the given NT's fragment specifier, and is defined below.
8785
2. For each token `T` in `M`:
8886
1. If `T` is not an NT, continue.
8987
2. If `T` is a simple NT, look ahead to the next token `T'` in `M`. If
90-
`T'` is `EOF`, replace `T'` with `F`. If `T'` is in the set
91-
`FOLLOW(NT)`, `T'` is EOF, `T'` is any NT, or `T'` is any identifier,
92-
continue. Else, reject.
88+
`T'` is `EOF` or a close delimiter of a token tree, replace `T'` with
89+
`F`. If `T'` is in the set `FOLLOW(NT)`, `T'` is EOF, `T'` is any NT,
90+
or `T'` is any identifier, continue. Else, reject.
9391
3. Else, `T` is a complex NT.
9492
1. If `T` has the form `$(...)+` or `$(...)*`, run the algorithm on
9593
the contents with `F` set to `EOF`. If it accepts, continue, else,
@@ -105,21 +103,16 @@ emitted and compilation should not complete.
105103
The current legal fragment specifiers are: `item`, `block`, `stmt`, `pat`,
106104
`expr`, `ty`, `ident`, `path`, `meta`, and `tt`.
107105

108-
- `FOLLOW(item)` = `{}`
109-
- `FOLLOW(block)` = `FOLLOW(expr)`
110106
- `FOLLOW(stmt)` = `FOLLOW(expr)`
111107
- `FOLLOW(pat)` = `{FatArrow, Comma, Pipe}`
112-
- `FOLLOW(expr)` = `{Comma, FatArrow, CloseBrace, CloseParen, Lit}` (where
113-
`Lit` is any literal, string or numeric)
114-
- `FOLLOW(ty)` = `{Comma, Eq, Gt, Lt, RArrow, FatArrow, OpenBrace, OpenParen,
115-
CloseBrace, CloseParen}`
108+
- `FOLLOW(expr)` = `{Comma, FatArrow, CloseBrace, CloseParen, CloseBracket}`
109+
- `FOLLOW(ty)` = `{Comma, CloseBrace, CloseParen, CloseBracket}`
110+
- `FOLLOW(block)` = any token
116111
- `FOLLOW(ident)` = any token
117-
- `FOLLOW(path)` = any token
118-
- `FOLLOW(meta)` = any token
119112
- `FOLLOW(tt)` = any token
120-
121-
**Note**: the `FOLLOW` sets as given are based on every MBE in the Rust
122-
distribution, but should probably be tuned before the RFC is accepted.
113+
- `FOLLOW(item)` = up for discussion
114+
- `FOLLOW(path)` = up for discussion
115+
- `FOLLOW(meta)` = up for discussion
123116

124117
# Drawbacks
125118

@@ -146,4 +139,9 @@ reasonable freedom.
146139

147140
# Unresolved questions
148141

149-
Are the given `FOLLOW` sets adequate?
142+
1. What should the FOLLOW sets for `item`, `path`, and `meta` be?
143+
2. Should the `FOLLOW` set for `ty` be extended? In practice, `RArrow`,
144+
`Colon`, `as`, and `in` are also used. (See next item)
145+
2. What, if any, identifiers should be allowed in the FOLLOW sets? The author
146+
is concerned that allowing arbitrary identifiers would limit the future use
147+
of "contextual keywords".

0 commit comments

Comments
 (0)