Split driver between parsing source files and crate files, by extension. Add dummy function for crate files.
This commit is contained in:
parent
001d7bfa17
commit
d1517471fb
@ -13,10 +13,22 @@ import std.option.none;
|
||||
import std._str;
|
||||
import std._vec;
|
||||
|
||||
impure fn parse_input(session.session sess,
|
||||
parser.parser p,
|
||||
str input) -> @front.ast.crate {
|
||||
if (_str.ends_with(input, ".rc")) {
|
||||
ret parser.parse_crate_from_crate_file(p);
|
||||
} else if (_str.ends_with(input, ".rs")) {
|
||||
ret parser.parse_crate_from_source_file(p);
|
||||
}
|
||||
sess.err("unknown unput file type: " + input);
|
||||
fail;
|
||||
}
|
||||
|
||||
impure fn compile_input(session.session sess, str input, str output,
|
||||
bool shared) {
|
||||
auto p = parser.new_parser(sess, 0, input);
|
||||
auto crate = parser.parse_crate(p);
|
||||
auto crate = parse_input(sess, p, input);
|
||||
crate = resolve.resolve_crate(sess, crate);
|
||||
crate = typeck.check_crate(sess, crate);
|
||||
trans.trans_crate(sess, crate, output, shared);
|
||||
|
@ -1738,7 +1738,14 @@ impure fn parse_use_and_imports(parser p) -> vec[ast.use_or_import] {
|
||||
}
|
||||
}
|
||||
|
||||
impure fn parse_crate(parser p) -> @ast.crate {
|
||||
impure fn parse_crate_from_crate_file(parser p) -> @ast.crate {
|
||||
auto lo = p.get_span();
|
||||
auto hi = lo;
|
||||
auto m = parse_mod_items(p, token.EOF);
|
||||
ret @spanned(lo, hi, rec(module=m));
|
||||
}
|
||||
|
||||
impure fn parse_crate_from_source_file(parser p) -> @ast.crate {
|
||||
auto lo = p.get_span();
|
||||
auto hi = lo;
|
||||
auto m = parse_mod_items(p, token.EOF);
|
||||
|
Loading…
Reference in New Issue
Block a user