aboutsummaryrefslogtreecommitdiff
path: root/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2017-03-10 10:21:55 -0500
committerBen Gamari <ben@smart-cactus.org>2017-03-10 10:21:55 -0500
commitdb13d5f56d8e693b44bafc793d7b3bfac1c25b91 (patch)
tree128f2c23169c06c7a645979e37a1ba2cfda82c4b /haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
parent240bc38b94ed2d0af27333b23392d03eeb615e82 (diff)
parentd2be5e88281d8e3148bc55830c27c75844b86f38 (diff)
Merge branch 'ghc-head'
Diffstat (limited to 'haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs')
-rw-r--r--haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs12
1 files changed, 11 insertions, 1 deletions
diff --git a/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs b/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
index e206413e..e4345602 100644
--- a/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
+++ b/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
@@ -31,12 +31,20 @@ chunk str@(c:_)
chunk str
| "--" `isPrefixOf` str = chunk' $ spanToNewline str
| "{-" `isPrefixOf` str = chunk' $ chunkComment 0 str
- | otherwise = case lex str of
+ | otherwise = case lex' str of
(tok:_) -> chunk' tok
[] -> [str]
where
chunk' (c, rest) = c:(chunk rest)
+-- | A bit better lexer then the default, i.e. handles DataKinds quotes
+lex' :: ReadS String
+lex' ('\'' : '\'' : rest) = [("''", rest)]
+lex' str@('\'' : '\\' : _ : '\'' : _) = lex str
+lex' str@('\'' : _ : '\'' : _) = lex str
+lex' ('\'' : rest) = [("'", rest)]
+lex' str = lex str
+
-- | Split input to "first line" string and the rest of it.
--
-- Ideally, this should be done simply with @'break' (== '\n')@. However,
@@ -124,6 +132,8 @@ classify str
| "--" `isPrefixOf` str = TkComment
| "{-#" `isPrefixOf` str = TkPragma
| "{-" `isPrefixOf` str = TkComment
+classify "''" = TkSpecial
+classify "'" = TkSpecial
classify str@(c:_)
| isSpace c = TkSpace
| isDigit c = TkNumber