Skip to content

Commit e2d558a

Browse files
committed
A few more comments
1 parent 02d1d92 commit e2d558a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/libsyntax/ext/tt/macro_parser.rs

+8
Original file line numberDiff line numberDiff 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`.
292294
fn 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...".
343351
pub fn parse_failure_msg(tok: Token) -> String {
344352
match tok {
345353
token::Eof => "unexpected end of macro invocation".to_string(),

0 commit comments

Comments
 (0)