aboutsummaryrefslogtreecommitdiff
path: root/haddock-api/src/Haddock/Backends/Hyperlinker
diff options
context:
space:
mode:
authorYuchen Pei <hi@ypei.me>2022-07-21 12:27:19 +1000
committerYuchen Pei <hi@ypei.me>2022-07-21 12:27:19 +1000
commit32ac0f03b4259fc8eebba9bb3a2a46d23122a43b (patch)
treea371fb9c5a3f78e6f53c66d70e1255fdc71bba4d /haddock-api/src/Haddock/Backends/Hyperlinker
parentcd17128898089450bb21790fd1864dc08fd4ddbc (diff)
parent2368e9329e6600b46000abd24ec00b7e27bcae75 (diff)
Merge remote-tracking branch 'upstream/ghc-9.4' into ghc-9.4
Diffstat (limited to 'haddock-api/src/Haddock/Backends/Hyperlinker')
-rw-r--r--haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs23
1 files changed, 14 insertions, 9 deletions
diff --git a/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs b/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
index d9a2e0cd..9f28d72a 100644
--- a/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
+++ b/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
@@ -10,14 +10,17 @@ import Data.List ( isPrefixOf, isSuffixOf )
import qualified Data.ByteString as BS
+import GHC.Platform
import GHC.Types.SourceText
import GHC.Driver.Session
+import GHC.Driver.Config.Diagnostic
import GHC.Utils.Error ( pprLocMsgEnvelope )
import GHC.Data.FastString ( mkFastString )
-import GHC.Parser.Errors.Ppr ( pprError )
+import GHC.Parser.Errors.Ppr ()
+import qualified GHC.Types.Error as E
import GHC.Parser.Lexer as Lexer
( P(..), ParseResult(..), PState(..), Token(..)
- , initParserState, lexer, mkParserOpts, getErrorMessages)
+ , initParserState, lexer, mkParserOpts, getPsErrorMessages)
import GHC.Data.Bag ( bagToList )
import GHC.Utils.Outputable ( text, ($$) )
import GHC.Utils.Panic ( panic )
@@ -40,7 +43,7 @@ parse
parse dflags fpath bs = case unP (go False []) initState of
POk _ toks -> reverse toks
PFailed pst ->
- let err:_ = bagToList (fmap pprError (getErrorMessages pst)) in
+ let err:_ = bagToList (E.getMessages $ getPsErrorMessages pst) in
panic $ showSDoc dflags $
text "Hyperlinker parse error:" $$ pprLocMsgEnvelope err
where
@@ -48,8 +51,10 @@ parse dflags fpath bs = case unP (go False []) initState of
initState = initParserState pflags buf start
buf = stringBufferFromByteString bs
start = mkRealSrcLoc (mkFastString fpath) 1 1
- pflags = mkParserOpts (warningFlags dflags)
- (extensionFlags dflags)
+ arch_os = platformArchOS (targetPlatform dflags)
+ pflags = mkParserOpts (extensionFlags dflags)
+ (initDiagOpts dflags)
+ (supportedLanguagesAndExtensions arch_os)
(safeImportsOn dflags)
False -- lex Haddocks as comment tokens
True -- produce comment tokens
@@ -233,6 +238,7 @@ classify tok =
ITrequires -> TkKeyword
ITinline_prag {} -> TkPragma
+ ITopaque_prag {} -> TkPragma
ITspec_prag {} -> TkPragma
ITspec_inline_prag {} -> TkPragma
ITsource_prag {} -> TkPragma
@@ -263,6 +269,7 @@ classify tok =
ITequal -> TkGlyph
ITlam -> TkGlyph
ITlcase -> TkGlyph
+ ITlcases -> TkGlyph
ITvbar -> TkGlyph
ITlarrow {} -> TkGlyph
ITrarrow {} -> TkGlyph
@@ -350,10 +357,7 @@ classify tok =
ITeof -> TkUnknown
ITlineComment {} -> TkComment
- ITdocCommentNext {} -> TkComment
- ITdocCommentPrev {} -> TkComment
- ITdocCommentNamed {} -> TkComment
- ITdocSection {} -> TkComment
+ ITdocComment {} -> TkComment
ITdocOptions {} -> TkComment
-- The lexer considers top-level pragmas as comments (see `pragState` in
@@ -374,6 +378,7 @@ inPragma True _ = True
inPragma False tok =
case tok of
ITinline_prag {} -> True
+ ITopaque_prag {} -> True
ITspec_prag {} -> True
ITspec_inline_prag {} -> True
ITsource_prag {} -> True