diff options
| author | Piotr Czarnecki <pioczarn@gmail.com> | 2014-10-07 00:18:24 +0100 |
|---|---|---|
| committer | Piotr Czarnecki <pioczarn@gmail.com> | 2014-11-05 23:06:01 +0100 |
| commit | 6f30a4ee6c35342cc2775d77882ad26fc31ba61e (patch) | |
| tree | 91b1dd2f9aa3ecc25cbe88193b2db99adb524d02 /src/libsyntax/parse | |
| parent | 38ce6d9eac5d0bcfa0c102bc64393a987b4a43e3 (diff) | |
| download | rust-6f30a4ee6c35342cc2775d77882ad26fc31ba61e.tar.gz rust-6f30a4ee6c35342cc2775d77882ad26fc31ba61e.zip | |
Remove `Matcher`s
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 64 | ||||
| -rw-r--r-- | src/libsyntax/parse/token.rs | 2 |
2 files changed, 2 insertions, 64 deletions
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<Matcher> { - // 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<Matcher> { - 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<Expr> { 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<ast::MetaItem>), NtPath(Box<ast::Path>), NtTT(P<ast::TokenTree>), // needs P'ed to break a circularity - NtMatchers(Vec<ast::Matcher>) } 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(..)"), } } } |
