@@ -227,7 +227,7 @@ only within the macro (i.e. it should not be visible outside the macro).
227227[code_dir]: https://github.com/rust-lang/rust/tree/master/compiler/rustc_expand/src/mbe
228228[code_mp]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_expand/mbe/macro_parser
229229[code_mr]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_expand/mbe/macro_rules
230- [code_parse_int]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_expand/mbe/macro_parser/fn.parse_tt .html
230+ [code_parse_int]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_expand/mbe/macro_parser/struct.TtParser .html#method.parse_tt
231231[parsing]: ./the-parser.html
232232
233233The context is attached to AST nodes. All AST nodes generated by macros have
@@ -503,9 +503,10 @@ The interface of the macro parser is as follows (this is slightly simplified):
503503
504504``` rust,ignore
505505fn parse_tt(
506- parser: &mut Cow<Parser>,
507- ms: &[TokenTree],
508- ) -> NamedParseResult
506+ &mut self,
507+ parser: &mut Cow<'_, Parser<'_>>,
508+ matcher: &[MatcherLoc]
509+ ) -> ParseResult
509510```
510511
511512We use these items in macro parser:
@@ -515,20 +516,20 @@ We use these items in macro parser:
515516 ask the MBE parser to parse. We will consume the raw stream of tokens and
516517 output a binding of metavariables to corresponding token trees. The parsing
517518 session can be used to report parser errors.
518- - ` ms ` a _ matcher _ . This is a sequence of token trees that we want to match
519- the token stream against.
519+ - ` matcher ` is a sequence of ` MatcherLoc ` s that we want to match
520+ the token stream against. They're converted from token trees before matching.
520521
521522In the analogy of a regex parser, the token stream is the input and we are matching it
522- against the pattern ` ms ` . Using our examples, the token stream could be the stream of
523- tokens containing the inside of the example invocation ` print foo ` , while ` ms `
523+ against the pattern ` matcher ` . Using our examples, the token stream could be the stream of
524+ tokens containing the inside of the example invocation ` print foo ` , while ` matcher `
524525might be the sequence of token (trees) ` print $mvar:ident ` .
525526
526- The output of the parser is a ` NamedParseResult ` , which indicates which of
527+ The output of the parser is a [ ` ParseResult ` ] , which indicates which of
527528three cases has occurred:
528529
529- - Success: the token stream matches the given matcher ` ms ` , and we have produced a binding
530+ - Success: the token stream matches the given ` matcher ` , and we have produced a binding
530531 from metavariables to the corresponding token trees.
531- - Failure: the token stream does not match ` ms ` . This results in an error message such as
532+ - Failure: the token stream does not match ` matcher ` . This results in an error message such as
532533 "No rule expected token _ blah_ ".
533534- Error: some fatal error has occurred _ in the parser_ . For example, this
534535 happens if there are more than one pattern match, since that indicates
@@ -607,6 +608,7 @@ Because the Rust ABI is unstable, we use the C ABI for this conversion.
607608[ stablets ] : https://doc.rust-lang.org/proc_macro/struct.TokenStream.html
608609[ pm ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_expand/proc_macro/index.html
609610[ pms ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_expand/proc_macro_server/index.html
611+ [ `ParseResult` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_expand/mbe/macro_parser/enum.ParseResult.html
610612
611613TODO: more here. [ #1160 ] ( https://github.com/rust-lang/rustc-dev-guide/issues/1160 )
612614
0 commit comments