From 3a2ca1da337800266309e9c1faaac08d6149c630 Mon Sep 17 00:00:00 2001 From: Dominic Orchard Date: Thu, 15 Aug 2024 18:22:27 +0100 Subject: [PATCH] better error handling when there are parsing issues when building make file graph --- src/Language/Fortran/Analysis/ModGraph.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Language/Fortran/Analysis/ModGraph.hs b/src/Language/Fortran/Analysis/ModGraph.hs index f2381dae..e9ad1699 100644 --- a/src/Language/Fortran/Analysis/ModGraph.hs +++ b/src/Language/Fortran/Analysis/ModGraph.hs @@ -85,12 +85,16 @@ genModGraph mversion includeDirs cppOpts paths = do let version = fromMaybe (deduceFortranVersion path) mversion mods = map snd fileMods parserF0 = Parser.byVerWithMods mods version - parserF fn bs = fromRight' $ parserF0 fn bs + parserF fn bs = + case parserF0 fn bs of + Right x -> return x + Left err -> do + error $ show err forM_ fileMods $ \ (fileName, mod) -> do forM_ [ name | Named name <- M.keys (combinedModuleMap [mod]) ] $ \ name -> do _ <- maybeAddModName name . Just $ MOFSMod fileName pure () - let pf = parserF path contents + pf <- parserF path contents mapM_ (perModule path) (childrenBi pf :: [ProgramUnit ()]) pure () execStateT (mapM_ iter paths) modGraph0