Skip to content

Commit 44a7002

Browse files
RaoulHCraehik
authored andcommitted
Add entry point for parsing includes
1 parent c1708c1 commit 44a7002

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Language/Fortran/Parser.hs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ module Language.Fortran.Parser
3636
-- * F77 with inlined includes
3737
-- $f77includes
3838
, f77lIncludes
39+
, f77lIncIncludes
3940
) where
4041

4142
import Language.Fortran.AST
@@ -253,6 +254,18 @@ f77lIncludes incs mods fn bs = do
253254
pf''
254255
return pf'''
255256

257+
-- | Entry point for include files
258+
--
259+
-- We can't perform full analysis (though it might be possible to do in future)
260+
-- but the AST is enough for certain types of analysis/refactoring
261+
f77lIncIncludes
262+
:: [FilePath] -> String -> B.ByteString -> IO [Block A0]
263+
f77lIncIncludes incs fn bs =
264+
case makeParserFixed F77.includesParser Fortran77Legacy fn bs of
265+
Left e -> liftIO $ throwIO e
266+
Right bls ->
267+
evalStateT (descendBiM (f77lIncludesInline incs []) bls) Map.empty
268+
256269
f77lIncludesInner :: Parser [Block A0]
257270
f77lIncludesInner = makeParserFixed F77.includesParser Fortran77Legacy
258271

0 commit comments

Comments
 (0)