on master help sign in
Implement experimental support for CPP
commit53f582a5751e166bfb76af977e77e96e844cba24 authorMark Karpov <markkarpov92@gmail.com> dateTue 21 Apr 2020, 14:36 (7 years ago) parentdde7560
34 files changed+340−43
CHANGELOG.md+3 README.md+4−1 app/Main.hs−5 data/examples/declaration/annotation/annotation-out.hs+1 data/examples/module-header/stack-header-0-out.hs+1 data/examples/module-header/stack-header-1-out.hs+1 data/examples/other/cpp/lonely-hash-out.hs+14 data/examples/other/cpp/lonely-hash.hs+14 data/examples/other/cpp/separation-0a-out.hs+7 data/examples/other/cpp/separation-0a.hs+6 data/examples/other/cpp/separation-0b-out.hs+10 data/examples/other/cpp/separation-0b.hs+9 data/examples/other/cpp/separation-1a-out.hs+12 data/examples/other/cpp/separation-1a.hs+11 data/examples/other/cpp/separation-1b-out.hs+15 data/examples/other/cpp/separation-1b.hs+14 data/examples/other/cpp/separation-2a-out.hs+9 data/examples/other/cpp/separation-2a.hs+8 data/examples/other/cpp/separation-2b-out.hs+12 data/examples/other/cpp/separation-2b.hs+11 data/examples/other/cpp/shifted-out.hs+21 data/examples/other/cpp/shifted.hs+17 data/examples/other/cpp/simple-import-out.hs+14 data/examples/other/cpp/simple-import.hs+14 format.sh+3−3 nix/ormolize/default.nix+1−1 ormolu.cabal+1 src/Ormolu/Config.hs−5 src/Ormolu/Exception.hs+3−10 src/Ormolu/Parser.hs−3 src/Ormolu/Printer/Comments.hs+5−1 src/Ormolu/Processing/Cpp.hs+70 src/Ormolu/Processing/Postprocess.hs+6−1 src/Ormolu/Processing/Preprocess.hs+23−13
CHANGELOG.md+3
@@ -12,6 +12,9 @@
1212* Ormolu can now be enabled and disabled via special comments. [Issue
1313 435](https://github.com/tweag/ormolu/issues/435).
1414
15+* Added experimental support for simple CPP. [Issue
16+ 415](https://github.com/tweag/ormolu/issues/415).
17+
1518## Ormolu 0.0.4.0
1619
1720* When given several files to format, Ormolu does not stop on the first
README.md+4−1
@@ -114,7 +114,10 @@ independent top-level definitions.
114114
115115## Current limitations
116116
117−* Does not handle CPP (wontfix, see [the design document][design]).
117+* CPP support is experimental. CPP is virtually impossible to handle
118+ correctly, so we process them as a sort of unchangeable snippets. This
119+ works only in simple cases when CPP conditionals are self-contained. Use
120+ Ormolu with CPP at your own risk.
118121* Input modules should be parsable by Haddock, which is a bit stricter
119122 criterion than just being valid Haskell modules.
120123* Various minor idempotence issues, most of them are related to comments.
app/Main.hs−5
@@ -169,11 +169,6 @@ configParser =
169169 short 'd',
170170 help "Output information useful for debugging"
171171 ]
172− <*> (switch . mconcat)
173− [ long "tolerate-cpp",
174− short 'p',
175− help "Do not fail if CPP pragma is present"
176− ]
177172 <*> (switch . mconcat)
178173 [ long "check-idempotency",
179174 short 'c',
data/examples/declaration/annotation/annotation-out.hs+1
@@ -18,4 +18,5 @@ foo = 5
1818
1919data Foo = Foo Int
2020{-# ANN type Foo ("HLint: ignore") #-}
21+
2122{- Comment -}
data/examples/module-header/stack-header-0-out.hs+1
@@ -3,4 +3,5 @@
33{-# LANGUAGE OverloadedStrings #-}
44
55main = return ()
6+
67-- stack runhaskell
data/examples/module-header/stack-header-1-out.hs+1
@@ -4,4 +4,5 @@
44{-# LANGUAGE OverloadedStrings #-}
55
66main = return ()
7+
78-- stack runhaskell
data/examples/other/cpp/lonely-hash-out.hsnew file+14
@@ -0,0 +1,14 @@
1+module Main (main) where
2+
3+import Data.Void
4+import Test.Hspec
5+import Test.Hspec.Megaparsec
6+import Text.Megaparsec
7+import Text.Megaparsec.Char
8+
9+# if !MIN_VERSION_base(4,13,0)
10+import Data.Semigroup ((<>))
11+# endif
12+
13+main :: IO ()
14+main = return ()
data/examples/other/cpp/lonely-hash.hsnew file+14
@@ -0,0 +1,14 @@
1+module Main (main) where
2+
3+import Data.Void
4+import Test.Hspec
5+import Test.Hspec.Megaparsec
6+import Text.Megaparsec
7+import Text.Megaparsec.Char
8+
9+# if !MIN_VERSION_base(4,13,0)
10+import Data.Semigroup ((<>))
11+# endif
12+
13+main :: IO ()
14+main = return ()
data/examples/other/cpp/separation-0a-out.hsnew file+7
@@ -0,0 +1,7 @@
1+instance Stream s => Monad (ParsecT e s m) where
2+ return = pure
3+ (>>=) = pBind
4+
5+#if !(MIN_VERSION_base(4,13,0))
6+ fail = Fail.fail
7+#endif
data/examples/other/cpp/separation-0a.hsnew file+6
@@ -0,0 +1,6 @@
1+instance Stream s => Monad (ParsecT e s m) where
2+ return = pure
3+ (>>=) = pBind
4+#if !(MIN_VERSION_base(4,13,0))
5+ fail = Fail.fail
6+#endif
data/examples/other/cpp/separation-0b-out.hsnew file+10
@@ -0,0 +1,10 @@
1+instance Stream s => Monad (ParsecT e s m) where
2+ return = pure
3+ (>>=) = pBind
4+
5+#if !(MIN_VERSION_base(4,13,0))
6+ fail = Fail.fail
7+#endif
8+
9+foo :: Int
10+foo = undefined
data/examples/other/cpp/separation-0b.hsnew file+9
@@ -0,0 +1,9 @@
1+instance Stream s => Monad (ParsecT e s m) where
2+ return = pure
3+ (>>=) = pBind
4+#if !(MIN_VERSION_base(4,13,0))
5+ fail = Fail.fail
6+#endif
7+
8+foo :: Int
9+foo = undefined
data/examples/other/cpp/separation-1a-out.hsnew file+12
@@ -0,0 +1,12 @@
1+decompressingPipe ::
2+ (PrimMonad m, MonadThrow m, MonadResource m) =>
3+ CompressionMethod ->
4+ ConduitT ByteString ByteString m ()
5+decompressingPipe Store = C.awaitForever C.yield
6+decompressingPipe Deflate = Z.decompress $ Z.WindowBits (-15)
7+
8+#ifdef ENABLE_BZIP2
9+decompressingPipe BZip2 = BZ.bunzip2
10+#else
11+decompressingPipe BZip2 = throwM BZip2Unsupported
12+#endif
data/examples/other/cpp/separation-1a.hsnew file+11
@@ -0,0 +1,11 @@
1+decompressingPipe
2+ :: (PrimMonad m, MonadThrow m, MonadResource m)
3+ => CompressionMethod
4+ -> ConduitT ByteString ByteString m ()
5+decompressingPipe Store = C.awaitForever C.yield
6+decompressingPipe Deflate = Z.decompress $ Z.WindowBits (-15)
7+#ifdef ENABLE_BZIP2
8+decompressingPipe BZip2 = BZ.bunzip2
9+#else
10+decompressingPipe BZip2 = throwM BZip2Unsupported
11+#endif
data/examples/other/cpp/separation-1b-out.hsnew file+15
@@ -0,0 +1,15 @@
1+decompressingPipe ::
2+ (PrimMonad m, MonadThrow m, MonadResource m) =>
3+ CompressionMethod ->
4+ ConduitT ByteString ByteString m ()
5+decompressingPipe Store = C.awaitForever C.yield
6+decompressingPipe Deflate = Z.decompress $ Z.WindowBits (-15)
7+
8+#ifdef ENABLE_BZIP2
9+decompressingPipe BZip2 = BZ.bunzip2
10+#else
11+decompressingPipe BZip2 = throwM BZip2Unsupported
12+#endif
13+
14+foo :: Int
15+foo = undefined
data/examples/other/cpp/separation-1b.hsnew file+14
@@ -0,0 +1,14 @@
1+decompressingPipe
2+ :: (PrimMonad m, MonadThrow m, MonadResource m)
3+ => CompressionMethod
4+ -> ConduitT ByteString ByteString m ()
5+decompressingPipe Store = C.awaitForever C.yield
6+decompressingPipe Deflate = Z.decompress $ Z.WindowBits (-15)
7+#ifdef ENABLE_BZIP2
8+decompressingPipe BZip2 = BZ.bunzip2
9+#else
10+decompressingPipe BZip2 = throwM BZip2Unsupported
11+#endif
12+
13+foo :: Int
14+foo = undefined
data/examples/other/cpp/separation-2a-out.hsnew file+9
@@ -0,0 +1,9 @@
1+ffff, ffffffff :: Natural
2+
3+#ifdef HASKELL_ZIP_DEV_MODE
4+ffff = 200
5+ffffffff = 5000
6+#else
7+ffff = 0xffff
8+ffffffff = 0xffffffff
9+#endif
data/examples/other/cpp/separation-2a.hsnew file+8
@@ -0,0 +1,8 @@
1+ffff, ffffffff :: Natural
2+#ifdef HASKELL_ZIP_DEV_MODE
3+ffff = 200
4+ffffffff = 5000
5+#else
6+ffff = 0xffff
7+ffffffff = 0xffffffff
8+#endif
data/examples/other/cpp/separation-2b-out.hsnew file+12
@@ -0,0 +1,12 @@
1+ffff, ffffffff :: Natural
2+
3+#ifdef HASKELL_ZIP_DEV_MODE
4+ffff = 200
5+ffffffff = 5000
6+#else
7+ffff = 0xffff
8+ffffffff = 0xffffffff
9+#endif
10+
11+foo :: Int
12+foo = undefined
data/examples/other/cpp/separation-2b.hsnew file+11
@@ -0,0 +1,11 @@
1+ffff, ffffffff :: Natural
2+#ifdef HASKELL_ZIP_DEV_MODE
3+ffff = 200
4+ffffffff = 5000
5+#else
6+ffff = 0xffff
7+ffffffff = 0xffffffff
8+#endif
9+
10+foo :: Int
11+foo = undefined
data/examples/other/cpp/shifted-out.hsnew file+21
@@ -0,0 +1,21 @@
1+sinkData h compression = do
2+ (uncompressedSize, crc32, compressedSize) <-
3+ case compression of
4+ Store ->
5+ withCompression
6+ dataSink
7+ Deflate ->
8+ withCompression $
9+ Z.compress 9 (Z.WindowBits (-15)) .| dataSink
10+#ifdef ENABLE_BZIP2
11+ BZip2 -> withCompression $
12+ BZ.bzip2 .| dataSink
13+#else
14+ BZip2 -> throwM BZip2Unsupported
15+#endif
16+ return
17+ DataDescriptor
18+ { ddCRC32 = fromIntegral crc32,
19+ ddCompressedSize = compressedSize,
20+ ddUncompressedSize = uncompressedSize
21+ }
data/examples/other/cpp/shifted.hsnew file+17
@@ -0,0 +1,17 @@
1+sinkData h compression = do
2+ (uncompressedSize, crc32, compressedSize) <-
3+ case compression of
4+ Store -> withCompression
5+ dataSink
6+ Deflate -> withCompression $
7+ Z.compress 9 (Z.WindowBits (-15)) .| dataSink
8+#ifdef ENABLE_BZIP2
9+ BZip2 -> withCompression $
10+ BZ.bzip2 .| dataSink
11+#else
12+ BZip2 -> throwM BZip2Unsupported
13+#endif
14+ return DataDescriptor
15+ { ddCRC32 = fromIntegral crc32
16+ , ddCompressedSize = compressedSize
17+ , ddUncompressedSize = uncompressedSize }
data/examples/other/cpp/simple-import-out.hsnew file+14
@@ -0,0 +1,14 @@
1+module Main (main) where
2+
3+import Data.Void
4+import Test.Hspec
5+import Test.Hspec.Megaparsec
6+import Text.Megaparsec
7+import Text.Megaparsec.Char
8+
9+#if !MIN_VERSION_base(4,13,0)
10+import Data.Semigroup ((<>))
11+#endif
12+
13+main :: IO ()
14+main = return ()
data/examples/other/cpp/simple-import.hsnew file+14
@@ -0,0 +1,14 @@
1+module Main (main) where
2+
3+import Data.Void
4+import Test.Hspec
5+import Test.Hspec.Megaparsec
6+import Text.Megaparsec
7+import Text.Megaparsec.Char
8+
9+#if !MIN_VERSION_base(4,13,0)
10+import Data.Semigroup ((<>))
11+#endif
12+
13+main :: IO ()
14+main = return ()
format.sh+3−3
@@ -7,6 +7,6 @@ set -e
77
88export LANG="C.UTF-8"
99
10−ormolu -p -m inplace $(find app -type f -name "*.hs")
11−ormolu -p -m inplace $(find src -type f \( -name "*.hs" -o -name "*.hs-boot" \))
12−ormolu -p -m inplace $(find tests -type f -name "*.hs")
10+ormolu -m inplace $(find app -type f -name "*.hs")
11+ormolu -m inplace $(find src -type f \( -name "*.hs" -o -name "*.hs-boot" \))
12+ormolu -m inplace $(find tests -type f -name "*.hs")
nix/ormolize/default.nix+1−1
@@ -34,7 +34,7 @@
3434 cp "$hs_file" "''${hs_file}-original"
3535 done
3636
37− (ormolu --tolerate-cpp --check-idempotency --mode inplace $hs_files || true) 2> log.txt
37+ (ormolu --check-idempotency --mode inplace $hs_files || true) 2> log.txt
3838 '';
3939 inherit doCheck;
4040 checkPhase =
ormolu.cabal+1
@@ -110,6 +110,7 @@ library
110110 , Ormolu.Printer.Operators
111111 , Ormolu.Printer.SpanStream
112112 , Ormolu.Processing.Common
113+ , Ormolu.Processing.Cpp
113114 , Ormolu.Processing.Postprocess
114115 , Ormolu.Processing.Preprocess
115116 , Ormolu.Utils
src/Ormolu/Config.hs−5
@@ -17,10 +17,6 @@ data Config = Config
1717 cfgUnsafe :: !Bool,
1818 -- | Output information useful for debugging
1919 cfgDebug :: !Bool,
20− -- | Do not fail if CPP pragma is present (still doesn't handle CPP but
21− -- useful for formatting of files that enable the extension without
22− -- actually containing CPP macros)
23− cfgTolerateCpp :: !Bool,
2420 -- | Checks if re-formatting the result is idempotent.
2521 cfgCheckIdempotency :: !Bool
2622 }
@@ -33,7 +29,6 @@ defaultConfig =
3329 { cfgDynOptions = [],
3430 cfgUnsafe = False,
3531 cfgDebug = False,
36− cfgTolerateCpp = False,
3732 cfgCheckIdempotency = False
3833 }
3934
src/Ormolu/Exception.hs+3−10
@@ -19,9 +19,7 @@ import System.IO
1919
2020-- | Ormolu exception representing all cases when Ormolu can fail.
2121data OrmoluException
22− = -- | Ormolu does not work with source files that use CPP
23− OrmoluCppEnabled FilePath
24− | -- | Parsing of original source code failed
22+ = -- | Parsing of original source code failed
2523 OrmoluParsingFailed GHC.SrcSpan String
2624 | -- | Parsing of formatted source code failed
2725 OrmoluOutputParsingFailed GHC.SrcSpan String
@@ -35,11 +33,6 @@ data OrmoluException
3533
3634instance Exception OrmoluException where
3735 displayException = \case
38− OrmoluCppEnabled path ->
39− unlines
40− [ "CPP is not supported:",
41− withIndent path
42− ]
4336 OrmoluParsingFailed s e ->
4437 showParsingErr "The GHC parser (in Haddock mode) failed:" s [e]
4538 OrmoluOutputParsingFailed s e ->
@@ -81,8 +74,8 @@ withPrettyOrmoluExceptions m = m `catch` h
8174 hPutStrLn stderr (displayException e)
8275 exitWith . ExitFailure $
8376 case e of
84− -- Error code 1 is for `error` or `notImplemented`
85− OrmoluCppEnabled {} -> 2
77+ -- Error code 1 is for 'error' or 'notImplemented'
78+ -- 2 used to be for erroring out on CPP
8679 OrmoluParsingFailed {} -> 3
8780 OrmoluOutputParsingFailed {} -> 4
8881 OrmoluASTDiffers {} -> 5
src/Ormolu/Parser.hs−3
@@ -12,7 +12,6 @@ where
1212import Bag (bagToList)
1313import qualified CmdLineParser as GHC
1414import Control.Exception
15−import Control.Monad
1615import Control.Monad.IO.Class
1716import qualified Data.List as L
1817import qualified Data.List.NonEmpty as NE
@@ -68,8 +67,6 @@ parseModule Config {..} path input' = liftIO $ do
6867 (mkSrcLoc (GHC.mkFastString path) 1 1)
6968 (mkSrcLoc (GHC.mkFastString path) 1 1)
7069 in throwIO (OrmoluParsingFailed loc err)
71− when (GHC.xopt Cpp dynFlags && not cfgTolerateCpp) $
72− throwIO (OrmoluCppEnabled path)
7370 let useRecordDot =
7471 "record-dot-preprocessor" == pgm_F dynFlags
7572 || any
src/Ormolu/Printer/Comments.hs+5−1
@@ -51,7 +51,11 @@ spitFollowingComments ref = do
5151
5252-- | Output all remaining comments in the comment stream.
5353spitRemainingComments :: R ()
54−spitRemainingComments = void $ handleCommentSeries spitRemainingComment
54+spitRemainingComments = do
55+ -- Make sure we have a blank a line between the last definition and the
56+ -- trailing comments.
57+ newline
58+ void $ handleCommentSeries spitRemainingComment
5559
5660----------------------------------------------------------------------------
5761-- Single-comment functions
src/Ormolu/Processing/Cpp.hsnew file+70
@@ -0,0 +1,70 @@
1+{-# LANGUAGE OverloadedStrings #-}
2+
3+-- | Support for CPP.
4+module Ormolu.Processing.Cpp
5+ ( State (..),
6+ processLine,
7+ unmaskLine,
8+ )
9+where
10+
11+import Control.Monad
12+import Data.Char (isSpace)
13+import qualified Data.List as L
14+import Data.Maybe (isJust)
15+import Data.String
16+import Data.Text (Text)
17+import qualified Data.Text as T
18+
19+-- | State of the CPP processor.
20+data State
21+ = -- | Outside of CPP directives
22+ Outside
23+ | -- | In a conditional expression
24+ InConditional
25+ | -- | In a continuation (after @\\@)
26+ InContinuation
27+ deriving (Eq, Show)
28+
29+-- | Automatically mask the line when needed and update the 'State'.
30+processLine :: String -> State -> (String, State)
31+processLine line state
32+ | for "define " = (masked, state')
33+ | for "include " = (masked, state')
34+ | for "undef " = (masked, state')
35+ | for "ifdef " = (masked, InConditional)
36+ | for "ifndef " = (masked, InConditional)
37+ | for "if " = (masked, InConditional)
38+ | for "else" = (masked, InConditional)
39+ | for "elif" = (masked, InConditional)
40+ | for "endif" = (masked, state')
41+ | otherwise =
42+ case state of
43+ Outside -> (line, Outside)
44+ InConditional -> (masked, InConditional)
45+ InContinuation -> (masked, state')
46+ where
47+ for directive = isJust $ do
48+ s <- dropWhile isSpace <$> L.stripPrefix "#" line
49+ void (L.stripPrefix directive s)
50+ masked = maskLine line
51+ state' =
52+ if "\\" `L.isSuffixOf` line
53+ then InContinuation
54+ else Outside
55+
56+-- | Mask the given line.
57+maskLine :: String -> String
58+maskLine x = maskPrefix ++ x
59+
60+-- | If the given line is masked, unmask it. Otherwise return the line
61+-- unchanged.
62+unmaskLine :: Text -> Text
63+unmaskLine x =
64+ case T.stripPrefix maskPrefix (T.stripStart x) of
65+ Nothing -> x
66+ Just x' -> x'
67+
68+-- | Mask prefix for CPP.
69+maskPrefix :: IsString s => s
70+maskPrefix = "-- ORMOLU_CPP_MASK"
src/Ormolu/Processing/Postprocess.hs+6−1
@@ -7,10 +7,15 @@ where
77import Data.Text (Text)
88import qualified Data.Text as T
99import Ormolu.Processing.Common
10+import qualified Ormolu.Processing.Cpp as Cpp
1011
1112-- | Postprocess output of the formatter.
1213postprocess :: Text -> Text
13−postprocess = T.unlines . filter (not . magicComment) . T.lines
14+postprocess =
15+ T.unlines
16+ . fmap Cpp.unmaskLine
17+ . filter (not . magicComment)
18+ . T.lines
1419 where
1520 magicComment x =
1621 x == startDisabling || x == endDisabling
src/Ormolu/Processing/Preprocess.hs+23−13
@@ -15,10 +15,11 @@ import Data.Maybe (maybeToList)
1515import FastString
1616import Ormolu.Parser.Shebang (isShebang)
1717import Ormolu.Processing.Common
18+import qualified Ormolu.Processing.Cpp as Cpp
1819import SrcLoc
1920
2021-- | Transform given input possibly returning comments extracted from it.
21−-- This handles LINE pragmas, shebangs, and the magic comments for
22+-- This handles LINE pragmas, CPP, shebangs, and the magic comments for
2223-- enabling\/disabling of Ormolu.
2324preprocess ::
2425 -- | File name, just to use in the spans
@@ -27,9 +28,9 @@ preprocess ::
2728 String ->
2829 -- | Adjusted input with comments extracted from it
2930 (String, [Located String])
30−preprocess path input = go 1 OrmoluEnabled id id (lines input)
31+preprocess path input = go 1 OrmoluEnabled Cpp.Outside id id (lines input)
3132 where
32− go !n ormoluState inputSoFar csSoFar = \case
33+ go !n ormoluState cppState inputSoFar csSoFar = \case
3334 [] ->
3435 let input' = unlines (inputSoFar [])
3536 in ( case ormoluState of
@@ -38,10 +39,12 @@ preprocess path input = go 1 OrmoluEnabled id id (lines input)
3839 csSoFar []
3940 )
4041 (x : xs) ->
41− let (x', ormoluState', cs) = processLine path n ormoluState x
42+ let (x', ormoluState', cppState', cs) =
43+ processLine path n ormoluState cppState x
4244 in go
4345 (n + 1)
4446 ormoluState'
47+ cppState'
4548 (inputSoFar . (x' :))
4649 (csSoFar . (maybeToList cs ++))
4750 xs
@@ -54,34 +57,41 @@ processLine ::
5457 Int ->
5558 -- | Whether Ormolu is currently enabled
5659 OrmoluState ->
60+ -- | CPP state
61+ Cpp.State ->
5762 -- | The actual line
5863 String ->
5964 -- | Adjusted line and possibly a comment extracted from it
60− (String, OrmoluState, Maybe (Located String))
61−processLine path n ormoluState line
65+ (String, OrmoluState, Cpp.State, Maybe (Located String))
66+processLine path n ormoluState Cpp.Outside line
6267 | "{-# LINE" `L.isPrefixOf` line =
6368 let (pragma, res) = getPragma line
6469 size = length pragma
6570 ss = mkSrcSpan (mkSrcLoc' 1) (mkSrcLoc' (size + 1))
66− in (res, ormoluState, Just (L ss pragma))
71+ in (res, ormoluState, Cpp.Outside, Just (L ss pragma))
6772 | isOrmoluEnable line =
6873 case ormoluState of
6974 OrmoluEnabled ->
70− (enableMarker, OrmoluEnabled, Nothing)
75+ (enableMarker, OrmoluEnabled, Cpp.Outside, Nothing)
7176 OrmoluDisabled ->
72− (endDisabling ++ enableMarker, OrmoluEnabled, Nothing)
77+ (endDisabling ++ enableMarker, OrmoluEnabled, Cpp.Outside, Nothing)
7378 | isOrmoluDisable line =
7479 case ormoluState of
7580 OrmoluEnabled ->
76− (disableMarker ++ startDisabling, OrmoluDisabled, Nothing)
81+ (disableMarker ++ startDisabling, OrmoluDisabled, Cpp.Outside, Nothing)
7782 OrmoluDisabled ->
78− (disableMarker, OrmoluDisabled, Nothing)
83+ (disableMarker, OrmoluDisabled, Cpp.Outside, Nothing)
7984 | isShebang line =
8085 let ss = mkSrcSpan (mkSrcLoc' 1) (mkSrcLoc' (length line))
81− in ("", ormoluState, Just (L ss line))
82− | otherwise = (line, ormoluState, Nothing)
86+ in ("", ormoluState, Cpp.Outside, Just (L ss line))
87+ | otherwise =
88+ let (line', cppState') = Cpp.processLine line Cpp.Outside
89+ in (line', ormoluState, cppState', Nothing)
8390 where
8491 mkSrcLoc' = mkSrcLoc (mkFastString path) n
92+processLine _ _ ormoluState cppState line =
93+ let (line', cppState') = Cpp.processLine line cppState
94+ in (line', ormoluState, cppState', Nothing)
8595
8696-- | Take a line pragma and output its replacement (where line pragma is
8797-- replaced with spaces) and the contents of the pragma itself.