add a -parse-only option to rustc

(undocumented, only used for profiling the parser)
This commit is contained in:
Marijn Haverbeke 2011-04-07 23:55:02 +02:00
parent 973023030e
commit 32e62d0151

View File

@ -59,10 +59,12 @@ impure fn compile_input(session.session sess,
str input, str output, str input, str output,
bool shared, bool shared,
bool optimize, bool optimize,
bool parse_only,
vec[str] library_search_paths) { vec[str] library_search_paths) {
auto def = tup(0, 0); auto def = tup(0, 0);
auto p = parser.new_parser(sess, env, def, input); auto p = parser.new_parser(sess, env, def, input);
auto crate = parse_input(sess, p, input); auto crate = parse_input(sess, p, input);
if (parse_only) {ret;}
crate = creader.read_crates(sess, crate, library_search_paths); crate = creader.read_crates(sess, crate, library_search_paths);
crate = resolve.resolve_crate(sess, crate); crate = resolve.resolve_crate(sess, crate);
auto typeck_result = typeck.check_crate(sess, crate); auto typeck_result = typeck.check_crate(sess, crate);
@ -132,6 +134,7 @@ impure fn main(vec[str] args) {
let bool shared = false; let bool shared = false;
let bool pretty = false; let bool pretty = false;
let bool ls = false; let bool ls = false;
let bool parse_only = false;
let bool glue = false; let bool glue = false;
// FIXME: Maybe we should support -O0, -O1, -Os, etc // FIXME: Maybe we should support -O0, -O1, -Os, etc
@ -156,6 +159,8 @@ impure fn main(vec[str] args) {
pretty = true; pretty = true;
} else if (_str.eq(arg, "-ls")) { } else if (_str.eq(arg, "-ls")) {
ls = true; ls = true;
} else if (_str.eq(arg, "-parse-only")) {
parse_only = true;
} else if (_str.eq(arg, "-o")) { } else if (_str.eq(arg, "-o")) {
if (i+1u < len) { if (i+1u < len) {
output_file = some(args.(i+1u)); output_file = some(args.(i+1u));
@ -228,11 +233,13 @@ impure fn main(vec[str] args) {
parts += vec(".bc"); parts += vec(".bc");
auto ofile = _str.concat(parts); auto ofile = _str.concat(parts);
compile_input(sess, env, ifile, ofile, shared, compile_input(sess, env, ifile, ofile, shared,
optimize, library_search_paths); optimize, parse_only,
library_search_paths);
} }
case (some[str](?ofile)) { case (some[str](?ofile)) {
compile_input(sess, env, ifile, ofile, shared, compile_input(sess, env, ifile, ofile, shared,
optimize, library_search_paths); optimize, parse_only,
library_search_paths);
} }
} }
} }