diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2012-10-15 14:56:42 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2012-10-15 15:35:36 -0700 |
| commit | 91ae5412d8141ea958924408bf3c1def5edca806 (patch) | |
| tree | 65e295ba7ac7159ea3f7fe172e1a241114ef5e2d /src/libsyntax/parse/parser.rs | |
| parent | c5b82a65e96cfe77e4983e78a34a7d5aa91329b4 (diff) | |
| download | rust-91ae5412d8141ea958924408bf3c1def5edca806.tar.gz rust-91ae5412d8141ea958924408bf3c1def5edca806.zip | |
rustc: Merge module and type namespaces. r=brson
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 973822ddff9..e29620a7e79 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -6,7 +6,7 @@ use std::map::HashMap; use token::{can_begin_expr, is_ident, is_ident_or_path, is_plain_ident, INTERPOLATED, special_idents}; use codemap::{span,fss_none}; -use util::interner::interner; +use util::interner::Interner; use ast_util::{spanned, respan, mk_sp, ident_to_path, operator_prec}; use lexer::reader; use prec::{as_prec, token_to_binop}; @@ -58,7 +58,7 @@ use ast::{_mod, add, alt_check, alt_exhaustive, arg, arm, attribute, stmt_semi, struct_def, struct_field, struct_variant_kind, subtract, sty_box, sty_by_ref, sty_region, sty_static, sty_uniq, sty_value, token_tree, trait_method, trait_ref, tt_delim, tt_seq, - tt_tok, tt_nonterminal, tuple_variant_kind, ty, ty_, ty_bot, + tt_tok, tt_nonterminal, tuple_variant_kind, Ty, ty_, ty_bot, ty_box, ty_field, ty_fn, ty_infer, ty_mac, ty_method, ty_nil, ty_param, ty_param_bound, ty_path, ty_ptr, ty_rec, ty_rptr, ty_tup, ty_u32, ty_uniq, ty_vec, ty_fixed_length, type_value_ns, @@ -71,7 +71,7 @@ use ast::{_mod, add, alt_check, alt_exhaustive, arg, arm, attribute, expr_vstore_uniq}; export file_type; -export parser; +export Parser; export CRATE_FILE; export SOURCE_FILE; @@ -190,14 +190,14 @@ pure fn maybe_append(+lhs: ~[attribute], rhs: Option<~[attribute]>) /* ident is handled by common.rs */ -fn parser(sess: parse_sess, cfg: ast::crate_cfg, - +rdr: reader, ftype: file_type) -> parser { +fn Parser(sess: parse_sess, cfg: ast::crate_cfg, + +rdr: reader, ftype: file_type) -> Parser { let tok0 = rdr.next_token(); let span0 = tok0.sp; let interner = rdr.interner(); - parser { + Parser { reader: move rdr, interner: move interner, sess: sess, @@ -223,14 +223,14 @@ fn parser(sess: parse_sess, cfg: ast::crate_cfg, } } -struct parser { +struct Parser { sess: parse_sess, cfg: crate_cfg, file_type: file_type, - mut token: token::token, + mut token: token::Token, mut span: span, mut last_span: span, - mut buffer: [mut {tok: token::token, sp: span}]/4, + mut buffer: [mut {tok: token::Token, sp: span}]/4, mut buffer_start: int, mut buffer_end: int, mut restriction: restriction, @@ -247,7 +247,7 @@ struct parser { drop {} /* do not copy the parser; its state is tied to outside state */ } -impl parser { +impl Parser { fn bump() { self.last_span = self.span; let next = if self.buffer_start == self.buffer_end { @@ -260,7 +260,7 @@ impl parser { self.token = next.tok; self.span = next.sp; } - fn swap(next: token::token, lo: uint, hi: uint) { + fn swap(next: token::Token, lo: uint, hi: uint) { self.token = next; self.span = mk_sp(lo, hi); } @@ -270,7 +270,7 @@ impl parser { } return (4 - self.buffer_start) + self.buffer_end; } - fn look_ahead(distance: uint) -> token::token { + fn look_ahead(distance: uint) -> token::Token { let dist = distance as int; while self.buffer_length() < dist { self.buffer[self.buffer_end] = self.reader.next_token(); @@ -411,7 +411,7 @@ impl parser { }); } - fn parse_ret_ty() -> (ret_style, @ty) { + fn parse_ret_ty() -> (ret_style, @Ty) { return if self.eat(token::RARROW) { let lo = self.span.lo; if self.eat(token::NOT) { @@ -472,7 +472,7 @@ impl parser { self.region_from_name(name) } - fn parse_ty(colons_before_params: bool) -> @ty { + fn parse_ty(colons_before_params: bool) -> @Ty { maybe_whole!(self, nt_ty); let lo = self.span.lo; @@ -609,10 +609,10 @@ impl parser { } } - fn parse_capture_item_or(parse_arg_fn: fn(parser) -> arg_or_capture_item) + fn parse_capture_item_or(parse_arg_fn: fn(Parser) -> arg_or_capture_item) -> arg_or_capture_item { - fn parse_capture_item(p:parser, is_move: bool) -> capture_item { + fn parse_capture_item(p:Parser, is_move: bool) -> capture_item { let sp = mk_sp(p.span.lo, p.span.hi); let ident = p.parse_ident(); @{id: p.get_id(), is_move: is_move, name: ident, span: sp} @@ -728,7 +728,7 @@ impl parser { } } - fn lit_from_token(tok: token::token) -> lit_ { + 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), @@ -760,8 +760,8 @@ impl parser { } fn parse_path_without_tps_( - parse_ident: fn(parser) -> ident, - parse_last_ident: fn(parser) -> ident) -> @path { + parse_ident: fn(Parser) -> ident, + parse_last_ident: fn(Parser) -> ident) -> @path { maybe_whole!(self, nt_path); let lo = self.span.lo; @@ -842,7 +842,7 @@ impl parser { } } - fn parse_field(sep: token::token) -> field { + fn parse_field(sep: token::Token) -> field { let lo = self.span.lo; let m = self.parse_mutability(); let i = self.parse_ident(); @@ -1220,7 +1220,7 @@ impl parser { return e; } - fn parse_sep_and_zerok() -> (Option<token::token>, bool) { + fn parse_sep_and_zerok() -> (Option<token::Token>, bool) { if self.token == token::BINOP(token::STAR) || self.token == token::BINOP(token::PLUS) { let zerok = self.token == token::BINOP(token::STAR); @@ -1243,7 +1243,7 @@ impl parser { fn parse_token_tree() -> token_tree { maybe_whole!(deref self, nt_tt); - fn parse_tt_tok(p: parser, delim_ok: bool) -> token_tree { + fn parse_tt_tok(p: Parser, delim_ok: bool) -> token_tree { match p.token { token::RPAREN | token::RBRACE | token::RBRACKET if !delim_ok => { @@ -1310,8 +1310,8 @@ impl parser { // This goofy function is necessary to correctly match parens in matchers. // Otherwise, `$( ( )` would be a valid matcher, and `$( () )` would be // invalid. It's similar to common::parse_seq. - fn parse_matcher_subseq(name_idx: @mut uint, bra: token::token, - ket: token::token) -> ~[matcher] { + fn parse_matcher_subseq(name_idx: @mut uint, bra: token::Token, + ket: token::Token) -> ~[matcher] { let mut ret_val = ~[]; let mut lparens = 0u; @@ -2158,7 +2158,7 @@ impl parser { fn parse_stmt(+first_item_attrs: ~[attribute]) -> @stmt { maybe_whole!(self, nt_stmt); - fn check_expected_item(p: parser, current_attrs: ~[attribute]) { + fn check_expected_item(p: Parser, current_attrs: ~[attribute]) { // If we have attributes then we should have an item if vec::is_not_empty(current_attrs) { p.fatal(~"expected item"); @@ -2221,7 +2221,7 @@ impl parser { maybe_whole!(pair_empty self, nt_block); - fn maybe_parse_inner_attrs_and_next(p: parser, parse_attrs: bool) -> + fn maybe_parse_inner_attrs_and_next(p: Parser, parse_attrs: bool) -> {inner: ~[attribute], next: ~[attribute]} { if parse_attrs { p.parse_inner_attrs_and_next() @@ -2386,7 +2386,7 @@ impl parser { } else { ~[] } } - fn parse_fn_decl(parse_arg_fn: fn(parser) -> arg_or_capture_item) + fn parse_fn_decl(parse_arg_fn: fn(Parser) -> arg_or_capture_item) -> (fn_decl, capture_clause) { let args_or_capture_items: ~[arg_or_capture_item] = @@ -2420,11 +2420,11 @@ impl parser { } fn parse_fn_decl_with_self(parse_arg_fn: - fn(parser) -> arg_or_capture_item) + fn(Parser) -> arg_or_capture_item) -> (self_ty, fn_decl, capture_clause) { fn maybe_parse_self_ty(cnstr: fn(+v: mutability) -> ast::self_ty_, - p: parser) -> 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)) || @@ -2604,7 +2604,7 @@ impl parser { // Parses four variants (with the region/type params always optional): // impl<T> ~[T] : to_str { ... } fn parse_item_impl() -> item_info { - fn wrap_path(p: parser, pt: @path) -> @ty { + fn wrap_path(p: Parser, pt: @path) -> @Ty { @{id: p.get_id(), node: ty_path(pt, p.get_id()), span: pt.span} } @@ -2664,7 +2664,7 @@ impl parser { ref_id: self.get_id(), impl_id: self.get_id()} } - fn parse_trait_ref_list(ket: token::token) -> ~[@trait_ref] { + fn parse_trait_ref_list(ket: token::Token) -> ~[@trait_ref] { self.parse_seq_to_before_end( ket, seq_sep_trailing_disallowed(token::COMMA), |p| p.parse_trait_ref()) @@ -2756,7 +2756,7 @@ impl parser { None) } - fn token_is_pound_or_doc_comment(++tok: token::token) -> bool { + fn token_is_pound_or_doc_comment(++tok: token::Token) -> bool { match tok { token::POUND | token::DOC_COMMENT(_) => true, _ => false @@ -2841,7 +2841,7 @@ impl parser { self.eat_keyword(~"static") } - fn parse_mod_items(term: token::token, + fn parse_mod_items(term: token::Token, +first_item_attrs: ~[attribute]) -> _mod { // Shouldn't be any view items since we've already parsed an item attr let {attrs_remaining, view_items, items: starting_items} = @@ -3222,7 +3222,7 @@ impl parser { } } - fn fn_expr_lookahead(tok: token::token) -> bool { + fn fn_expr_lookahead(tok: token::Token) -> bool { match tok { token::LPAREN | token::AT | token::TILDE | token::BINOP(_) => true, _ => false @@ -3608,7 +3608,7 @@ impl parser { return self.fatal(~"expected crate directive"); } - fn parse_crate_directives(term: token::token, + fn parse_crate_directives(term: token::Token, first_outer_attr: ~[attribute]) -> ~[@crate_directive] { |
