Skip to content

Commit 9d71a39

Browse files
committed
---
yaml --- r: 1185 b: refs/heads/master c: d151747 h: refs/heads/master i: 1183: 7a4f557 v: v3
1 parent 144c109 commit 9d71a39

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 001d7bfa174dc8097268bf41368c84474aafcd3a
2+
refs/heads/master: d1517471fbe45781a39afed6367944491ce8f4b1

trunk/src/comp/driver/rustc.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,22 @@ import std.option.none;
1313
import std._str;
1414
import std._vec;
1515

16+
impure fn parse_input(session.session sess,
17+
parser.parser p,
18+
str input) -> @front.ast.crate {
19+
if (_str.ends_with(input, ".rc")) {
20+
ret parser.parse_crate_from_crate_file(p);
21+
} else if (_str.ends_with(input, ".rs")) {
22+
ret parser.parse_crate_from_source_file(p);
23+
}
24+
sess.err("unknown unput file type: " + input);
25+
fail;
26+
}
27+
1628
impure fn compile_input(session.session sess, str input, str output,
1729
bool shared) {
1830
auto p = parser.new_parser(sess, 0, input);
19-
auto crate = parser.parse_crate(p);
31+
auto crate = parse_input(sess, p, input);
2032
crate = resolve.resolve_crate(sess, crate);
2133
crate = typeck.check_crate(sess, crate);
2234
trans.trans_crate(sess, crate, output, shared);

trunk/src/comp/front/parser.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1738,7 +1738,14 @@ impure fn parse_use_and_imports(parser p) -> vec[ast.use_or_import] {
17381738
}
17391739
}
17401740

1741-
impure fn parse_crate(parser p) -> @ast.crate {
1741+
impure fn parse_crate_from_crate_file(parser p) -> @ast.crate {
1742+
auto lo = p.get_span();
1743+
auto hi = lo;
1744+
auto m = parse_mod_items(p, token.EOF);
1745+
ret @spanned(lo, hi, rec(module=m));
1746+
}
1747+
1748+
impure fn parse_crate_from_source_file(parser p) -> @ast.crate {
17421749
auto lo = p.get_span();
17431750
auto hi = lo;
17441751
auto m = parse_mod_items(p, token.EOF);

0 commit comments

Comments
 (0)