From 81a79603c0c9c2425d0a8475d29b4ef77fae8607 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 18 Nov 2012 17:42:37 -0800 Subject: [PATCH] Add a temporary hack to divert the parser to an alternate file --- src/libsyntax/parse.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 { 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);