Forráskód Böngészése

deal with left-factor parser case

Simon Krajewski 9 hónapja
szülő
commit
1f8fcddff5
1 módosított fájl, 24 hozzáadás és 21 törlés
  1. 24 21
      src/syntax/grammar.mly

+ 24 - 21
src/syntax/grammar.mly

@@ -1714,28 +1714,31 @@ and parse_call_params f p1 s =
 			| [< '(PClose,p2) >] ->
 				let e = check_signature_mark e p1 p2 in
 				f (List.rev (e :: acc)) p2
-			| [< '(Comma,p2); '(PClose,p3) >] ->
-				if (is_signature_display()) then begin
-					let prev_arg_pos = punion p1 p2 in
-					let comma_paren_pos = punion p2 p3 in
-					(* first check wether the display position is within the previous argument *)
-					if encloses_position_gt display_position#get prev_arg_pos then begin
-						(* wrap the argument that was just parsed *)
-						let e = mk_display_expr e DKMarked in
-						f (List.rev (e :: acc)) p3
-					(* then check wether the display position is between the comma and the closing parenthesis *)
-					end else if encloses_position_gt display_position#get comma_paren_pos then begin
-						(* add a dummy final argument *)
-						let e2 = mk_display_expr (mk_null_expr comma_paren_pos) DKMarked in
-						f (List.rev (e2 :: e :: acc)) p3
-					end else f (List.rev (e :: acc)) p3
-				end else begin
-				(* if not in signature display mode don't check anything *)
-					f (List.rev (e :: acc)) p3
-				end
 			| [< '(Comma,p2) >] ->
-				let e = check_signature_mark e p1 p2 in
-				parse_next_param (e :: acc) p2
+				begin match s with parser
+					| [< '(PClose, p3) >] ->
+						if (is_signature_display()) then begin
+							let prev_arg_pos = punion p1 p2 in
+							let comma_paren_pos = punion p2 p3 in
+							(* first check wether the display position is within the previous argument *)
+							if encloses_position_gt display_position#get prev_arg_pos then begin
+								(* wrap the argument that was just parsed *)
+								let e = mk_display_expr e DKMarked in
+								f (List.rev (e :: acc)) p3
+							(* then check wether the display position is between the comma and the closing parenthesis *)
+							end else if encloses_position_gt display_position#get comma_paren_pos then begin
+								(* add a dummy final argument *)
+								let e2 = mk_display_expr (mk_null_expr comma_paren_pos) DKMarked in
+								f (List.rev (e2 :: e :: acc)) p3
+							end else f (List.rev (e :: acc)) p3
+						end else begin
+						(* if not in signature display mode don't check anything *)
+							f (List.rev (e :: acc)) p3
+						end
+					| [< >] ->
+						let e = check_signature_mark e p1 p2 in
+						parse_next_param (e :: acc) p2
+				end
 			| [< >] ->
 				let p2 = next_pos s in
 				syntax_error (Expected [",";")"]) s ();