]> git.lizzy.rs Git - rust.git/commitdiff
rollup merge of #19430: pczarn/interp_tt-cleanup
authorAlex Crichton <alex@alexcrichton.com>
Tue, 6 Jan 2015 23:38:10 +0000 (15:38 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 6 Jan 2015 23:38:10 +0000 (15:38 -0800)
Conflicts:
src/libsyntax/parse/parser.rs

1  2 
src/libstd/io/mod.rs
src/libsyntax/ast.rs
src/libsyntax/ext/tt/macro_parser.rs
src/libsyntax/ext/tt/macro_rules.rs
src/libsyntax/ext/tt/transcribe.rs
src/libsyntax/parse/lexer/mod.rs
src/libsyntax/parse/mod.rs
src/libsyntax/parse/parser.rs

Simple merge
Simple merge
index 0f9d613cf135f3c930d9b3539e7b1a69a138f84f,1d46c4ba3f211da6aec111a7fea15e162dd42863..d33d03bbfa97eb7aa0d9dc794b4feeafa131a623
@@@ -529,14 -540,8 +540,8 @@@ pub fn parse_nt(p: &mut Parser, name: &
          token::NtPath(box p.parse_path(LifetimeAndTypesWithoutColons))
        }
        "meta" => token::NtMeta(p.parse_meta_item()),
-       "tt" => {
-         p.quote_depth += 1u; //but in theory, non-quoted tts might be useful
-         let res = token::NtTT(P(p.parse_token_tree()));
-         p.quote_depth -= 1u;
-         res
-       }
        _ => {
 -          p.fatal(format!("unsupported builtin nonterminal parser: {}", name)[])
 +          p.fatal(format!("unsupported builtin nonterminal parser: {}", name).index(&FullRange))
        }
      }
  }
Simple merge
Simple merge
Simple merge
Simple merge
index 7d7e10e181e332a4a528b364b8fe6d20a60dd8b1,631a8a5081348fbefb321bb1b160504673eca7dc..0ba9f23fc119ba4606bd88ecae1d005fbdf8863e
@@@ -2642,63 -2767,25 +2708,25 @@@ impl<'a> Parser<'a> 
          fn parse_non_delim_tt_tok(p: &mut Parser) -> TokenTree {
              maybe_whole!(deref p, NtTT);
              match p.token {
-               token::CloseDelim(_) => {
-                   // This is a conservative error: only report the last unclosed delimiter. The
-                   // previous unclosed delimiters could actually be closed! The parser just hasn't
-                   // gotten to them yet.
-                   match p.open_braces.last() {
-                       None => {}
-                       Some(&sp) => p.span_note(sp, "unclosed delimiter"),
-                   };
-                   let token_str = p.this_token_to_string();
-                   p.fatal(format!("incorrect close delimiter: `{}`",
-                                   token_str).index(&FullRange))
-               },
-               /* we ought to allow different depths of unquotation */
-               token::Dollar if p.quote_depth > 0u => {
-                 p.bump();
-                 let sp = p.span;
-                 if p.token == token::OpenDelim(token::Paren) {
-                     let seq = p.parse_seq(
-                         &token::OpenDelim(token::Paren),
-                         &token::CloseDelim(token::Paren),
-                         seq_sep_none(),
-                         |p| p.parse_token_tree()
-                     );
-                     let (sep, repeat) = p.parse_sep_and_kleene_op();
-                     let seq = match seq {
-                         Spanned { node, .. } => node,
+                 token::CloseDelim(_) => {
+                     // This is a conservative error: only report the last unclosed delimiter. The
+                     // previous unclosed delimiters could actually be closed! The parser just hasn't
+                     // gotten to them yet.
+                     match p.open_braces.last() {
+                         None => {}
+                         Some(&sp) => p.span_note(sp, "unclosed delimiter"),
                      };
-                     let name_num = macro_parser::count_names(seq.index(&FullRange));
-                     TtSequence(mk_sp(sp.lo, p.span.hi),
-                                Rc::new(SequenceRepetition {
-                                    tts: seq,
-                                    separator: sep,
-                                    op: repeat,
-                                    num_captures: name_num
-                                }))
-                 } else if p.token.is_keyword_allow_following_colon(keywords::Crate) {
-                     p.bump();
-                     TtToken(sp, SpecialVarNt(SpecialMacroVar::CrateMacroVar))
-                 } else {
-                     // A nonterminal that matches or not
-                     let namep = match p.token { token::Ident(_, p) => p, _ => token::Plain };
-                     let name = p.parse_ident();
-                     if p.token == token::Colon && p.look_ahead(1, |t| t.is_ident()) {
-                         p.bump();
-                         let kindp = match p.token { token::Ident(_, p) => p, _ => token::Plain };
-                         let nt_kind = p.parse_ident();
-                         let m = TtToken(sp, MatchNt(name, nt_kind, namep, kindp));
-                         m
-                     } else {
-                         TtToken(sp, SubstNt(name, namep))
-                     }
+                     let token_str = p.this_token_to_string();
+                     p.fatal(format!("incorrect close delimiter: `{}`",
 -                                    token_str)[])
++                                    token_str).index(&FullRange))
+                 },
+                 /* we ought to allow different depths of unquotation */
+                 token::Dollar | token::SubstNt(..) if p.quote_depth > 0u => {
+                     p.parse_unquoted()
+                 }
+                 _ => {
+                     TtToken(p.span, p.bump_and_get())
                  }
-               }
-               _ => {
-                   TtToken(p.span, p.bump_and_get())
-               }
              }
          }