module TextParser.Header (parseHeader) where

import TextData.Data
import TextData.Keywords
import Text.Parsec
import Text.Parsec.String
import Text.Parsec.Combinator


{-PARSE a header-}
parseHeader :: Parser Header
parseHeader = do t <- parseHeaderTag title_tag
                 l <- parseHeaderTag lastname_tag
                 f <- parseHeaderTag firstname_tag
                 d <- parseHeaderTag date_tag
                 parseHeaderSeperator
                 return $ Header t l f d

parseHeaderTag :: String -> Parser String
parseHeaderTag s = do string s
                      char colon
                      manyTill anyChar $ try $ string "\n"


parseHeaderSeperator :: Parser ()
parseHeaderSeperator = do count header_seperator_count (char dash)
                          manyTill (char dash) $ try $ string "\n"
                          return ()
