[commit: haddock] master: Create scaffolding for Haskell source parser module. (ce0237f)
git at git.haskell.org
git at git.haskell.org
Wed Jul 8 08:39:46 UTC 2015
Repository : ssh://git@git.haskell.org/haddock
On branch : master
Link : http://git.haskell.org/haddock.git/commitdiff/ce0237fa8f482a64dc8ea3ec409a1482ac89e6ac
>---------------------------------------------------------------
commit ce0237fa8f482a64dc8ea3ec409a1482ac89e6ac
Author: Łukasz Hanuszczak <lukasz.hanuszczak at gmail.com>
Date: Thu Jun 4 19:27:34 2015 +0200
Create scaffolding for Haskell source parser module.
>---------------------------------------------------------------
ce0237fa8f482a64dc8ea3ec409a1482ac89e6ac
haddock-api/haddock-api.cabal | 1 +
.../src/Haddock/Backends/Hyperlinker/Parser.hs | 36 ++++++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/haddock-api/haddock-api.cabal b/haddock-api/haddock-api.cabal
index 3bc2226..b90e3bf 100644
--- a/haddock-api/haddock-api.cabal
+++ b/haddock-api/haddock-api.cabal
@@ -79,6 +79,7 @@ library
Haddock.Backends.LaTeX
Haddock.Backends.HaddockDB
Haddock.Backends.Hoogle
+ Haddock.Backends.Hyperlinker.Parser
Haddock.ModuleTree
Haddock.Types
Haddock.Doc
diff --git a/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs b/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
new file mode 100644
index 0000000..11a92b5
--- /dev/null
+++ b/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
@@ -0,0 +1,36 @@
+module Haddock.Backends.Hyperlinker.Parser (parse) where
+
+data Token = Token
+ { tkType :: TokenType
+ , tkValue :: String
+ , tkSpan :: Span
+ }
+
+data Position = Position
+ { posRow :: !Int
+ , posCol :: !Int
+ }
+
+data Span = Span
+ { spStart :: Position
+ , spEnd :: Position
+ }
+
+data TokenType
+ = Identifier
+ | Comment
+ | Whitespace
+ | Operator
+ | Symbol
+
+parse :: String -> [Token]
+parse = tokenize . tag . chunk
+
+chunk :: String -> [String]
+chunk = undefined
+
+tag :: [String] -> [(Span, String)]
+tag = undefined
+
+tokenize :: [(Span, String)] -> [Token]
+tokenize = undefined
More information about the ghc-commits
mailing list