Skip to content

Commit 81a7960

Browse files
committed
Add a temporary hack to divert the parser to an alternate file
1 parent 58e2624 commit 81a7960

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/libsyntax/parse.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,18 @@ fn new_parser_from_file(sess: parse_sess, cfg: ast::crate_cfg,
175175
path: &Path) -> Result<Parser, ~str> {
176176
match io::read_whole_file_str(path) {
177177
result::Ok(move src) => {
178+
179+
// HACK: If the file contains a special token use a different
180+
// source file. Used to send the stage1+ parser (the stage0 parser
181+
// doesn't have this hack) to a different crate file.
182+
// Transitional. Remove me.
183+
let src = if src.starts_with("// DIVERT") {
184+
let actual_path = &path.with_filestem("alternate_crate");
185+
result::unwrap(io::read_whole_file_str(actual_path))
186+
} else {
187+
move src
188+
};
189+
178190
let filemap = sess.cm.new_filemap(path.to_str(), @move src);
179191
let srdr = lexer::new_string_reader(sess.span_diagnostic, filemap,
180192
sess.interner);

0 commit comments

Comments
 (0)