2
0
Эх сурвалжийг харах

improved unclosed macro error reporting

Nicolas Cannasse 17 жил өмнө
parent
commit
91906c6c3e
2 өөрчлөгдсөн 13 нэмэгдсэн , 12 устгасан
  1. 1 0
      doc/CHANGES.txt
  2. 12 12
      parser.ml

+ 1 - 0
doc/CHANGES.txt

@@ -54,6 +54,7 @@ TODO inlining : substitute class+function type parameters in order to have fully
 	haxe.Stack support for flash9
 	haxe.Stack support for flash9
 	fixed current package bug in inherited constructor type
 	fixed current package bug in inherited constructor type
 	delayed type-parameter constraints check (allow mutual rec extends for SPOD)
 	delayed type-parameter constraints check (allow mutual rec extends for SPOD)
+	improved unclosed macro error reporting
 
 
 2008-04-05: 1.19
 2008-04-05: 1.19
 	fixed flash9 Array.toString
 	fixed flash9 Array.toString

+ 12 - 12
parser.ml

@@ -668,9 +668,9 @@ let parse ctx code file =
 			| [] -> raise Exit
 			| [] -> raise Exit
 			| _ :: l ->
 			| _ :: l ->
 				mstack := l;
 				mstack := l;
-				process_token (skip_tokens false))
+				process_token (skip_tokens (snd tk) false))
 		| Macro "if" ->
 		| Macro "if" ->
-			process_token (enter_macro())
+			process_token (enter_macro (snd tk))
 		| Macro "error" ->
 		| Macro "error" ->
 			error Unimplemented (snd tk)
 			error Unimplemented (snd tk)
 		| Macro "line" ->
 		| Macro "line" ->
@@ -683,13 +683,13 @@ let parse ctx code file =
 		| _ ->
 		| _ ->
 			tk
 			tk
 
 
-	and enter_macro() =
+	and enter_macro p =
 		let ok , tk = eval_macro false in
 		let ok , tk = eval_macro false in
 		if ok then begin
 		if ok then begin
-			mstack := snd tk :: !mstack;
+			mstack := p :: !mstack;
 			tk
 			tk
 		end else
 		end else
-			skip_tokens_loop true tk
+			skip_tokens_loop p true tk
 
 
 	and eval_macro allow_expr =
 	and eval_macro allow_expr =
 		match Lexer.token code with
 		match Lexer.token code with
@@ -715,25 +715,25 @@ let parse ctx code file =
 		| _ ->
 		| _ ->
 			raise Exit
 			raise Exit
 
 
-	and skip_tokens_loop test tk =
+	and skip_tokens_loop p test tk =
 		match fst tk with
 		match fst tk with
 		| Macro "end" ->
 		| Macro "end" ->
 			Lexer.token code
 			Lexer.token code
 		| Macro "elseif" | Macro "else" when not test ->
 		| Macro "elseif" | Macro "else" when not test ->
-			skip_tokens test
+			skip_tokens p test
 		| Macro "else" ->
 		| Macro "else" ->
 			mstack := snd tk :: !mstack;
 			mstack := snd tk :: !mstack;
 			Lexer.token code
 			Lexer.token code
 		| Macro "elseif" ->
 		| Macro "elseif" ->
-			enter_macro()
+			enter_macro (snd tk)
 		| Macro "if" ->
 		| Macro "if" ->
-			skip_tokens_loop test (skip_tokens false)
+			skip_tokens_loop p test (skip_tokens p false)
 		| Eof ->
 		| Eof ->
-			raise Exit
+			error Unclosed_macro p
 		| _ ->
 		| _ ->
-			skip_tokens test
+			skip_tokens p test
 
 
-	and skip_tokens test = skip_tokens_loop test (Lexer.token code)
+	and skip_tokens p test = skip_tokens_loop p test (Lexer.token code)
 
 
 	in
 	in
 	let s = Stream.from (fun _ ->
 	let s = Stream.from (fun _ ->