lib: factor out parsing child journal into separate function

This commit is contained in:
Joseph Weston 2018-07-23 11:30:10 +02:00 committed by Simon Michael
parent 52da073828
commit 96f7a03487

View File

@ -196,9 +196,16 @@ includedirectivep = do
curdir <- lift $ expandPath (takeDirectory $ sourceName parentpos) "" curdir <- lift $ expandPath (takeDirectory $ sourceName parentpos) ""
`orRethrowIOError` (show parentpos ++ " locating " ++ filename) `orRethrowIOError` (show parentpos ++ " locating " ++ filename)
-- </> correctly handles case when 'filename' is absolute -- </> correctly handles case when 'filename' is absolute
let filepath = curdir </> filename let filepaths = [curdir </> filename]
-- read child input -- read child inputs
childInput <- lift $ readFilePortably filepath `orRethrowIOError` (show parentpos ++ " reading " ++ filepath) forM_ filepaths $ parseChild parentpos
void newline
where
parseChild parentpos filepath = do
childInput <- lift $ readFilePortably filepath
`orRethrowIOError` (show parentpos ++ " reading " ++ filepath)
-- save parent state -- save parent state
parentParserState <- getParserState parentParserState <- getParserState
@ -224,8 +231,6 @@ includedirectivep = do
put $ updatedChildj <> parentj put $ updatedChildj <> parentj
-- discard child's parse info, prepend its (reversed) list data, combine other fields -- discard child's parse info, prepend its (reversed) list data, combine other fields
void newline
newJournalWithParseStateFrom :: Journal -> Journal newJournalWithParseStateFrom :: Journal -> Journal
newJournalWithParseStateFrom j = mempty{ newJournalWithParseStateFrom j = mempty{