Skip to content
Snippets Groups Projects
Commit f7d654cf authored by byorgey's avatar byorgey
Browse files

implement a poor man's LANGUAGE pragma parser

parent 225b4df4
No related branches found
No related tags found
No related merge requests found
...@@ -124,9 +124,25 @@ findImportsAndExts projectRoot sf = do ...@@ -124,9 +124,25 @@ findImportsAndExts projectRoot sf = do
-- Haskell parser since cabal's dependencies must be kept at a -- Haskell parser since cabal's dependencies must be kept at a
-- minimum. -- minimum.
exts = undefined --- XXX todo: parse LANGUAGE pragmas. -- A poor man's LANGUAGE pragma parser.
. lines exts = mapMaybe simpleParse
$ s . concatMap getPragmas
. filter isLANGUAGEPragma
. map fst
. drop 1
. takeWhile (not . null . snd)
. iterate (takeBraces . snd)
$ ("",s)
takeBraces = break (== '}') . dropWhile (/= '{')
isLANGUAGEPragma = ("{-# LANGUAGE " `isPrefixOf`)
getPragmas = map trim . splitCommas . takeWhile (/= '#') . drop 13
splitCommas "" = []
splitCommas xs = x : splitCommas (drop 1 y)
where (x,y) = break (==',') xs
return sf { imports = modules return sf { imports = modules
, extensions = exts , extensions = exts
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment