about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-01-08 19:29:16 -0800
committerPatrick Walton <pcwalton@mimiga.net>2013-01-08 19:29:16 -0800
commit44ab00ee37c4ffb8440ff20fd8a15cd24a6f3e46 (patch)
tree83f3d67a9e21c6ce1b99c2ce8f6a737896c673db /src/libsyntax/parse
parenta8d37af2473da79be704c9ce2374f278c47177b6 (diff)
downloadrust-44ab00ee37c4ffb8440ff20fd8a15cd24a6f3e46.tar.gz
rust-44ab00ee37c4ffb8440ff20fd8a15cd24a6f3e46.zip
Revert "librustc: Make unqualified identifier searches terminate at the nearest module scope. r=tjc"
This reverts commit a8d37af2473da79be704c9ce2374f278c47177b6.
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/attr.rs3
-rw-r--r--src/libsyntax/parse/comments.rs4
-rw-r--r--src/libsyntax/parse/common.rs4
-rw-r--r--src/libsyntax/parse/lexer.rs4
-rw-r--r--src/libsyntax/parse/mod.rs106
-rw-r--r--src/libsyntax/parse/obsolete.rs3
-rw-r--r--src/libsyntax/parse/parser.rs38
-rw-r--r--src/libsyntax/parse/prec.rs4
-rw-r--r--src/libsyntax/parse/token.rs2
9 files changed, 80 insertions, 88 deletions
diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs
index 49197be4bb9..a3fd069afbb 100644
--- a/src/libsyntax/parse/attr.rs
+++ b/src/libsyntax/parse/attr.rs
@@ -8,11 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use core::prelude::*;
-
 use ast;
 use ast_util::spanned;
-use codemap::BytePos;
 use parse::common::*; //resolve bug?
 use parse::token;
 
diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs
index 0e101d54ba3..d5365d59041 100644
--- a/src/libsyntax/parse/comments.rs
+++ b/src/libsyntax/parse/comments.rs
@@ -8,10 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use core::prelude::*;
-
 use ast;
-use codemap::{BytePos, CharPos, CodeMap, FileMap};
+use codemap::{CodeMap, FileMap, CharPos};
 use diagnostic;
 use parse::lexer::{is_whitespace, get_str_from, reader};
 use parse::lexer::{string_reader, bump, is_eof, nextch};
diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs
index 1c6022130dc..ca0bbbb7369 100644
--- a/src/libsyntax/parse/common.rs
+++ b/src/libsyntax/parse/common.rs
@@ -8,16 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use core::prelude::*;
-
 use ast;
 use ast_util::spanned;
-use codemap::BytePos;
 use parse::lexer::reader;
 use parse::parser::Parser;
 use parse::token;
 
-use core::option::{None, Option, Some};
 use core::option;
 use std::map::HashMap;
 
diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs
index 573c36e619b..c51f7e4dad6 100644
--- a/src/libsyntax/parse/lexer.rs
+++ b/src/libsyntax/parse/lexer.rs
@@ -8,15 +8,13 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use core::prelude::*;
-
 use ast;
 use ast_util;
 use codemap::{span, CodeMap, CharPos, BytePos};
 use codemap;
 use diagnostic::span_handler;
 use ext::tt::transcribe::{tt_next_token};
-use ext::tt::transcribe::{tt_reader, new_tt_reader, dup_tt_reader};
+use ext::tt::transcribe::{tt_reader,  new_tt_reader, dup_tt_reader};
 use parse::token;
 
 use core::char;
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs
index b14b60af134..fb5c6250179 100644
--- a/src/libsyntax/parse/mod.rs
+++ b/src/libsyntax/parse/mod.rs
@@ -10,6 +10,8 @@
 
 //! The main parser interface
 
+#[legacy_exports];
+
 use ast::node_id;
 use ast;
 use codemap::{span, CodeMap, FileMap, CharPos, BytePos};
@@ -22,47 +24,70 @@ use parse::token::{ident_interner, mk_ident_interner};
 use util::interner;
 
 use core::io;
