From a18c3af7f983f3b6d3cd84093c9079031da58468 Mon Sep 17 00:00:00 2001 From: Sylvain Henry Date: Tue, 29 Sep 2020 17:18:32 +0200 Subject: Update for parser (#1234) --- haddock-api/src/Haddock/Backends/Hoogle.hs | 2 -- haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs | 6 +++--- haddock-api/src/Haddock/Parser.hs | 5 +++-- 3 files changed, 6 insertions(+), 7 deletions(-) (limited to 'haddock-api/src') diff --git a/haddock-api/src/Haddock/Backends/Hoogle.hs b/haddock-api/src/Haddock/Backends/Hoogle.hs index 8d56a1ed..90bd6b66 100644 --- a/haddock-api/src/Haddock/Backends/Hoogle.hs +++ b/haddock-api/src/Haddock/Backends/Hoogle.hs @@ -38,8 +38,6 @@ import Data.Version import System.Directory import System.FilePath -import GHC.Core.Multiplicity - prefix :: [String] prefix = ["-- Hoogle documentation, generated by Haddock" ,"-- See Hoogle, http://www.haskell.org/hoogle/" diff --git a/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs b/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs index b97ada16..d9746189 100644 --- a/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs +++ b/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs @@ -15,7 +15,7 @@ import GHC.Utils.Error ( pprLocErrMsg ) import GHC.Data.FastString ( mkFastString ) import GHC.Parser.Lexer as Lexer ( P(..), ParseResult(..), PState(..), Token(..) - , mkPStatePure, lexer, mkParserFlags', getErrorMessages) + , initParserState, lexer, mkParserOpts, getErrorMessages) import GHC.Data.Bag ( bagToList ) import GHC.Utils.Outputable ( text, ($$) ) import GHC.Utils.Panic ( panic ) @@ -44,10 +44,10 @@ parse dflags fpath bs = case unP (go False []) initState of text "Hyperlinker parse error:" $$ pprLocErrMsg err where - initState = mkPStatePure pflags buf start + initState = initParserState pflags buf start buf = stringBufferFromByteString bs start = mkRealSrcLoc (mkFastString fpath) 1 1 - pflags = mkParserFlags' (warningFlags dflags) + pflags = mkParserOpts (warningFlags dflags) (extensionFlags dflags) (homeUnitId (mkHomeUnitFromFlags dflags)) (safeImportsOn dflags) diff --git a/haddock-api/src/Haddock/Parser.hs b/haddock-api/src/Haddock/Parser.hs index e1b5c787..366bcd55 100644 --- a/haddock-api/src/Haddock/Parser.hs +++ b/haddock-api/src/Haddock/Parser.hs @@ -17,8 +17,9 @@ import qualified Documentation.Haddock.Parser as P import Documentation.Haddock.Types import GHC.Driver.Session ( DynFlags ) +import GHC.Driver.Config import GHC.Data.FastString ( fsLit ) -import GHC.Parser.Lexer ( mkPState, unP, ParseResult(POk) ) +import GHC.Parser.Lexer ( initParserState, unP, ParseResult(POk) ) import GHC.Parser ( parseIdentifier ) import GHC.Types.Name.Reader ( RdrName ) import GHC.Types.SrcLoc ( mkRealSrcLoc, unLoc ) @@ -34,7 +35,7 @@ parseIdent :: DynFlags -> String -> Maybe RdrName parseIdent dflags str0 = let buffer = stringToStringBuffer str0 realSrcLc = mkRealSrcLoc (fsLit "") 0 0 - pstate = mkPState dflags buffer realSrcLc + pstate = initParserState (initParserOpts dflags) buffer realSrcLc in case unP parseIdentifier pstate of POk _ name -> Just (unLoc name) _ -> Nothing -- cgit v1.2.3