Skip to content

Commit

Permalink
Add entry point for parsing includes
Browse files Browse the repository at this point in the history
  • Loading branch information
Raoul Hidalgo Charman authored and raehik committed Jun 15, 2022
1 parent c1708c1 commit 44a7002
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Language/Fortran/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module Language.Fortran.Parser
-- * F77 with inlined includes
-- $f77includes
, f77lIncludes
, f77lIncIncludes
) where

import Language.Fortran.AST
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 44a7002

Please sign in to comment.