aboutsummaryrefslogtreecommitdiff
path: root/haddock-api
diff options
context:
space:
mode:
authorŁukasz Hanuszczak <lukasz.hanuszczak@gmail.com>2015-06-04 19:59:27 +0200
committerŁukasz Hanuszczak <lukasz.hanuszczak@gmail.com>2015-06-30 22:37:48 +0200
commite17f62506ecf20d61781c610d6fbb5f3c8cd132e (patch)
treefa88016b0dda05b5c6d76ff6d1bca7de5130f1b5 /haddock-api
parentce0237fa8f482a64dc8ea3ec409a1482ac89e6ac (diff)
Implement function for tagging parsed chunks with source spans.
Diffstat (limited to 'haddock-api')
-rw-r--r--haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs b/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
index 11a92b57..4bcc0c8a 100644
--- a/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
+++ b/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
@@ -30,7 +30,14 @@ chunk :: String -> [String]
chunk = undefined
tag :: [String] -> [(Span, String)]
-tag = undefined
+tag =
+ reverse . snd . foldl aux (Position 1 1, [])
+ where
+ aux (pos, cs) c =
+ let pos' = if c == "\n"
+ then pos { posRow = posRow pos + 1, posCol = 1 }
+ else pos { posCol = posCol pos + length c }
+ in (pos', (Span pos pos', c):cs)
tokenize :: [(Span, String)] -> [Token]
tokenize = undefined