Remove empty space

This commit is contained in:
Joey Yakimowich-Payne 2018-05-27 17:58:31 +09:00
commit c613cc3449
3 changed files with 16 additions and 15 deletions

View file

@ -697,14 +697,14 @@ let rec find_some_opt p = function
| Some v -> Some v | Some v -> Some v
| None -> find_some_opt p l | None -> find_some_opt p l
let find_some p xs = let find_some p xs =
match find_some_opt p xs with match find_some_opt p xs with
| None -> raise Not_found | None -> raise Not_found
| Some x -> x | Some x -> x
let rec find_opt f xs = let rec find_opt f xs =
find_some_opt (fun x -> if f x then Some x else None) xs find_some_opt (fun x -> if f x then Some x else None) xs
(*****************************************************************************) (*****************************************************************************)
(* Regexp, can also use PCRE *) (* Regexp, can also use PCRE *)
@ -866,7 +866,7 @@ let realpath2 path =
let realpath2 path = let realpath2 path =
let stat = Unix.stat path in let stat = Unix.stat path in
let dir, suffix = let dir, suffix =
match stat.Unix.st_kind with match stat.Unix.st_kind with
| Unix.S_DIR -> path, "" | Unix.S_DIR -> path, ""
| _ -> Filename.dirname path, Filename.basename path | _ -> Filename.dirname path, Filename.basename path
@ -1058,7 +1058,7 @@ let group_by f xs =
(* could use Set *) (* could use Set *)
let hkeys = Hashtbl.create 101 in let hkeys = Hashtbl.create 101 in
xs |> List.iter (fun x -> xs |> List.iter (fun x ->
let k = f x in let k = f x in
Hashtbl.replace hkeys k true; Hashtbl.replace hkeys k true;
@ -1072,7 +1072,7 @@ let group_by_multi fkeys xs =
(* could use Set *) (* could use Set *)
let hkeys = Hashtbl.create 101 in let hkeys = Hashtbl.create 101 in
xs |> List.iter (fun x -> xs |> List.iter (fun x ->
let ks = fkeys x in let ks = fkeys x in
ks |> List.iter (fun k -> ks |> List.iter (fun k ->
@ -1277,7 +1277,7 @@ let main_boilerplate f =
)) ))
(fun()-> (fun()->
if !profile <> ProfNone if !profile <> ProfNone
then begin then begin
pr2 (profile_diagnostic ()); pr2 (profile_diagnostic ());
Gc.print_stat stderr; Gc.print_stat stderr;
end; end;

View file

@ -70,7 +70,8 @@ let rec process_token tok =
| OriginTok loc -> loc.str | OriginTok loc -> loc.str
| FakeTokStr (v1, opt) -> "" | FakeTokStr (v1, opt) -> ""
| Ab -> "" | Ab -> ""
| ExpandedTok (tok1, tok2, integer) -> tok1.str | ExpandedTok (tok1, tok2, integer) ->
tok1.str
and process_include_kind = function and process_include_kind = function
| Local -> "" | Local -> ""

View file

@ -7,7 +7,7 @@ module Flag = Flag_parsing_cpp
(*****************************************************************************) (*****************************************************************************)
(* Helpers *) (* Helpers *)
(*****************************************************************************) (*****************************************************************************)
let parse file = let parse file =
Common.save_excursion Flag.error_recovery false (fun () -> Common.save_excursion Flag.error_recovery false (fun () ->
Common.save_excursion Flag.show_parsing_error false (fun () -> Common.save_excursion Flag.show_parsing_error false (fun () ->
Common.save_excursion Flag.verbose_parsing false (fun () -> Common.save_excursion Flag.verbose_parsing false (fun () ->
@ -23,7 +23,7 @@ let unittest =
(*-----------------------------------------------------------------------*) (*-----------------------------------------------------------------------*)
(* Lexing *) (* Lexing *)
(*-----------------------------------------------------------------------*) (*-----------------------------------------------------------------------*)
(* todo: (* todo:
* - make sure parse int correctly, and float, and that actually does * - make sure parse int correctly, and float, and that actually does
* not return multiple tokens for 42.42 * not return multiple tokens for 42.42
* - ... * - ...
@ -34,7 +34,7 @@ let unittest =
(*-----------------------------------------------------------------------*) (*-----------------------------------------------------------------------*)
"regression files" >:: (fun () -> "regression files" >:: (fun () ->
let dir = Filename.concat Config_pfff.path "/tests/cpp/parsing" in let dir = Filename.concat Config_pfff.path "/tests/cpp/parsing" in
let files = let files =
Common2.glob (spf "%s/*.cpp" dir) @ Common2.glob (spf "%s/*.h" dir) in Common2.glob (spf "%s/*.cpp" dir) @ Common2.glob (spf "%s/*.h" dir) in
files +> List.iter (fun file -> files +> List.iter (fun file ->
try try
@ -44,12 +44,12 @@ let unittest =
assert_failure (spf "it should correctly parse %s" file) assert_failure (spf "it should correctly parse %s" file)
) )
); );
"rejecting bad code" >:: (fun () -> "rejecting bad code" >:: (fun () ->
let dir = Filename.concat Config_pfff.path "/tests/cpp/parsing_errors" in let dir = Filename.concat Config_pfff.path "/tests/cpp/parsing_errors" in
let files = Common2.glob (spf "%s/*.cpp" dir) in let files = Common2.glob (spf "%s/*.cpp" dir) in
files +> List.iter (fun file -> files +> List.iter (fun file ->
try try
let _ast = parse file in let _ast = parse file in
assert_failure (spf "it should have thrown a Parse_error %s" file) assert_failure (spf "it should have thrown a Parse_error %s" file)
with with
@ -58,11 +58,11 @@ let unittest =
(Common.exn_to_s exn) file) (Common.exn_to_s exn) file)
) )
); );
(* parsing C files (and not C++ files) possibly containing C++ keywords *) (* parsing C files (and not C++ files) possibly containing C++ keywords *)
"C regression files" >:: (fun () -> "C regression files" >:: (fun () ->
let dir = Filename.concat Config_pfff.path "/tests/c/parsing" in let dir = Filename.concat Config_pfff.path "/tests/c/parsing" in
let files = let files =
Common2.glob (spf "%s/*.c" dir) Common2.glob (spf "%s/*.c" dir)
(* @ Common2.glob (spf "%s/*.h" dir) *) in (* @ Common2.glob (spf "%s/*.h" dir) *) in
files +> List.iter (fun file -> files +> List.iter (fun file ->