From 6f30a4ee6c35342cc2775d77882ad26fc31ba61e Mon Sep 17 00:00:00 2001 From: Piotr Czarnecki Date: Tue, 7 Oct 2014 00:18:24 +0100 Subject: Remove `Matcher`s --- src/libsyntax/parse/parser.rs | 64 ++----------------------------------------- src/libsyntax/parse/token.rs | 2 -- 2 files changed, 2 insertions(+), 64 deletions(-) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 741014fec89..5a0c7d92fa2 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -37,8 +37,8 @@ use ast::{ItemMac, ItemMod, ItemStruct, ItemTrait, ItemTy}; use ast::{LifetimeDef, Lit, Lit_}; use ast::{LitBool, LitChar, LitByte, LitBinary}; use ast::{LitNil, LitStr, LitInt, Local, LocalLet}; -use ast::{MutImmutable, MutMutable, Mac_, MacInvocTT, Matcher, MatchNonterminal, MatchNormal}; -use ast::{MatchSeq, MatchTok, Method, MutTy, BiMul, Mutability}; +use ast::{MutImmutable, MutMutable, Mac_, MacInvocTT, MatchNormal}; +use ast::{Method, MutTy, BiMul, Mutability}; use ast::{MethodImplItem, NamedField, UnNeg, NoReturn, UnNot}; use ast::{Pat, PatEnum, PatIdent, PatLit, PatRange, PatRegion, PatStruct}; use ast::{PatTup, PatBox, PatWild, PatWildMulti, PatWildSingle}; @@ -2628,66 +2628,6 @@ impl<'a> Parser<'a> { tts } - pub fn parse_matchers(&mut self) -> Vec { - // unification of Matcher's and TokenTree's would vastly improve - // the interpolation of Matcher's - maybe_whole!(self, NtMatchers); - let mut name_idx = 0u; - let delim = self.expect_open_delim(); - self.parse_matcher_subseq_upto(&mut name_idx, &token::CloseDelim(delim)) - } - - /// This goofy function is necessary to correctly match parens in Matcher's. - /// Otherwise, `$( ( )` would be a valid Matcher, and `$( () )` would be - /// invalid. It's similar to common::parse_seq. - pub fn parse_matcher_subseq_upto(&mut self, - name_idx: &mut uint, - ket: &token::Token) - -> Vec { - let mut ret_val = Vec::new(); - let mut lparens = 0u; - - while self.token != *ket || lparens > 0u { - if self.token == token::OpenDelim(token::Paren) { lparens += 1u; } - if self.token == token::CloseDelim(token::Paren) { lparens -= 1u; } - ret_val.push(self.parse_matcher(name_idx)); - } - - self.bump(); - - return ret_val; - } - - pub fn parse_matcher(&mut self, name_idx: &mut uint) -> Matcher { - let lo = self.span.lo; - - let m = if self.token == token::Dollar { - self.bump(); - if self.token == token::OpenDelim(token::Paren) { - let name_idx_lo = *name_idx; - self.bump(); - let ms = self.parse_matcher_subseq_upto(name_idx, - &token::CloseDelim(token::Paren)); - if ms.len() == 0u { - self.fatal("repetition body must be nonempty"); - } - let (sep, kleene_op) = self.parse_sep_and_kleene_op(); - MatchSeq(ms, sep, kleene_op, name_idx_lo, *name_idx) - } else { - let bound_to = self.parse_ident(); - self.expect(&token::Colon); - let nt_name = self.parse_ident(); - let m = MatchNonterminal(bound_to, nt_name, *name_idx); - *name_idx += 1; - m - } - } else { - MatchTok(self.bump_and_get()) - }; - - return spanned(lo, self.span.hi, m); - } - /// Parse a prefix-operator expr pub fn parse_prefix_expr(&mut self) -> P { let lo = self.span.lo; diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 8dd2f8b840f..b0cca5e14de 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -337,7 +337,6 @@ pub enum Nonterminal { NtMeta(P), NtPath(Box), NtTT(P), // needs P'ed to break a circularity - NtMatchers(Vec) } impl fmt::Show for Nonterminal { @@ -353,7 +352,6 @@ impl fmt::Show for Nonterminal { NtMeta(..) => f.pad("NtMeta(..)"), NtPath(..) => f.pad("NtPath(..)"), NtTT(..) => f.pad("NtTT(..)"), - NtMatchers(..) => f.pad("NtMatchers(..)"), } } } -- cgit 1.4.1-3-g733a5