-use core::option::{None, Option, Some};
-use core::path::Path;
-use core::result::{Err, Ok, Result};
 use core::result;
 
+export parser;
+export common;
+export lexer;
+export token;
+export comments;
+export prec;
+export classify;
+export attr;
+export obsolete;
+
+export parse_sess;
+export new_parse_sess, new_parse_sess_special_handler;
+export next_node_id;
+export new_parser_from_file, new_parser_etc_from_file;
+export new_parser_from_source_str;
+export new_parser_from_tts;
+export new_sub_parser_from_file;
+export parse_crate_from_file, parse_crate_from_crate_file;
+export parse_crate_from_source_str;
+export parse_expr_from_source_str, parse_item_from_source_str;
+export parse_stmt_from_source_str;
+export parse_tts_from_source_str;
+export parse_from_source_str;
+
+
 #[legacy_exports]
-pub mod lexer;
+mod lexer;
 #[legacy_exports]
-pub mod parser;
+mod parser;
 #[legacy_exports]
-pub mod token;
+mod token;
 #[legacy_exports]
-pub mod comments;
+mod comments;
 #[legacy_exports]
-pub mod attr;
+mod attr;
 #[legacy_exports]
 
 /// Common routines shared by parser mods
 #[legacy_exports]
-pub mod common;
+mod common;
 
 /// Functions dealing with operator precedence
 #[legacy_exports]
-pub mod prec;
+mod prec;
 
 /// Routines the parser uses to classify AST nodes
 #[legacy_exports]
-pub mod classify;
+mod classify;
 
 /// Reporting obsolete syntax
 #[legacy_exports]
-pub mod obsolete;
+mod obsolete;
+
 
