diff options
| author | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2013-02-24 20:51:56 -0800 |
|---|---|---|
| committer | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2013-02-26 02:14:01 -0800 |
| commit | 28691a0852854a9996d07ab92bb55e92beef2c98 (patch) | |
| tree | f2557892421370abd122c1f881c0847c749a0862 /src/libsyntax/parse | |
| parent | ff36986fa490917bcacfb4e5010e304d5e82f3bb (diff) | |
| download | rust-28691a0852854a9996d07ab92bb55e92beef2c98.tar.gz rust-28691a0852854a9996d07ab92bb55e92beef2c98.zip | |
libsyntax: more minor cleanup
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/attr.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/parse/common.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 52 |
3 files changed, 32 insertions, 32 deletions
diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index bad6c76c36a..56e350db47b 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -161,8 +161,8 @@ impl parser_attr for Parser { fn parse_optional_meta() -> ~[@ast::meta_item] { match *self.token { - token::LPAREN => return self.parse_meta_seq(), - _ => return ~[] + token::LPAREN => self.parse_meta_seq(), + _ => ~[] } } } diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs index 764ff52a303..4632ceb6e7d 100644 --- a/src/libsyntax/parse/common.rs +++ b/src/libsyntax/parse/common.rs @@ -139,8 +139,8 @@ pub impl Parser { fn token_is_word(word: &~str, tok: &token::Token) -> bool { match *tok { - token::IDENT(sid, false) => { *self.id_to_str(sid) == *word } - _ => { false } + token::IDENT(sid, false) => { *self.id_to_str(sid) == *word } + _ => { false } } } @@ -165,8 +165,8 @@ pub impl Parser { fn eat_keyword(word: &~str) -> bool { self.require_keyword(word); let is_kw = match *self.token { - token::IDENT(sid, false) => *word == *self.id_to_str(sid), - _ => false + token::IDENT(sid, false) => *word == *self.id_to_str(sid), + _ => false }; if is_kw { self.bump() } is_kw diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index a5226127947..9b825512c39 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -633,7 +633,7 @@ pub impl Parser { seq_sep_trailing_allowed(token::COMMA), |p| p.parse_ty_field() ); - if vec::len(elems) == 0u { + if elems.len() == 0 { self.unexpected_last(token::RBRACE); } ty_rec(elems) @@ -858,17 +858,17 @@ pub impl Parser { } } - fn lit_from_token(tok: token::Token) -> lit_ { - match tok { - token::LIT_INT(i, it) => lit_int(i, it), - token::LIT_UINT(u, ut) => lit_uint(u, ut), - token::LIT_INT_UNSUFFIXED(i) => lit_int_unsuffixed(i), - token::LIT_FLOAT(s, ft) => lit_float(self.id_to_str(s), ft), - token::LIT_FLOAT_UNSUFFIXED(s) => - lit_float_unsuffixed(self.id_to_str(s)), - token::LIT_STR(s) => lit_str(self.id_to_str(s)), - token::LPAREN => { self.expect(&token::RPAREN); lit_nil }, - _ => { self.unexpected_last(tok); } + fn lit_from_token(tok: &token::Token) -> lit_ { + match *tok { + token::LIT_INT(i, it) => lit_int(i, it), + token::LIT_UINT(u, ut) => lit_uint(u, ut), + token::LIT_INT_UNSUFFIXED(i) => lit_int_unsuffixed(i), + token::LIT_FLOAT(s, ft) => lit_float(self.id_to_str(s), ft), + token::LIT_FLOAT_UNSUFFIXED(s) => + lit_float_unsuffixed(self.id_to_str(s)), + token::LIT_STR(s) => lit_str(self.id_to_str(s)), + token::LPAREN => { self.expect(&token::RPAREN); lit_nil }, + _ => { self.unexpected_last(*tok); } } } @@ -882,7 +882,7 @@ pub impl Parser { // XXX: This is a really bad copy! let tok = copy *self.token; self.bump(); - self.lit_from_token(tok) + self.lit_from_token(&tok) }; codemap::spanned { node: lit, span: mk_sp(lo, self.last_span.hi) } } @@ -1240,8 +1240,8 @@ pub impl Parser { if *self.token == token::NOT { self.bump(); match *self.token { - token::LPAREN | token::LBRACE => {} - _ => self.fatal(~"expected open delimiter") + token::LPAREN | token::LBRACE => {} + _ => self.fatal(~"expected open delimiter") }; let ket = token::flip_delimiter(&*self.token); @@ -2554,7 +2554,8 @@ pub impl Parser { self.expect(&token::LBRACE); let (inner, next) = maybe_parse_inner_attrs_and_next(self, parse_attrs); - return (inner, self.parse_block_tail_(lo, default_blk, next)); + + (inner, self.parse_block_tail_(lo, default_blk, next)) } fn parse_block_no_value() -> blk { @@ -2624,10 +2625,7 @@ pub impl Parser { fmt!( "expected `;` or `}` after \ expression but found `%s`", - token_to_str( - self.reader, - &t - ) + token_to_str(self.reader, &t) ) ); } @@ -2823,12 +2821,14 @@ pub impl Parser { self.bump(); } - fn parse_fn_decl_with_self(parse_arg_fn: - fn(Parser) -> arg_or_capture_item) - -> (self_ty, fn_decl) { - - fn maybe_parse_self_ty(cnstr: fn(+v: mutability) -> ast::self_ty_, - p: Parser) -> ast::self_ty_ { + fn parse_fn_decl_with_self( + parse_arg_fn: + fn(Parser) -> arg_or_capture_item + ) -> (self_ty, fn_decl) { + fn maybe_parse_self_ty( + cnstr: fn(+v: mutability) -> ast::self_ty_, + p: Parser + ) -> ast::self_ty_ { // We need to make sure it isn't a mode or a type if p.token_is_keyword(&~"self", &p.look_ahead(1)) || ((p.token_is_keyword(&~"const", &p.look_ahead(1)) || |
