From ce0237fa8f482a64dc8ea3ec409a1482ac89e6ac Mon Sep 17 00:00:00 2001 From: Ɓukasz Hanuszczak Date: Thu, 4 Jun 2015 19:27:34 +0200 Subject: Create scaffolding for Haskell source parser module. --- .../src/Haddock/Backends/Hyperlinker/Parser.hs | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs (limited to 'haddock-api/src/Haddock/Backends') 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 00000000..11a92b57 --- /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 -- cgit v1.2.3