浏览代码

add file to lexer lookup only if we actually parse it (closes #3188)

Simon Krajewski 11 年之前
父节点
当前提交
40ffbc1007
共有 3 个文件被更改,包括 4 次插入4 次删除
  1. 2 2
      lexer.mll
  2. 1 1
      typeload.ml
  3. 1 1
      typer.ml

+ 2 - 2
lexer.mll

@@ -85,10 +85,10 @@ let keywords =
 		Inline;Using;Null;True;False;Abstract;Macro];
 	h
 
-let init file =
+let init file do_add =
 	let f = make_file file in
 	cur := f;
-	Hashtbl.replace all_files file f
+	if do_add then Hashtbl.replace all_files file f
 
 let save() =
 	!cur

+ 1 - 1
typeload.ml

@@ -208,7 +208,7 @@ let make_module ctx mpath file tdecls loadp =
 let parse_file com file p =
 	let ch = (try open_in_bin file with _ -> error ("Could not open " ^ file) p) in
 	let t = Common.timer "parsing" in
-	Lexer.init file;
+	Lexer.init file true;
 	incr stats.s_files_parsed;
 	let data = (try Parser.parse com (Lexing.from_channel ch) with e -> close_in ch; t(); raise e) in
 	close_in ch;

+ 1 - 1
typer.ml

@@ -339,7 +339,7 @@ let parse_string ctx s p inlined =
 		Lexer.restore old;
 		Parser.display_error := old_de
 	in
-	Lexer.init p.pfile;
+	Lexer.init p.pfile false;
 	Parser.display_error := (fun e p -> raise (Parser.Error (e,p)));
 	if not inlined then Parser.resume_display := null_pos;
 	let _, decls = try