lib: factor out parsing child journal into separate function
This commit is contained in:
parent
52da073828
commit
96f7a03487
@ -196,9 +196,16 @@ includedirectivep = do
|
||||
curdir <- lift $ expandPath (takeDirectory $ sourceName parentpos) ""
|
||||
`orRethrowIOError` (show parentpos ++ " locating " ++ filename)
|
||||
-- </> correctly handles case when 'filename' is absolute
|
||||
let filepath = curdir </> filename
|
||||
-- read child input
|
||||
childInput <- lift $ readFilePortably filepath `orRethrowIOError` (show parentpos ++ " reading " ++ filepath)
|
||||
let filepaths = [curdir </> filename]
|
||||
-- read child inputs
|
||||
forM_ filepaths $ parseChild parentpos
|
||||
|
||||
void newline
|
||||
|
||||
where
|
||||
parseChild parentpos filepath = do
|
||||
childInput <- lift $ readFilePortably filepath
|
||||
`orRethrowIOError` (show parentpos ++ " reading " ++ filepath)
|
||||
|
||||
-- save parent state
|
||||
parentParserState <- getParserState
|
||||
@ -224,8 +231,6 @@ includedirectivep = do
|
||||
put $ updatedChildj <> parentj
|
||||
-- discard child's parse info, prepend its (reversed) list data, combine other fields
|
||||
|
||||
void newline
|
||||
|
||||
|
||||
newJournalWithParseStateFrom :: Journal -> Journal
|
||||
newJournalWithParseStateFrom j = mempty{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user