File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -289,11 +289,17 @@ pub enum NamedMatch {
289289 MatchedNonterminal ( Rc < Nonterminal > ) ,
290290}
291291
292+ /// Takes a sequence of token trees `ms` representing a matcher which successfully matched input
293+ /// and an iterator of items that matched input and produces a `NamedParseResult`.
292294fn nameize < I : Iterator < Item = NamedMatch > > (
293295 sess : & ParseSess ,
294296 ms : & [ TokenTree ] ,
295297 mut res : I ,
296298) -> NamedParseResult {
299+ // Recursively descend into each type of matcher (e.g. sequences, delimited, metavars) and make
300+ // sure that each metavar has _exactly one_ binding. If a metavar does not have exactly one
301+ // binding, then there is an error. If it does, then we insert the binding into the
302+ // `NamedParseResult`.
297303 fn n_rec < I : Iterator < Item = NamedMatch > > (
298304 sess : & ParseSess ,
299305 m : & TokenTree ,
@@ -340,6 +346,8 @@ fn nameize<I: Iterator<Item = NamedMatch>>(
340346 Success ( ret_val)
341347}
342348
349+ /// Generate an appropriate parsing failure message. For EOF, this is "unexpected end...". For
350+ /// other tokens, this is "unexpected token...".
343351pub fn parse_failure_msg ( tok : Token ) -> String {
344352 match tok {
345353 token:: Eof => "unexpected end of macro invocation" . to_string ( ) ,
You can’t perform that action at this time.
0 commit comments