aboutsummaryrefslogtreecommitdiff
path: root/bootstrap
diff options
context:
space:
mode:
authorBrad Richardson <everythingfunctional@protonmail.com>2020-10-14 15:35:00 -0500
committerBrad Richardson <everythingfunctional@protonmail.com>2020-10-14 15:35:00 -0500
commit3457efd4cbb806118f7893f452bc1dd016e53390 (patch)
tree534e52c49f8d1d94a6908789eebf234227aac31a /bootstrap
parent1c69913b1d0ff68deffee4ee57ca3faef95b4a9d (diff)
downloadfpm-3457efd4cbb806118f7893f452bc1dd016e53390.tar.gz
fpm-3457efd4cbb806118f7893f452bc1dd016e53390.zip
Refactor parsing process a bit
Diffstat (limited to 'bootstrap')
-rw-r--r--bootstrap/src/BuildModel.hs27
1 files changed, 14 insertions, 13 deletions
diff --git a/bootstrap/src/BuildModel.hs b/bootstrap/src/BuildModel.hs
index dab8aed..aa720f9 100644
--- a/bootstrap/src/BuildModel.hs
+++ b/bootstrap/src/BuildModel.hs
@@ -41,6 +41,7 @@ data Source = Program {
processRawSource :: RawSource -> Source
processRawSource rawSource =
let sourceFileName = rawSourceFilename rawSource
+ parsedContents = parseContents rawSource
in Program
{ programSourceFileName = sourceFileName
, programObjectFileName = \buildDirectory ->
@@ -49,25 +50,25 @@ processRawSource rawSource =
sourceFileName
)
<.> "o"
- , programModulesUsed = getModulesUsed rawSource
+ , programModulesUsed = getModulesUsed parsedContents
}
pathSeparatorsToUnderscores :: FilePath -> FilePath
pathSeparatorsToUnderscores fileName =
intercalate "_" (splitDirectories fileName)
-getModulesUsed :: RawSource -> [String]
-getModulesUsed rawSource =
- let fileLines = lines $ rawSourceContents rawSource
- lineContents = map parseFortranLine fileLines
- in contentsToModuleNames lineContents
-
-contentsToModuleNames :: [LineContents] -> [String]
-contentsToModuleNames = mapMaybe contentToMaybeModuleName
- where
- contentToMaybeModuleName content = case content of
- ModuleUsed moduleName -> Just moduleName
- _ -> Nothing
+parseContents :: RawSource -> [LineContents]
+parseContents rawSource =
+ let fileLines = lines $ rawSourceContents rawSource in
+ map parseFortranLine fileLines
+
+getModulesUsed :: [LineContents] -> [String]
+getModulesUsed =
+ mapMaybe contentToMaybeModuleName
+ where
+ contentToMaybeModuleName content = case content of
+ ModuleUsed moduleName -> Just moduleName
+ _ -> Nothing
readFileLinesIO :: FilePath -> IO [String]
readFileLinesIO file = do