diff --git a/src/Language/Fortran/Parser.hs b/src/Language/Fortran/Parser.hs index bb832576..b5f599d3 100644 --- a/src/Language/Fortran/Parser.hs +++ b/src/Language/Fortran/Parser.hs @@ -36,6 +36,7 @@ module Language.Fortran.Parser -- * F77 with inlined includes -- $f77includes , f77lIncludes + , f77lIncIncludes ) where import Language.Fortran.AST @@ -253,6 +254,18 @@ f77lIncludes incs mods fn bs = do pf'' return pf''' +-- | Entry point for include files +-- +-- We can't perform full analysis (though it might be possible to do in future) +-- but the AST is enough for certain types of analysis/refactoring +f77lIncIncludes + :: [FilePath] -> String -> B.ByteString -> IO [Block A0] +f77lIncIncludes incs fn bs = + case makeParserFixed F77.includesParser Fortran77Legacy fn bs of + Left e -> liftIO $ throwIO e + Right bls -> + evalStateT (descendBiM (f77lIncludesInline incs []) bls) Map.empty + f77lIncludesInner :: Parser [Block A0] f77lIncludesInner = makeParserFixed F77.includesParser Fortran77Legacy