Pārlūkot izejas kodu

[parser] group parser display information

Simon Krajewski 6 gadi atpakaļ
vecāks
revīzija
2c92694e69

+ 1 - 1
src/macro/eval/evalDebugMisc.ml

@@ -81,7 +81,7 @@ exception Parse_expr_error of string
 let parse_expr ctx s p =
 	let error s = raise (Parse_expr_error s) in
 	match ParserEntry.parse_expr_string (ctx.curapi.get_com()).Common.defines s p error true with
-	| ParseSuccess data | ParseDisplayFile(data,_,_) -> data
+	| ParseSuccess data | ParseDisplayFile(data,_) -> data
 	| ParseError(_,(msg,_),_) -> error (Parser.error_msg msg)
 
 (* Vars *)

+ 6 - 1
src/syntax/parser.ml

@@ -70,9 +70,14 @@ type parse_data = string list * (type_def * pos) list
 
 type parse_error = (error_msg * pos)
 
+type parser_display_information = {
+	pd_errors : parse_error list;
+	pd_dead_blocks : pos list;
+}
+
 type 'a parse_result =
 	(* Parsed display file. There can be errors. *)
-	| ParseDisplayFile of 'a * parse_error list * pos list
+	| ParseDisplayFile of 'a * parser_display_information
 	(* Parsed non-display-file without errors. *)
 	| ParseSuccess of 'a
 	(* Parsed non-display file with errors *)

+ 2 - 2
src/syntax/parserEntry.ml

@@ -270,7 +270,7 @@ let parse ctx code file =
 		restore();
 		Lexer.restore old;
 		if was_display_file then
-			ParseDisplayFile(l,List.rev !syntax_errors,dbc#get_dead_blocks)
+			ParseDisplayFile(l,{pd_errors = List.rev !syntax_errors;pd_dead_blocks = dbc#get_dead_blocks})
 		else begin match List.rev !syntax_errors with
 			| [] -> ParseSuccess l
 			| error :: errors -> ParseError(l,error,errors)
@@ -333,4 +333,4 @@ let parse_expr_string com s p error inl =
 	match parse_string com (head ^ s ^ ";}") p error inl with
 	| ParseSuccess data -> ParseSuccess(extract_expr data)
 	| ParseError(data,error,errors) -> ParseError(extract_expr data,error,errors)
-	| ParseDisplayFile(data,errors,dead) -> ParseDisplayFile(extract_expr data,errors,dead)
+	| ParseDisplayFile(data,pdi) -> ParseDisplayFile(extract_expr data,pdi)

+ 1 - 1
src/typing/macroContext.ml

@@ -129,7 +129,7 @@ let make_macro_api ctx p =
 			try
 				begin match ParserEntry.parse_expr_string ctx.com.defines s p error inl with
 					| ParseSuccess data -> data
-					| ParseDisplayFile(data,_,_) when inl -> data (* ignore errors when inline-parsing in display file *)
+					| ParseDisplayFile(data,_) when inl -> data (* ignore errors when inline-parsing in display file *)
 					| ParseDisplayFile _ -> assert false (* cannot happen because ParserEntry.parse_string sets `display_position := null_pos;` *)
 					| ParseError _ -> raise MacroApi.Invalid_expr
 				end

+ 1 - 1
src/typing/typeloadModule.ml

@@ -911,7 +911,7 @@ let handle_import_hx ctx m decls p =
 			if Sys.file_exists path then begin
 				let _,r = match !TypeloadParse.parse_hook ctx.com path p with
 					| ParseSuccess data -> data
-					| ParseDisplayFile(data,_,_) -> data
+					| ParseDisplayFile(data,_) -> data
 					| ParseError(_,(msg,p),_) -> Parser.error msg p
 				in
 				List.iter (fun (d,p) -> match d with EImport _ | EUsing _ -> () | _ -> error "Only import and using is allowed in import.hx files" p) r;

+ 5 - 5
src/typing/typeloadParse.ml

@@ -43,7 +43,7 @@ let parse_file_from_lexbuf com file p lexbuf =
 	in
 	begin match !Parser.display_mode,parse_result with
 		| DMModuleSymbols (Some ""),_ -> ()
-		| DMModuleSymbols filter,(ParseSuccess data | ParseDisplayFile(data,_,_)) when filter = None && DisplayPosition.display_position#is_in_file file ->
+		| DMModuleSymbols filter,(ParseSuccess data | ParseDisplayFile(data,_)) when filter = None && DisplayPosition.display_position#is_in_file file ->
 			let ds = DocumentSymbols.collect_module_symbols (filter = None) data in
 			DisplayException.raise_module_symbols (DocumentSymbols.Printer.print_module_symbols com [file,ds] filter);
 		| _ ->
@@ -122,7 +122,7 @@ let resolve_module_file com m remap p =
 			| [] -> []
 		in
 		let meta =  match parse_result with
-			| ParseSuccess(_,decls) | ParseDisplayFile((_,decls),_,_) -> loop decls
+			| ParseSuccess(_,decls) | ParseDisplayFile((_,decls),_) -> loop decls
 			| ParseError _ -> []
 		in
 		if not (Meta.has Meta.NoPackageRestrict meta) then begin
@@ -154,12 +154,12 @@ let parse_module_file com file p =
 	in
 	let pack,decls = match (!parse_hook) com file p with
 		| ParseSuccess data -> data
-		| ParseDisplayFile(data,errors,dead) ->
-			begin match errors with
+		| ParseDisplayFile(data,pdi) ->
+			begin match pdi.pd_errors with
 			| (msg,p) :: _ -> handle_parser_error msg p
 			| [] -> ()
 			end;
-			if dead <> [] then Hashtbl.replace com.display_information.dead_blocks file dead;
+			if pdi.pd_dead_blocks <> [] then Hashtbl.replace com.display_information.dead_blocks file pdi.pd_dead_blocks;
 			data
 		| ParseError(data,(msg,p),_) ->
 			handle_parser_error msg p;

+ 1 - 1
src/typing/typer.ml

@@ -1577,7 +1577,7 @@ and format_string ctx s p =
 				let ep = { p with pmin = !pmin + pos + 2; pmax = !pmin + send + 1 } in
 				try
 					begin match ParserEntry.parse_expr_string ctx.com.defines scode ep error true with
-						| ParseSuccess data | ParseDisplayFile(data,_,_) -> data
+						| ParseSuccess data | ParseDisplayFile(data,_) -> data
 						| ParseError(_,(msg,p),_) -> error (Parser.error_msg msg) p
 					end
 				with Exit ->