syntax: Put the main parser interface in mod parse

This commit is contained in:
Brian Anderson
2012-04-17 23:34:48 -07:00
parent 2c0cb901c8
commit 9a8a04629e
15 changed files with 214 additions and 199 deletions

View File

@@ -1,7 +1,7 @@
// -*- rust -*-
import metadata::{creader, cstore};
import session::session;
import syntax::parse::{parser};
import syntax::parse;
import syntax::{ast, codemap};
import syntax::attr;
import middle::{trans, resolve, freevars, kind, ty, typeck, fn_usage,
@@ -76,10 +76,10 @@ fn input_is_stdin(filename: str) -> bool { filename == "-" }
fn parse_input(sess: session, cfg: ast::crate_cfg, input: str)
-> @ast::crate {
if !input_is_stdin(input) {
parser::parse_crate_from_file(input, cfg, sess.parse_sess)
parse::parse_crate_from_file(input, cfg, sess.parse_sess)
} else {
let src = @str::from_bytes(io::stdin().read_whole_stream());
parser::parse_crate_from_source_str(input, src, cfg, sess.parse_sess)
parse::parse_crate_from_source_str(input, src, cfg, sess.parse_sess)
}
}

View File

@@ -3,7 +3,7 @@ import syntax::{ast, codemap};
import syntax::ast::node_id;
import codemap::span;
import syntax::ast::{int_ty, uint_ty, float_ty};
import syntax::parse::parser::parse_sess;
import syntax::parse::parse_sess;
import util::filesearch;
import back::target_strs;
import middle::lint;
@@ -106,7 +106,7 @@ impl session for session {
self.span_diagnostic.handler().unimpl(msg)
}
fn next_node_id() -> ast::node_id {
ret syntax::parse::parser::next_node_id(self.parse_sess);
ret syntax::parse::next_node_id(self.parse_sess);
}
fn diagnostic() -> diagnostic::span_handler {
self.span_diagnostic

View File

@@ -34,7 +34,7 @@ import e = encoder;
// used in testing:
import driver::diagnostic;
import syntax::codemap;
import syntax::parse::parser;
import syntax::parse;
import syntax::print::pprust;
export encode_inlined_item;
@@ -956,7 +956,7 @@ fn decode_item_ast(par_doc: ebml::doc) -> @ast::item {
}
#[cfg(test)]
fn new_parse_sess() -> parser::parse_sess {
fn new_parse_sess() -> parse::parse_sess {
let cm = codemap::new_codemap();
let handler = diagnostic::mk_handler(option::none);
let sess = @{
@@ -972,7 +972,7 @@ fn new_parse_sess() -> parser::parse_sess {
#[cfg(test)]
iface fake_ext_ctxt {
fn cfg() -> ast::crate_cfg;
fn parse_sess() -> parser::parse_sess;
fn parse_sess() -> parse::parse_sess;
}
#[cfg(test)]
@@ -981,7 +981,7 @@ type fake_session = ();
#[cfg(test)]
impl of fake_ext_ctxt for fake_session {
fn cfg() -> ast::crate_cfg { [] }
fn parse_sess() -> parser::parse_sess { new_parse_sess() }
fn parse_sess() -> parse::parse_sess { new_parse_sess() }
}
#[cfg(test)]