Skip to content

Commit 5db222a

Browse files
committed
Finalize FOLLOW sets
1 parent 68ecb34 commit 5db222a

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

text/0000-macro-future-proofing.md

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ allowed tokens for the given NT's fragment specifier, and is defined below.
8787
2. If `T` is a simple NT, look ahead to the next token `T'` in `M`. If
8888
`T'` is `EOF` or a close delimiter of a token tree, replace `T'` with
8989
`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.
90+
or `T'` is any close delimiter, continue. Else, reject.
9191
3. Else, `T` is a complex NT.
9292
1. If `T` has the form `$(...)+` or `$(...)*`, run the algorithm on
9393
the contents with `F` set to `EOF`. If it accepts, continue, else,
@@ -104,15 +104,17 @@ The current legal fragment specifiers are: `item`, `block`, `stmt`, `pat`,
104104
`expr`, `ty`, `ident`, `path`, `meta`, and `tt`.
105105

106106
- `FOLLOW(stmt)` = `FOLLOW(expr)`
107-
- `FOLLOW(pat)` = `{FatArrow, Comma, Pipe}`
108-
- `FOLLOW(expr)` = `{Comma, FatArrow, CloseBrace, CloseParen, CloseBracket}`
109-
- `FOLLOW(ty)` = `{Comma, CloseBrace, CloseParen, CloseBracket}`
107+
- `FOLLOW(pat)` = `{FatArrow, Comma, Eq}`
108+
- `FOLLOW(expr)` = `{Comma, Semicolon}`
109+
- `FOLLOW(path)` = `FOLLOW(ty)`
110+
- `FOLLOW(ty)` = `{Comma, RArrow, Colon, Eq, Gt, Ident(as)}`
110111
- `FOLLOW(block)` = any token
111112
- `FOLLOW(ident)` = any token
112113
- `FOLLOW(tt)` = any token
113-
- `FOLLOW(item)` = up for discussion
114-
- `FOLLOW(path)` = up for discussion
115-
- `FOLLOW(meta)` = up for discussion
114+
- `FOLLOW(item)` = any token
115+
- `FOLLOW(meta)` = any token
116+
117+
(Note that close delimiters are valid following any NT.)
116118

117119
# Drawbacks
118120

@@ -136,12 +138,3 @@ reasonable freedom.
136138
same issue would come up.
137139
3. Do nothing. This is very dangerous, and has the potential to essentially
138140
freeze Rust's syntax for fear of accidentally breaking a macro.
139-
140-
# Unresolved questions
141-
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)