Selaa lähdekoodia

improved completion for lambda functions

Nicolas Cannasse 15 vuotta sitten
vanhempi
commit
28da83b876
2 muutettua tiedostoa jossa 22 lisäystä ja 2 poistoa
  1. 1 0
      doc/CHANGES.txt
  2. 21 2
      parser.ml

+ 1 - 0
doc/CHANGES.txt

@@ -37,6 +37,7 @@
 	php : fixed errror in XML error reporting
 	all : allow sub-types declarations everywhere (pack.Type.Sub)
 	all : added completion for sub-types declarations
+	all : improved completion with lambda function
 
 2009-07-26: 2.04
 	flash9 : fixed get_full_path error with -D fdb

+ 21 - 2
parser.ml

@@ -285,7 +285,8 @@ and parse_type_path1 pack = parser
 				(if is_resuming p then
 					raise (TypePath (List.rev pack,Some name))
 				else match s with parser
-					[< '(Const (Type name),_) >] -> Some name)
+					| [< '(Const (Type name),_) >] -> Some name
+					| [< >] -> serror())
 			| [< >] -> None
 		) in
 		let params = (match s with parser
@@ -582,7 +583,7 @@ and expr_next e1 = parser
 	| [< '(POpen,p1); s >] ->
 		if is_resuming p1 then display (EDisplay e1,p1);
 		(match s with parser
-		| [< params = psep Comma expr; '(PClose,p2); s >] -> expr_next (ECall (e1,params) , punion (pos e1) p2) s
+		| [< params = parse_call_params e1; '(PClose,p2); s >] -> expr_next (ECall (e1,params) , punion (pos e1) p2) s
 		| [< >] -> serror())
 	| [< '(BkOpen,_); e2 = expr; '(BkClose,p2); s >] ->
 		expr_next (EArray (e1,e2), punion (pos e1) p2) s
@@ -637,6 +638,24 @@ and parse_catch etry = parser
 				Display e -> display (ETry (etry,[name,t,e]),p))
 		| [< '(_,p) >] -> error Missing_type p
 
+and parse_call_params ec s =
+	try
+		match s with parser
+		| [< e = expr >] ->
+			let rec loop acc =
+				try 
+					match s with parser
+					| [< '(Comma,_); e = expr >] -> loop (e::acc)
+					| [< >] -> List.rev acc
+				with Display e ->
+					display (ECall (ec,List.rev (e::acc)),pos ec)
+			in
+			loop [e]
+		| [< >] ->
+			[]
+	with Display e ->
+		display (ECall (ec,[e]),pos ec)
+
 and toplevel_expr s =
 	try
 		expr s