diff --git a/commons/common.ml b/commons/common.ml index b5a7fc4..ed0872a 100644 --- a/commons/common.ml +++ b/commons/common.ml @@ -697,14 +697,14 @@ let rec find_some_opt p = function | Some v -> Some v | None -> find_some_opt p l -let find_some p xs = +let find_some p xs = match find_some_opt p xs with | None -> raise Not_found | 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 - + (*****************************************************************************) (* Regexp, can also use PCRE *) @@ -866,7 +866,7 @@ let realpath2 path = let realpath2 path = let stat = Unix.stat path in - let dir, suffix = + let dir, suffix = match stat.Unix.st_kind with | Unix.S_DIR -> path, "" | _ -> Filename.dirname path, Filename.basename path @@ -1058,7 +1058,7 @@ let group_by f xs = (* could use Set *) let hkeys = Hashtbl.create 101 in - + xs |> List.iter (fun x -> let k = f x in Hashtbl.replace hkeys k true; @@ -1072,7 +1072,7 @@ let group_by_multi fkeys xs = (* could use Set *) let hkeys = Hashtbl.create 101 in - + xs |> List.iter (fun x -> let ks = fkeys x in ks |> List.iter (fun k -> @@ -1277,7 +1277,7 @@ let main_boilerplate f = )) (fun()-> if !profile <> ProfNone - then begin + then begin pr2 (profile_diagnostic ()); Gc.print_stat stderr; end; diff --git a/generators/nim/generate_nim.ml b/generators/nim/generate_nim.ml index bc75e58..25fce0a 100644 --- a/generators/nim/generate_nim.ml +++ b/generators/nim/generate_nim.ml @@ -70,7 +70,8 @@ let rec process_token tok = | OriginTok loc -> loc.str | FakeTokStr (v1, opt) -> "" | Ab -> "" - | ExpandedTok (tok1, tok2, integer) -> tok1.str + | ExpandedTok (tok1, tok2, integer) -> + tok1.str and process_include_kind = function | Local -> "" diff --git a/lang_cpp/parsing/unit_parsing_cpp.ml b/lang_cpp/parsing/unit_parsing_cpp.ml index 6e3aa5d..c9aa403 100644 --- a/lang_cpp/parsing/unit_parsing_cpp.ml +++ b/lang_cpp/parsing/unit_parsing_cpp.ml @@ -7,7 +7,7 @@ module Flag = Flag_parsing_cpp (*****************************************************************************) (* Helpers *) (*****************************************************************************) -let parse file = +let parse file = Common.save_excursion Flag.error_recovery false (fun () -> Common.save_excursion Flag.show_parsing_error false (fun () -> Common.save_excursion Flag.verbose_parsing false (fun () -> @@ -23,7 +23,7 @@ let unittest = (*-----------------------------------------------------------------------*) (* Lexing *) (*-----------------------------------------------------------------------*) - (* todo: + (* todo: * - make sure parse int correctly, and float, and that actually does * not return multiple tokens for 42.42 * - ... @@ -34,7 +34,7 @@ let unittest = (*-----------------------------------------------------------------------*) "regression files" >:: (fun () -> 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 files +> List.iter (fun file -> try @@ -44,12 +44,12 @@ let unittest = assert_failure (spf "it should correctly parse %s" file) ) ); - + "rejecting bad code" >:: (fun () -> let dir = Filename.concat Config_pfff.path "/tests/cpp/parsing_errors" in let files = Common2.glob (spf "%s/*.cpp" dir) in files +> List.iter (fun file -> - try + try let _ast = parse file in assert_failure (spf "it should have thrown a Parse_error %s" file) with @@ -58,11 +58,11 @@ let unittest = (Common.exn_to_s exn) file) ) ); - + (* parsing C files (and not C++ files) possibly containing C++ keywords *) "C regression files" >:: (fun () -> 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/*.h" dir) *) in files +> List.iter (fun file ->