diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-06-10 00:49:59 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-06-13 11:30:45 -0700 |
| commit | ce750a7dbcd2dc68db6de89956b1de3ecf9f2d0a (patch) | |
| tree | 55c2ee5be0986c2489879022d4788d6c3ac2c964 /src/libsyntax/parse | |
| parent | bdd20000665a35e14b4ec2c54f893fc80fe451ef (diff) | |
| download | rust-ce750a7dbcd2dc68db6de89956b1de3ecf9f2d0a.tar.gz rust-ce750a7dbcd2dc68db6de89956b1de3ecf9f2d0a.zip | |
Box AST idents
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/common.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/parse/eval.rs | 16 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 28 |
3 files changed, 25 insertions, 25 deletions
diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs index 0520993de74..c8e62a2245d 100644 --- a/src/libsyntax/parse/common.rs +++ b/src/libsyntax/parse/common.rs @@ -81,7 +81,7 @@ impl parser_common for parser { fn token_is_keyword(word: str, ++tok: token::token) -> bool { self.require_keyword(word); alt tok { - token::IDENT(sid, false) { str::eq(word, self.get_str(sid)) } + token::IDENT(sid, false) { str::eq(word, *self.get_str(sid)) } _ { false } } } @@ -97,7 +97,7 @@ impl parser_common for parser { // workaround LLVM bug #13042 alt @self.token { @token::IDENT(sid, false) { - if str::eq(word, self.get_str(sid)) { + if str::eq(word, *self.get_str(sid)) { self.bump(); ret true; } else { ret false; } @@ -128,7 +128,7 @@ impl parser_common for parser { } } - fn check_restricted_keywords_(w: ast::ident) { + fn check_restricted_keywords_(w: str) { if self.is_restricted_keyword(w) { self.fatal("found `" + w + "` in restricted position"); } diff --git a/src/libsyntax/parse/eval.rs b/src/libsyntax/parse/eval.rs index 254d5cc5d5d..4b5632124d8 100644 --- a/src/libsyntax/parse/eval.rs +++ b/src/libsyntax/parse/eval.rs @@ -75,7 +75,7 @@ fn parse_companion_mod(cx: ctx, prefix: str, suffix: option<str>) } } -fn cdir_path_opt(id: str, attrs: [ast::attribute]) -> str { +fn cdir_path_opt(id: ast::ident, attrs: [ast::attribute]) -> @str { alt ::attr::first_attr_value_str_by_name(attrs, "path") { some(d) { ret d; @@ -89,11 +89,11 @@ fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: str, &items: [@ast::item]) { alt cdir.node { ast::cdir_src_mod(id, attrs) { - let file_path = cdir_path_opt(id + ".rs", attrs); + let file_path = cdir_path_opt(@(*id + ".rs"), attrs); let full_path = - if path::path_is_absolute(file_path) { - file_path - } else { prefix + path::path_sep() + file_path }; + if path::path_is_absolute(*file_path) { + *file_path + } else { prefix + path::path_sep() + *file_path }; let p0 = new_parser_from_file(cx.sess, cx.cfg, full_path, SOURCE_FILE); let inner_attrs = p0.parse_inner_attrs_and_next(); @@ -112,9 +112,9 @@ fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: str, ast::cdir_dir_mod(id, cdirs, attrs) { let path = cdir_path_opt(id, attrs); let full_path = - if path::path_is_absolute(path) { - path - } else { prefix + path::path_sep() + path }; + if path::path_is_absolute(*path) { + *path + } else { prefix + path::path_sep() + *path }; let (m0, a0) = eval_crate_directives_to_mod( cx, cdirs, full_path, none); let i = diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 828cd5ce7d4..975e9031877 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -151,8 +151,8 @@ class parser { fn warn(m: str) { self.sess.span_diagnostic.span_warn(copy self.span, m) } - fn get_str(i: token::str_num) -> str { - *interner::get(*self.reader.interner, i) + fn get_str(i: token::str_num) -> @str { + interner::get(*self.reader.interner, i) } fn get_id() -> node_id { next_node_id(self.sess) } @@ -178,7 +178,7 @@ class parser { let name = self.parse_value_ident(); p.bump(); name - } else { "" }; + } else { @"" }; {mode: mode, ty: p.parse_ty(false), ident: name, id: p.get_id()} @@ -229,7 +229,7 @@ class parser { fn ident_index(args: [arg], i: ident) -> uint { let mut j = 0u; for args.each {|a| if a.ident == i { ret j; } j += 1u; } - self.fatal("unbound variable `" + i + "` in constraint arg"); + self.fatal("unbound variable `" + *i + "` in constraint arg"); } fn parse_type_constr_arg() -> @ty_constr_arg { @@ -315,7 +315,7 @@ class parser { } } - fn region_from_name(s: option<str>) -> @region { + fn region_from_name(s: option<@str>) -> @region { let r = alt s { some (string) { re_named(string) } none { re_anon } @@ -1858,13 +1858,13 @@ class parser { fn parse_method_name() -> ident { alt copy self.token { - token::BINOP(op) { self.bump(); token::binop_to_str(op) } - token::NOT { self.bump(); "!" } - token::LBRACKET { self.bump(); self.expect(token::RBRACKET); "[]" } + token::BINOP(op) { self.bump(); @token::binop_to_str(op) } + token::NOT { self.bump(); @"!" } + token::LBRACKET { self.bump(); self.expect(token::RBRACKET); @"[]" } _ { let id = self.parse_value_ident(); - if id == "unary" && self.eat(token::BINOP(token::MINUS)) { - "unary-" + if id == @"unary" && self.eat(token::BINOP(token::MINUS)) { + @"unary-" } else { id } } @@ -1969,7 +1969,7 @@ class parser { // Hack. But then, this whole function is in service of a hack. let a_r = alt rp { rp_none { none } - rp_self { some(self.region_from_name(some("self"))) } + rp_self { some(self.region_from_name(some(@"self"))) } }; @{span: s, global: false, idents: [i], @@ -2243,7 +2243,7 @@ class parser { let mut variants: [variant] = []; // Newtype syntax if self.token == token::EQ { - self.check_restricted_keywords_(id); + self.check_restricted_keywords_(*id); self.bump(); let ty = self.parse_ty(false); self.expect(token::SEMI); @@ -2381,7 +2381,7 @@ class parser { let lo = self.span.lo; let first_ident = self.parse_ident(); let mut path = [first_ident]; - #debug("parsed view_path: %s", first_ident); + #debug("parsed view_path: %s", *first_ident); alt self.token { token::EQ { // x = foo::bar @@ -2504,7 +2504,7 @@ class parser { config: self.cfg}); } - fn parse_str() -> str { + fn parse_str() -> @str { alt copy self.token { token::LIT_STR(s) { self.bump(); self.get_str(s) } _ { |
