Made the preprocessor correct the path a #USEd file when it finds it on the search path while including it
This commit is contained in:
parent
91092c17ff
commit
5bf1ffa785
|
@ -65,11 +65,19 @@ preprocessFile m filename
|
||||||
= do (handle, realFilename) <- searchFile m filename
|
= do (handle, realFilename) <- searchFile m filename
|
||||||
progress $ "Loading source file " ++ realFilename
|
progress $ "Loading source file " ++ realFilename
|
||||||
origCS <- get
|
origCS <- get
|
||||||
modify (\cs -> cs { csCurrentFile = realFilename })
|
let modFunc = if drop4 filename `Set.member` csUsedFiles origCS
|
||||||
|
then Set.insert (drop4 realFilename)
|
||||||
|
. Set.delete (drop4 filename)
|
||||||
|
else id
|
||||||
|
modify (\cs -> cs { csCurrentFile = realFilename
|
||||||
|
, csUsedFiles = modFunc $ csUsedFiles cs })
|
||||||
s <- liftIO $ hGetContents handle
|
s <- liftIO $ hGetContents handle
|
||||||
toks <- preprocessSource m realFilename s
|
toks <- preprocessSource m realFilename s
|
||||||
modify (\cs -> cs { csCurrentFile = csCurrentFile origCS })
|
modify (\cs -> cs { csCurrentFile = csCurrentFile origCS })
|
||||||
return toks
|
return toks
|
||||||
|
where
|
||||||
|
-- drops 4 from the end:
|
||||||
|
drop4 = reverse . drop 4 . reverse
|
||||||
|
|
||||||
-- | Preprocesses source directly and returns its tokenised form ready for parsing.
|
-- | Preprocesses source directly and returns its tokenised form ready for parsing.
|
||||||
preprocessSource :: Meta -> String -> String -> PassM [Token]
|
preprocessSource :: Meta -> String -> String -> PassM [Token]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user