ghc-parser 0.2.0.3 → 0.2.1.0
raw patch · 2 files changed
+21/−2 lines, 2 filesdep ~ghc
Dependency ranges changed: ghc
Files
generic-src/Language/Haskell/GHC/Parser.hs view
@@ -18,6 +18,7 @@ parserTypeSignature, parserModule, parserExpression,+ parsePragmasIntoDynFlags, -- Haskell string preprocessing. removeComments,@@ -28,6 +29,7 @@ import Data.Char (isAlphaNum) import Bag+import DynFlags (parseDynamicFilePragma) import ErrUtils hiding (ErrMsg) import FastString #if MIN_VERSION_ghc(8,4,0)@@ -35,8 +37,10 @@ #else import GHC hiding (Located, parser) #endif+import HeaderInfo (getOptions) import Lexer hiding (buffer) import OrdList+import Panic (handleGhcException) import qualified SrcLoc as SrcLoc import StringBuffer hiding (len) @@ -152,6 +156,21 @@ -- Convert the bag of errors into an error string. printErrorBag bag = joinLines . map show $ bagToList bag++-- Taken from http://blog.shaynefletcher.org/2019/06/have-ghc-parsing-respect-dynamic-pragmas.html+parsePragmasIntoDynFlags :: DynFlags -> FilePath -> String -> IO (Maybe DynFlags)+parsePragmasIntoDynFlags flags filepath str =+ catchErrors $ do+ let opts = getOptions flags (stringToStringBuffer str) filepath+ (flags', _, _) <- parseDynamicFilePragma flags opts+ return $ Just flags'+ where+ catchErrors :: IO (Maybe DynFlags) -> IO (Maybe DynFlags)+ catchErrors act =+ handleGhcException reportErr (handleSourceError reportErr act)+ reportErr e = do+ putStrLn $ "error : " ++ show e+ return Nothing -- Not the same as 'unlines', due to trailing \n joinLines :: [String] -> String
ghc-parser.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: ghc-parser-version: 0.2.0.3+version: 0.2.1.0 synopsis: Haskell source parser from GHC. -- description: homepage: https://github.com/gibiansky/IHaskell@@ -24,7 +24,7 @@ -- other-modules: -- other-extensions: build-depends: base >=4.9 && < 5,- ghc >=8.0 && <8.7+ ghc >=8.0 && <8.9 if impl(ghc >= 8.0) && impl(ghc < 8.4) hs-source-dirs: generic-src src-8.0