@@ -7,7 +7,7 @@ before name resolution, macros are expanded using these portions of the code.
7
7
The macro parser, in turn, may call the normal Rust parser when it needs to
8
8
bind a metavariable (e.g. ` $my_expr ` ) while parsing the contents of a macro
9
9
invocation. The code for macro expansion is in
10
- [ ` src/libsyntax/ext /mbe/ ` ] [ code_dir ] . This chapter aims to explain how macro
10
+ [ ` src/libsyntax_expand /mbe/ ` ] [ code_dir ] . This chapter aims to explain how macro
11
11
expansion works.
12
12
13
13
### Example
@@ -61,7 +61,7 @@ invocations. Interestingly, both are done by the macro parser.
61
61
Basically, the macro parser is like an NFA-based regex parser. It uses an
62
62
algorithm similar in spirit to the [ Earley parsing
63
63
algorithm] ( https://en.wikipedia.org/wiki/Earley_parser ) . The macro parser is
64
- defined in [ ` src/libsyntax/ext /mbe/macro_parser.rs ` ] [ code_mp ] .
64
+ defined in [ ` src/libsyntax_expand /mbe/macro_parser.rs ` ] [ code_mp ] .
65
65
66
66
The interface of the macro parser is as follows (this is slightly simplified):
67
67
@@ -110,7 +110,7 @@ normal Rust parser.
110
110
As mentioned above, both definitions and invocations of macros are parsed using
111
111
the macro parser. This is extremely non-intuitive and self-referential. The code
112
112
to parse macro _ definitions_ is in
113
- [ ` src/libsyntax/ext /mbe/macro_rules.rs ` ] [ code_mr ] . It defines the pattern for
113
+ [ ` src/libsyntax_expand /mbe/macro_rules.rs ` ] [ code_mr ] . It defines the pattern for
114
114
matching for a macro definition as ` $( $lhs:tt => $rhs:tt );+ ` . In other words,
115
115
a ` macro_rules ` definition should have in its body at least one occurrence of a
116
116
token tree followed by ` => ` followed by another token tree. When the compiler
@@ -139,7 +139,7 @@ the parse is ambiguous, while if there are no matches at all, there is a syntax
139
139
error.
140
140
141
141
For more information about the macro parser's implementation, see the comments
142
- in [ ` src/libsyntax/ext /mbe/macro_parser.rs ` ] [ code_mp ] .
142
+ in [ ` src/libsyntax_expand /mbe/macro_parser.rs ` ] [ code_mp ] .
143
143
144
144
### Hygiene
145
145
205
205
TODO: maybe something about macros 2.0?
206
206
207
207
208
- [code_dir]: https://github.com/rust-lang/rust/tree/master/src/libsyntax/ext /mbe
209
- [code_mp]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/ext /mbe/macro_parser
210
- [code_mr]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/ext /mbe/macro_rules
211
- [code_parse_int]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/ext /mbe/macro_parser/fn.parse.html
208
+ [code_dir]: https://github.com/rust-lang/rust/tree/master/src/libsyntax_expand /mbe
209
+ [code_mp]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax_expand /mbe/macro_parser
210
+ [code_mr]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax_expand /mbe/macro_rules
211
+ [code_parse_int]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax_expand /mbe/macro_parser/fn.parse.html
212
212
[parsing]: ./the-parser.html
0 commit comments