File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Language/Haskell/Exts/Annotated Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change
1
+ module Language.Haskell.Exts.Annotated.CPP
2
+ ( parseFileWithComments
3
+ , parseFileContentsWithComments
4
+ ) where
5
+
6
+ import Language.Preprocessor.Cpphs
7
+ import Language.Preprocessor.Unlit
8
+ import Language.Haskell.Exts (ParseMode (.. ))
9
+ import Language.Haskell.Exts.Annotated
10
+ hiding (parseFileWithComments , parseFileContentsWithComments )
11
+ import Control.Applicative
12
+ import Data.List
13
+
14
+ parseFileWithComments :: CpphsOptions -> ParseMode -> FilePath -> IO (ParseResult (Module SrcSpanInfo , [Comment ]))
15
+ parseFileWithComments cppopts p fp = readFile fp >>= parseFileContentsWithComments cppopts p
16
+
17
+ parseFileContentsWithComments :: CpphsOptions -> ParseMode -> String -> IO (ParseResult (Module SrcSpanInfo , [Comment ]))
18
+ parseFileContentsWithComments cppopts p@ (ParseMode fn exts ign _ _) rawStr =
19
+ let md = delit fn rawStr
20
+ allExts = impliesExts $ case (ign, readExtensions md) of
21
+ (False ,Just es) -> exts ++ es
22
+ _ -> exts
23
+ in parseModuleWithComments (p { extensions = allExts }) <$> runCpphs cppopts fn md
24
+
25
+ cpp cppopts str = runCpphs cppopts str
26
+
27
+ delit :: String -> String -> String
28
+ delit fn = if " .lhs" `isSuffixOf` fn then unlit fn else id
You can’t perform that action at this time.
0 commit comments