2
0
Simon Krajewski 1 жил өмнө
parent
commit
5432abb47e

+ 1 - 1
src/syntax/grammar.mly

@@ -121,7 +121,7 @@ let check_redundant_var p1 = parser
 
 
 let parsing_macro_cond = ref false
 let parsing_macro_cond = ref false
 
 
-let rec	parse_file s =
+let rec parse_file s =
 	last_doc := None;
 	last_doc := None;
 	match s with parser
 	match s with parser
 	| [< '(Kwd Package,_); pack = parse_package; s >] ->
 	| [< '(Kwd Package,_); pack = parse_package; s >] ->

+ 8 - 0
src/syntax/parserEntry.ml

@@ -355,6 +355,14 @@ let parse entry ctx code file =
 	) in
 	) in
 	try
 	try
 		let l = entry s in
 		let l = entry s in
+		begin match Stream.peek s with
+			| None ->
+				() (* Eof could already have been consumed *)
+			| Some (Eof,_) ->
+				() (* This is what we want *)
+			| Some (tok,p) ->
+				error (Unexpected tok) p (* This isn't *)
+		end;
 		let was_display_file = !in_display_file in
 		let was_display_file = !in_display_file in
 		restore();
 		restore();
 		Lexer.restore old;
 		Lexer.restore old;