diff options
| author | Graydon Hoare <graydon@mozilla.com> | 2012-12-12 12:25:40 -0800 |
|---|---|---|
| committer | Graydon Hoare <graydon@mozilla.com> | 2012-12-12 15:02:47 -0800 |
| commit | e24ae85025e40aa17915f6c604d89aefbca274bd (patch) | |
| tree | e60ccfc313fc01636e698aca06f92d180bafbf9c /src/libsyntax/parse | |
| parent | 9cced55b93a14cdca9bb86ae99b22021fac8685f (diff) | |
| download | rust-e24ae85025e40aa17915f6c604d89aefbca274bd.tar.gz rust-e24ae85025e40aa17915f6c604d89aefbca274bd.zip | |
syntax: remove most code handling old-style syntax extensions.
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/attr.rs | 35 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer.rs | 5 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 112 | ||||
| -rw-r--r-- | src/libsyntax/parse/token.rs | 8 |
4 files changed, 4 insertions, 156 deletions
diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index 3f0b031bd06..7248a0e2244 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -12,16 +12,9 @@ use either::{Either, Left, Right}; use ast_util::spanned; use common::*; //resolve bug? -export attr_or_ext; export parser_attr; -// A type to distingush between the parsing of item attributes or syntax -// extensions, which both begin with token.POUND -type attr_or_ext = Option<Either<~[ast::attribute], @ast::expr>>; - trait parser_attr { - fn parse_outer_attrs_or_ext(first_item_attrs: ~[ast::attribute]) - -> attr_or_ext; fn parse_outer_attributes() -> ~[ast::attribute]; fn parse_attribute(style: ast::attr_style) -> ast::attribute; fn parse_attribute_naked(style: ast::attr_style, lo: BytePos) -> @@ -35,34 +28,6 @@ trait parser_attr { impl Parser: parser_attr { - fn parse_outer_attrs_or_ext(first_item_attrs: ~[ast::attribute]) - -> attr_or_ext - { - let expect_item_next = vec::is_not_empty(first_item_attrs); - match self.token { - token::POUND => { - let lo = self.span.lo; - if self.look_ahead(1u) == token::LBRACKET { - self.bump(); - let first_attr = - self.parse_attribute_naked(ast::attr_outer, lo); - return Some(Left(vec::append(~[first_attr], - self.parse_outer_attributes()))); - } else if !(self.look_ahead(1u) == token::LT - || self.look_ahead(1u) == token::LBRACKET - || self.look_ahead(1u) == token::POUND - || expect_item_next) { - self.bump(); - return Some(Right(self.parse_syntax_ext_naked(lo))); - } else { return None; } - } - token::DOC_COMMENT(_) => { - return Some(Left(self.parse_outer_attributes())); - } - _ => return None - } - } - // Parse attributes that appear before an item fn parse_outer_attributes() -> ~[ast::attribute] { let mut attrs: ~[ast::attribute] = ~[]; diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index 3763a74b9d2..c4e34311b88 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -515,11 +515,6 @@ fn next_token_inner(rdr: string_reader) -> token::Token { bump(rdr); return token::DOTDOT; } - if rdr.curr == '.' && nextch(rdr) == '.' { - bump(rdr); - bump(rdr); - return token::ELLIPSIS; - } return token::DOT; } '(' => { bump(rdr); return token::LPAREN; } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index ead0de78f6e..625ff289607 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -54,8 +54,8 @@ use ast::{_mod, add, arg, arm, attribute, item_foreign_mod, item_impl, item_mac, item_mod, item_trait, item_ty, lit, lit_, lit_bool, lit_float, lit_float_unsuffixed, lit_int, lit_int_unsuffixed, lit_nil, lit_str, lit_uint, local, - m_const, m_imm, m_mutbl, mac_, mac_aq, mac_ellipsis, mac_invoc, - mac_invoc_tt, mac_var, matcher, match_nonterminal, match_seq, + m_const, m_imm, m_mutbl, mac_, + mac_invoc_tt, matcher, match_nonterminal, match_seq, match_tok, method, mode, module_ns, mt, mul, mutability, named_field, neg, noreturn, not, pat, pat_box, pat_enum, pat_ident, pat_lit, pat_range, pat_rec, pat_region, pat_struct, @@ -510,15 +510,6 @@ impl Parser { let lo = self.span.lo; - match self.maybe_parse_dollar_mac() { - Some(ref e) => { - return @{id: self.get_id(), - node: ty_mac(spanned(lo, self.span.hi, (*e))), - span: mk_sp(lo, self.span.hi)}; - } - None => () - } - let t = if self.token == token::LPAREN { self.bump(); if self.token == token::RPAREN { @@ -730,32 +721,6 @@ impl Parser { } } - fn maybe_parse_dollar_mac() -> Option<mac_> { - match copy self.token { - token::DOLLAR => { - let lo = self.span.lo; - self.bump(); - match copy self.token { - token::LIT_INT_UNSUFFIXED(num) => { - self.bump(); - Some(mac_var(num as uint)) - } - token::LPAREN => { - self.bump(); - let e = self.parse_expr(); - self.expect(token::RPAREN); - let hi = self.last_span.hi; - Some(mac_aq(mk_sp(lo,hi), e)) - } - _ => { - self.fatal(~"expected `(` or unsuffixed integer literal"); - } - } - } - _ => None - } - } - fn maybe_parse_fixed_vstore_with_star() -> Option<uint> { if self.eat(token::BINOP(token::STAR)) { match copy self.token { @@ -928,11 +893,6 @@ impl Parser { let mut ex: expr_; - match self.maybe_parse_dollar_mac() { - Some(ref x) => return self.mk_mac_expr(lo, self.span.hi, (*x)), - _ => () - } - if self.token == token::LPAREN { self.bump(); if self.token == token::RPAREN { @@ -1022,13 +982,6 @@ impl Parser { } } hi = self.span.hi; - } else if self.token == token::ELLIPSIS { - self.bump(); - return self.mk_mac_expr(lo, self.span.hi, mac_ellipsis); - } else if self.token == token::POUND { - let ex_ext = self.parse_syntax_ext(); - hi = ex_ext.span.hi; - ex = ex_ext.node; } else if self.eat_keyword(~"fail") { if can_begin_expr(self.token) { let e = self.parse_expr(); @@ -1141,54 +1094,6 @@ impl Parser { return self.mk_expr(blk.span.lo, blk.span.hi, expr_block(blk)); } - fn parse_syntax_ext() -> @expr { - let lo = self.span.lo; - self.expect(token::POUND); - return self.parse_syntax_ext_naked(lo); - } - - fn parse_syntax_ext_naked(lo: BytePos) -> @expr { - match self.token { - token::IDENT(_, _) => (), - _ => self.fatal(~"expected a syntax expander name") - } - let pth = self.parse_path_without_tps(); - //temporary for a backwards-compatible cycle: - let sep = seq_sep_trailing_disallowed(token::COMMA); - let mut e = None; - if (self.token == token::LPAREN || self.token == token::LBRACKET) { - let lo = self.span.lo; - let es = - if self.token == token::LPAREN { - self.parse_unspanned_seq(token::LPAREN, token::RPAREN, - sep, |p| p.parse_expr()) - } else { - self.parse_unspanned_seq(token::LBRACKET, token::RBRACKET, - sep, |p| p.parse_expr()) - }; - let hi = self.span.hi; - e = Some(self.mk_expr(lo, hi, expr_vec(es, m_imm))); - } - let mut b = None; - if self.token == token::LBRACE { - self.bump(); - let lo = self.span.lo; - let mut depth = 1u; - while (depth > 0u) { - match (self.token) { - token::LBRACE => depth += 1u, - token::RBRACE => depth -= 1u, - token::EOF => self.fatal(~"unexpected EOF in macro body"), - _ => () - } - self.bump(); - } - let hi = self.last_span.lo; - b = Some({span: mk_sp(lo,hi)}); - } - return self.mk_mac_expr(lo, self.span.hi, mac_invoc(pth, e, b)); - } - fn parse_dot_or_call_expr() -> @expr { let b = self.parse_bottom_expr(); self.parse_dot_or_call_expr_with(b) @@ -2253,17 +2158,8 @@ impl Parser { } } else { - let mut item_attrs; - match self.parse_outer_attrs_or_ext(first_item_attrs) { - None => item_attrs = ~[], - Some(Left(ref attrs)) => item_attrs = (*attrs), - Some(Right(ext)) => { - return @spanned(lo, ext.span.hi, - stmt_expr(ext, self.get_id())); - } - } - - let item_attrs = vec::append(first_item_attrs, item_attrs); + let item_attrs = vec::append(first_item_attrs, + self.parse_outer_attributes()); match self.parse_item_or_view_item(item_attrs, true, false, false) { diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index a0aecd0375e..7e7c61d2bf2 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -49,7 +49,6 @@ enum Token { AT, DOT, DOTDOT, - ELLIPSIS, COMMA, SEMI, COLON, @@ -137,7 +136,6 @@ fn to_str(in: @ident_interner, t: Token) -> ~str { AT => ~"@", DOT => ~".", DOTDOT => ~"..", - ELLIPSIS => ~"...", COMMA => ~",", SEMI => ~";", COLON => ~":", @@ -578,12 +576,6 @@ impl Token : cmp::Eq { _ => false } } - ELLIPSIS => { - match (*other) { - ELLIPSIS => true, - _ => false - } - } COMMA => { match (*other) { COMMA => true, |
