diff options
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 |
commit | e17f62506ecf20d61781c610d6fbb5f3c8cd132e (patch) | |
tree | fa88016b0dda05b5c6d76ff6d1bca7de5130f1b5 /haddock-api | |
parent | ce0237fa8f482a64dc8ea3ec409a1482ac89e6ac (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.hs | 9 |
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 |