[commit: haddock] master: Add support for recognizing compiler pragmas in source parser. (e5bd5d3)

git at git.haskell.org git at git.haskell.org
Wed Jul 8 08:39:34 UTC 2015


Repository : ssh://git@git.haskell.org/haddock

On branch  : master
Link       : http://git.haskell.org/haddock.git/commitdiff/e5bd5d39550692f936c973637f8ec8d314919359

>---------------------------------------------------------------

commit e5bd5d39550692f936c973637f8ec8d314919359
Author: Łukasz Hanuszczak <lukasz.hanuszczak at gmail.com>
Date:   Fri Jun 5 15:12:40 2015 +0200

    Add support for recognizing compiler pragmas in source parser.


>---------------------------------------------------------------

e5bd5d39550692f936c973637f8ec8d314919359
 haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs   | 2 ++
 haddock-api/src/Haddock/Backends/Hyperlinker/Renderer.hs | 1 +
 2 files changed, 3 insertions(+)

diff --git a/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs b/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
index 29edb4c..0e1ad5b 100644
--- a/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
+++ b/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
@@ -35,6 +35,7 @@ data TokenType
     | TkSpace
     | TkComment
     | TkCpp
+    | TkPragma
     | TkUnknown
 
 parse :: String -> [Token]
@@ -92,6 +93,7 @@ tokenize =
 classify :: String -> TokenType
 classify str
     | "--" `isPrefixOf` str = TkComment
+    | "{-#" `isPrefixOf` str = TkPragma
     | "{-" `isPrefixOf` str = TkComment
 classify (c:_)
     | isSpace c = TkSpace
diff --git a/haddock-api/src/Haddock/Backends/Hyperlinker/Renderer.hs b/haddock-api/src/Haddock/Backends/Hyperlinker/Renderer.hs
index 9ebb870..39d7d18 100644
--- a/haddock-api/src/Haddock/Backends/Hyperlinker/Renderer.hs
+++ b/haddock-api/src/Haddock/Backends/Hyperlinker/Renderer.hs
@@ -38,4 +38,5 @@ tokenAttrs TkSpecial = [Html.theclass "hs-special"]
 tokenAttrs TkSpace = []
 tokenAttrs TkComment = [Html.theclass "hs-comment"]
 tokenAttrs TkCpp = [Html.theclass "hs-cpp"]
+tokenAttrs TkPragma = [Html.theclass "hs-pragma"]
 tokenAttrs TkUnknown = []



More information about the ghc-commits mailing list