Skip to content

Commit 32e62d0

Browse files
committed
add a -parse-only option to rustc
(undocumented, only used for profiling the parser)
1 parent 9730230 commit 32e62d0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/comp/driver/rustc.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,12 @@ impure fn compile_input(session.session sess,
5959
str input, str output,
6060
bool shared,
6161
bool optimize,
62+
bool parse_only,
6263
vec[str] library_search_paths) {
6364
auto def = tup(0, 0);
6465
auto p = parser.new_parser(sess, env, def, input);
6566
auto crate = parse_input(sess, p, input);
67+
if (parse_only) {ret;}
6668
crate = creader.read_crates(sess, crate, library_search_paths);
6769
crate = resolve.resolve_crate(sess, crate);
6870
auto typeck_result = typeck.check_crate(sess, crate);
@@ -132,6 +134,7 @@ impure fn main(vec[str] args) {
132134
let bool shared = false;
133135
let bool pretty = false;
134136
let bool ls = false;
137+
let bool parse_only = false;
135138
let bool glue = false;
136139

137140
// FIXME: Maybe we should support -O0, -O1, -Os, etc
@@ -156,6 +159,8 @@ impure fn main(vec[str] args) {
156159
pretty = true;
157160
} else if (_str.eq(arg, "-ls")) {
158161
ls = true;
162+
} else if (_str.eq(arg, "-parse-only")) {
163+
parse_only = true;
159164
} else if (_str.eq(arg, "-o")) {
160165
if (i+1u < len) {
161166
output_file = some(args.(i+1u));
@@ -228,11 +233,13 @@ impure fn main(vec[str] args) {
228233
parts += vec(".bc");
229234
auto ofile = _str.concat(parts);
230235
compile_input(sess, env, ifile, ofile, shared,
231-
optimize, library_search_paths);
236+
optimize, parse_only,
237+
library_search_paths);
232238
}
233239
case (some[str](?ofile)) {
234240
compile_input(sess, env, ifile, ofile, shared,
235-
optimize, library_search_paths);
241+
optimize, parse_only,
242+
library_search_paths);
236243
}
237244
}
238245
}

0 commit comments

Comments
 (0)