diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-11-18 17:42:37 -0800 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-11-26 18:13:54 -0800 |
| commit | 81a79603c0c9c2425d0a8475d29b4ef77fae8607 (patch) | |
| tree | 3fed9ba476c2e53419f3e22a85189e044747b002 /src/libsyntax | |
| parent | 58e26243a7d7efa8e37703fb6dca95652c79f848 (diff) | |
| download | rust-81a79603c0c9c2425d0a8475d29b4ef77fae8607.tar.gz rust-81a79603c0c9c2425d0a8475d29b4ef77fae8607.zip | |
Add a temporary hack to divert the parser to an alternate file
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/parse.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libsyntax/parse.rs b/src/libsyntax/parse.rs index 3ddb03547cb..d1388bedad9 100644 --- a/src/libsyntax/parse.rs +++ b/src/libsyntax/parse.rs @@ -175,6 +175,18 @@ fn new_parser_from_file(sess: parse_sess, cfg: ast::crate_cfg, path: &Path) -> Result<Parser, ~str> { match io::read_whole_file_str(path) { result::Ok(move src) => { + + // HACK: If the file contains a special token use a different + // source file. Used to send the stage1+ parser (the stage0 parser + // doesn't have this hack) to a different crate file. + // Transitional. Remove me. + let src = if src.starts_with("// DIVERT") { + let actual_path = &path.with_filestem("alternate_crate"); + result::unwrap(io::read_whole_file_str(actual_path)) + } else { + move src + }; + let filemap = sess.cm.new_filemap(path.to_str(), @move src); let srdr = lexer::new_string_reader(sess.span_diagnostic, filemap, sess.interner); |
