diff options
| author | Mark Mansi <markm@cs.wisc.edu> | 2018-01-24 23:23:01 -0600 |
|---|---|---|
| committer | Mark Mansi <markm@cs.wisc.edu> | 2018-01-26 14:47:24 -0600 |
| commit | e2d558ad56d03bdc59ab2aaa28aaedf9172a0539 (patch) | |
| tree | 52c8aafaa54a3b0eaaa5e542834a85ba00e94230 /src/libsyntax | |
| parent | 02d1d92878181a1c99b6d6029f44fbbb91bff499 (diff) | |
| download | rust-e2d558ad56d03bdc59ab2aaa28aaedf9172a0539.tar.gz rust-e2d558ad56d03bdc59ab2aaa28aaedf9172a0539.zip | |
A few more comments
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ext/tt/macro_parser.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index e15198cc383..af18801c97e 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -289,11 +289,17 @@ pub enum NamedMatch { MatchedNonterminal(Rc<Nonterminal>), } +/// Takes a sequence of token trees `ms` representing a matcher which successfully matched input +/// and an iterator of items that matched input and produces a `NamedParseResult`. fn nameize<I: Iterator<Item = NamedMatch>>( sess: &ParseSess, ms: &[TokenTree], mut res: I, ) -> NamedParseResult { + // Recursively descend into each type of matcher (e.g. sequences, delimited, metavars) and make + // sure that each metavar has _exactly one_ binding. If a metavar does not have exactly one + // binding, then there is an error. If it does, then we insert the binding into the + // `NamedParseResult`. fn n_rec<I: Iterator<Item = NamedMatch>>( sess: &ParseSess, m: &TokenTree, @@ -340,6 +346,8 @@ fn nameize<I: Iterator<Item = NamedMatch>>( Success(ret_val) } +/// Generate an appropriate parsing failure message. For EOF, this is "unexpected end...". For +/// other tokens, this is "unexpected token...". pub fn parse_failure_msg(tok: Token) -> String { match tok { token::Eof => "unexpected end of macro invocation".to_string(), |