-pub type parse_sess = @{
+type parse_sess = @{
     cm: @codemap::CodeMap,
     mut next_id: node_id,
     span_diagnostic: span_handler,
     interner: @ident_interner,
 };
 
-pub fn new_parse_sess(demitter: Option<emitter>) -> parse_sess {
+fn new_parse_sess(demitter: Option<emitter>) -> parse_sess {
     let cm = @CodeMap::new();
     return @{cm: cm,
              mut next_id: 1,
@@ -71,7 +96,7 @@ pub fn new_parse_sess(demitter: Option<emitter>) -> parse_sess {
             };
 }
 
-pub fn new_parse_sess_special_handler(sh: span_handler, cm: @codemap::CodeMap)
+fn new_parse_sess_special_handler(sh: span_handler, cm: @codemap::CodeMap)
     -> parse_sess {
     return @{cm: cm,
              mut next_id: 1,
@@ -80,17 +105,15 @@ pub fn new_parse_sess_special_handler(sh: span_handler, cm: @codemap::CodeMap)
              };
 }
 
-pub fn parse_crate_from_file(input: &Path, cfg: ast::crate_cfg,
+fn parse_crate_from_file(input: &Path, cfg: ast::crate_cfg,
                          sess: parse_sess) -> @ast::crate {
     let p = new_crate_parser_from_file(sess, cfg, input);
     let r = p.parse_crate_mod(cfg);
     return r;
 }
 
-pub fn parse_crate_from_source_str(name: ~str,
-                                   source: @~str,
-                                   cfg: ast::crate_cfg,
-                                   sess: parse_sess) -> @ast::crate {
+fn parse_crate_from_source_str(name: ~str, source: @~str, cfg: ast::crate_cfg,
+                               sess: parse_sess) -> @ast::crate {
     let p = new_parser_from_source_str(sess, cfg, name,
                                        codemap::FssNone, source);
     let r = p.parse_crate_mod(cfg);
@@ -98,10 +121,8 @@ pub fn parse_crate_from_source_str(name: ~str,
     return r;
 }
 
-pub fn parse_expr_from_source_str(name: ~str,
-                                  source: @~str,
-                                  cfg: ast::crate_cfg,
-                                  sess: parse_sess) -> @ast::expr {
+fn parse_expr_from_source_str(name: ~str, source: @~str, cfg: ast::crate_cfg,
+                              sess: parse_sess) -> @ast::expr {
     let p = new_parser_from_source_str(sess, cfg, name,
                                        codemap::FssNone, source);
     let r = p.parse_expr();
@@ -109,12 +130,9 @@ pub fn parse_expr_from_source_str(name: ~str,
     return r;
 }
 
-pub fn parse_item_from_source_str(name: ~str,
-                                  source: @~str,
-                                  cfg: ast::crate_cfg,
-                                  +attrs: ~[ast::attribute],
-                                  sess: parse_sess)
-                               -> Option<@ast::item> {
+fn parse_item_from_source_str(name: ~str, source: @~str, cfg: ast::crate_cfg,
+                              +attrs: ~[ast::attribute],
+                              sess: parse_sess) -> Option<@ast::item> {
     let p = new_parser_from_source_str(sess, cfg, name,
                                        codemap::FssNone, source);
     let r = p.parse_item(attrs);
@@ -122,11 +140,9 @@ pub fn parse_item_from_source_str(name: ~str,
     return r;
 }
 
-pub fn parse_stmt_from_source_str(name: ~str,
-                                  source: @~str,
-                                  cfg: ast::crate_cfg,
-                                  +attrs: ~[ast::attribute],
-                                  sess: parse_sess) -> @ast::stmt {
+fn parse_stmt_from_source_str(name: ~str, source: @~str, cfg: ast::crate_cfg,
+                              +attrs: ~[ast::attribute],
+                              sess: parse_sess) -> @ast::stmt {
     let p = new_parser_from_source_str(sess, cfg, name,
                                        codemap::FssNone, source);
     let r = p.parse_stmt(attrs);
@@ -134,10 +150,8 @@ pub fn parse_stmt_from_source_str(name: ~str,
     return r;
 }
 
-pub fn parse_tts_from_source_str(name: ~str,
-                                 source: @~str,
-                                 cfg: ast::crate_cfg,
-                                 sess: parse_sess) -> ~[ast::token_tree] {
+fn parse_tts_from_source_str(name: ~str, source: @~str, cfg: ast::crate_cfg,
+                             sess: parse_sess) -> ~[ast::token_tree] {
     let p = new_parser_from_source_str(sess, cfg, name,
                                        codemap::FssNone, source);
     p.quote_depth += 1u;
@@ -146,7 +160,7 @@ pub fn parse_tts_from_source_str(name: ~str,
     return r;
 }
 
-pub fn parse_from_source_str<T>(f: fn (p: Parser) -> T,
+fn parse_from_source_str<T>(f: fn (p: Parser) -> T,
                             name: ~str, ss: codemap::FileSubstr,
                             source: @~str, cfg: ast::crate_cfg,
                             sess: parse_sess)
@@ -162,7 +176,7 @@ pub fn parse_from_source_str<T>(f: fn (p: Parser) -> T,
     move r
 }
 
-pub fn next_node_id(sess: parse_sess) -> node_id {
+fn next_node_id(sess: parse_sess) -> node_id {
     let rv = sess.next_id;
     sess.next_id += 1;
     // ID 0 is reserved for the crate and doesn't actually exist in the AST
@@ -170,7 +184,7 @@ pub fn next_node_id(sess: parse_sess) -> node_id {
     return rv;
 }
 
-pub fn new_parser_from_source_str(sess: parse_sess, cfg: ast::crate_cfg,
+fn new_parser_from_source_str(sess: parse_sess, cfg: ast::crate_cfg,
                               +name: ~str, +ss: codemap::FileSubstr,
                               source: @~str) -> Parser {
     let filemap = sess.cm.new_filemap_w_substr(name, ss, source);
@@ -179,7 +193,7 @@ pub fn new_parser_from_source_str(sess: parse_sess, cfg: ast::crate_cfg,
     return Parser(sess, cfg, srdr as reader);
 }
 
-pub fn new_parser_from_file(sess: parse_sess, cfg: ast::crate_cfg,
+fn new_parser_from_file(sess: parse_sess, cfg: ast::crate_cfg,
                         path: &Path) -> Result<Parser, ~str> {
     match io::read_whole_file_str(path) {
       result::Ok(move src) => {
@@ -197,7 +211,7 @@ pub fn new_parser_from_file(sess: parse_sess, cfg: ast::crate_cfg,
 
 /// Create a new parser for an entire crate, handling errors as appropriate
 /// if the file doesn't exist
-pub fn new_crate_parser_from_file(sess: parse_sess, cfg: ast::crate_cfg,
+fn new_crate_parser_from_file(sess: parse_sess, cfg: ast::crate_cfg,
                               path: &Path) -> Parser {
     match new_parser_from_file(sess, cfg, path) {
         Ok(move parser) => move parser,
@@ -209,7 +223,7 @@ pub fn new_crate_parser_from_file(sess: parse_sess, cfg: ast::crate_cfg,
 
 /// Create a new parser based on a span from an existing parser. Handles
 /// error messages correctly when the file does not exist.
-pub fn new_sub_parser_from_file(sess: parse_sess, cfg: ast::crate_cfg,
+fn new_sub_parser_from_file(sess: parse_sess, cfg: ast::crate_cfg,
                             path: &Path, sp: span) -> Parser {
     match new_parser_from_file(sess, cfg, path) {
         Ok(move parser) => move parser,
@@ -219,7 +233,7 @@ pub fn new_sub_parser_from_file(sess: parse_sess, cfg: ast::crate_cfg,
     }
 }
 
-pub fn new_parser_from_tts(sess: parse_sess, cfg: ast::crate_cfg,
+fn new_parser_from_tts(sess: parse_sess, cfg: ast::crate_cfg,
                        tts: ~[ast::token_tree]) -> Parser {
     let trdr = lexer::new_tt_reader(sess.span_diagnostic, sess.interner,
                                     None, tts);
diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs
index 15905c090db..6b73cf308a2 100644
--- a/src/libsyntax/parse/obsolete.rs
+++ b/src/libsyntax/parse/obsolete.rs
@@ -17,13 +17,10 @@ Obsolete syntax that becomes too hard to parse can be
 removed.
 */
 
-use core::prelude::*;
-
 use ast::{expr, expr_lit, lit_nil};
 use ast;
 use ast_util::{respan};
 use codemap::span;
-use parse::parser::Parser;
 use parse::token::Token;
 use parse::token;
 
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 80fd04f0e10..f32a782622a 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use core::prelude::*;
-
 use ast::{ProtoBox, ProtoUniq, provided, public, pure_fn, purity, re_static};
 use ast::{_mod, add, arg, arm, attribute, bind_by_ref, bind_infer};
 use ast::{bind_by_value, bind_by_move, bitand, bitor, bitxor, blk};
@@ -35,24 +33,23 @@ use ast::{lit_bool, lit_float, lit_float_unsuffixed, lit_int};
 use ast::{lit_int_unsuffixed, lit_nil, lit_str, lit_uint, local, m_const};
 use ast::{m_imm, m_mutbl, mac_, mac_invoc_tt, matcher, match_nonterminal};
 use ast::{match_seq, match_tok, method, mode, module_ns, mt, mul, mutability};
-use ast::{named_field, neg, node_id, noreturn, not, pat, pat_box, pat_enum};
-use ast::{pat_ident, pat_lit, pat_range, pat_rec, pat_region, pat_struct};
-use ast::{pat_tup, pat_uniq, pat_wild, path, private, Proto, ProtoBare};
-use ast::{ProtoBorrowed, re_self, re_anon, re_named, region, rem, required};
-use ast::{ret_style, return_val, self_ty, shl, shr, stmt, stmt_decl};
-use ast::{stmt_expr, stmt_semi, stmt_mac, struct_def, struct_field};
-use ast::{struct_immutable, struct_mutable, struct_variant_kind, subtract};
-use ast::{sty_box, sty_by_ref, sty_region, sty_static, sty_uniq, sty_value};
-use ast::{token_tree, trait_method, trait_ref, tt_delim, tt_seq, tt_tok};
-use ast::{tt_nonterminal, tuple_variant_kind, Ty, ty_, ty_bot, ty_box};
-use ast::{ty_field, ty_fixed_length_vec, ty_fn, ty_infer, ty_mac, ty_method};
-use ast::{ty_nil, ty_param, ty_param_bound, ty_path, ty_ptr, ty_rec, ty_rptr};
-use ast::{ty_tup, ty_u32, ty_uniq, ty_vec, type_value_ns, uniq};
-use ast::{unnamed_field, unsafe_blk, unsafe_fn, variant, view_item};
-use ast::{view_item_, view_item_export, view_item_import, view_item_use};
-use ast::{view_path, view_path_glob, view_path_list, view_path_simple};
-use ast::{visibility, vstore, vstore_box, vstore_fixed, vstore_slice};
-use ast::{vstore_uniq};
+use ast::{named_field, neg, noreturn, not, pat, pat_box, pat_enum, pat_ident};
+use ast::{pat_lit, pat_range, pat_rec, pat_region, pat_struct, pat_tup};
+use ast::{pat_uniq, pat_wild, path, private, Proto, ProtoBare, ProtoBorrowed};
+use ast::{re_self, re_anon, re_named, region, rem, required, ret_style};
+use ast::{return_val, self_ty, shl, shr, stmt, stmt_decl, stmt_expr};
+use ast::{stmt_semi, stmt_mac, struct_def, struct_field, struct_immutable};
+use ast::{struct_mutable, struct_variant_kind, subtract, sty_box, sty_by_ref};
+use ast::{sty_region, sty_static, sty_uniq, sty_value, token_tree};
+use ast::{trait_method, trait_ref, tt_delim, tt_seq, tt_tok, tt_nonterminal};
+use ast::{tuple_variant_kind, Ty, ty_, ty_bot, ty_box, ty_field, ty_fn};
+use ast::{ty_fixed_length_vec, type_value_ns, uniq, unnamed_field};
+use ast::{ty_infer, ty_mac, ty_method, ty_nil, ty_param, ty_param_bound};
+use ast::{ty_path, ty_ptr, ty_rec, ty_rptr, ty_tup, ty_u32, ty_uniq, ty_vec};
+use ast::{unsafe_blk, unsafe_fn, variant, view_item, view_item_};
+use ast::{view_item_export, view_item_import, view_item_use, view_path};
+use ast::{view_path_glob, view_path_list, view_path_simple, visibility};
+use ast::{vstore, vstore_box, vstore_fixed, vstore_slice, vstore_uniq};
 use ast;
 use ast_util::{spanned, respan, mk_sp, ident_to_path, operator_prec};
 use ast_util;
@@ -72,7 +69,6 @@ use parse::prec::{as_prec, token_to_binop};
 use parse::token::{can_begin_expr, is_ident, is_ident_or_path};
 use parse::token::{is_plain_ident, INTERPOLATED, special_idents};
 use parse::token;
-use parse::{new_sub_parser_from_file, next_node_id, parse_sess};
 use print::pprust::expr_to_str;
 use util::interner::Interner;
 
diff --git a/src/libsyntax/parse/prec.rs b/src/libsyntax/parse/prec.rs
index 10754777129..4663b875bb5 100644
--- a/src/libsyntax/parse/prec.rs
+++ b/src/libsyntax/parse/prec.rs
@@ -12,11 +12,9 @@ export as_prec;
 export unop_prec;
 export token_to_binop;
 
-use ast::*;
 use parse::token::*;
 use parse::token::Token;
-
-use core::prelude::*;
+use ast::*;
 
 /// Unary operators have higher precedence than binary
 const unop_prec: uint = 100u;
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index 606247b8cbe..f286b15c752 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use core::prelude::*;
-
 use ast;
 use ast_util;
 use parse::token;