File tree Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: 001d7bfa174dc8097268bf41368c84474aafcd3a
2
+ refs/heads/master: d1517471fbe45781a39afed6367944491ce8f4b1
Original file line number Diff line number Diff line change @@ -13,10 +13,22 @@ import std.option.none;
13
13
import std. _str ;
14
14
import std. _vec ;
15
15
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
+
16
28
impure fn compile_input ( session. session sess, str input, str output,
17
29
bool shared) {
18
30
auto p = parser. new_parser ( sess, 0 , input) ;
19
- auto crate = parser . parse_crate ( p ) ;
31
+ auto crate = parse_input ( sess , p , input ) ;
20
32
crate = resolve. resolve_crate ( sess, crate ) ;
21
33
crate = typeck. check_crate ( sess, crate ) ;
22
34
trans. trans_crate ( sess, crate , output, shared) ;
Original file line number Diff line number Diff line change @@ -1738,7 +1738,14 @@ impure fn parse_use_and_imports(parser p) -> vec[ast.use_or_import] {
1738
1738
}
1739
1739
}
1740
1740
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 {
1742
1749
auto lo = p. get_span ( ) ;
1743
1750
auto hi = lo;
1744
1751
auto m = parse_mod_items ( p, token. EOF ) ;
You can’t perform that action at this time.
0 commit comments