blob: 50916937ef82610935a5d1a22cfc21db6f87f468 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
{-# LANGUAGE PatternSynonyms, OverloadedStrings #-}
module Haddock.Backends.Hyperlinker.Types where
import qualified GHC
import Data.ByteString ( ByteString )
import Data.Map (Map)
data Token = Token
{ tkType :: TokenType
, tkValue :: ByteString -- ^ UTF-8 encoded
, tkSpan :: {-# UNPACK #-} !Span
}
deriving (Show)
pattern BacktickTok, OpenParenTok, CloseParenTok :: Span -> Token
pattern BacktickTok sp = Token TkSpecial "`" sp
pattern OpenParenTok sp = Token TkSpecial "(" sp
pattern CloseParenTok sp = Token TkSpecial ")" sp
type Position = GHC.RealSrcLoc
type Span = GHC.RealSrcSpan
data TokenType
= TkIdentifier
| TkKeyword
| TkString
| TkChar
| TkNumber
| TkOperator
| TkGlyph
| TkSpecial
| TkSpace
| TkComment
| TkCpp
| TkPragma
| TkUnknown
deriving (Show, Eq)
-- | Path for making cross-package hyperlinks in generated sources.
--
-- Used in 'SrcMap' to determine whether module originates in current package
-- or in an external package.
data SrcPath
= SrcExternal FilePath
| SrcLocal
-- | Mapping from modules to cross-package source paths.
type SrcMaps = (Map GHC.Module SrcPath, Map GHC.ModuleName SrcPath)
|