From bb6cef20b82ef7a7f2d49f3ef6dc1a7ce880b5f0 Mon Sep 17 00:00:00 2001 From: Mateusz Kowalczyk Date: Tue, 9 Jul 2013 14:24:10 +0100 Subject: One pass parser and tests. We remove the HTML test as it is no longer necessary. We cover the test case in spec tests and other HTML tests but keeping this around fails: this is because the new parser has different semantics there. In fact, I suspect the original behaviour was a bug that wasn't caught/fixed but simply included as-is during the testing. --- src/Haddock/Interface/LexParseRn.hs | 11 +++++------ src/Haddock/Interface/ParseModuleHeader.hs | 9 +++------ 2 files changed, 8 insertions(+), 12 deletions(-) (limited to 'src/Haddock/Interface') diff --git a/src/Haddock/Interface/LexParseRn.hs b/src/Haddock/Interface/LexParseRn.hs index 9d775bcb..13563532 100644 --- a/src/Haddock/Interface/LexParseRn.hs +++ b/src/Haddock/Interface/LexParseRn.hs @@ -19,8 +19,7 @@ module Haddock.Interface.LexParseRn import Haddock.Types -import Haddock.Lex -import Haddock.Parse +import Haddock.Parser import Haddock.Interface.ParseModuleHeader import Haddock.Doc @@ -50,19 +49,19 @@ processDocStringParas = process parseParas processDocString :: DynFlags -> GlobalRdrEnv -> HsDocString -> ErrMsgM (Maybe (Doc Name)) processDocString = process parseString -process :: ([LToken] -> Maybe (Doc RdrName)) +process :: (DynFlags -> String -> Maybe (Doc RdrName)) -> DynFlags -> GlobalRdrEnv -> HsDocString -> ErrMsgM (Maybe (Doc Name)) process parse dflags gre (HsDocString fs) = do let str = unpackFS fs - let toks = tokenise dflags str (0,0) -- TODO: real position - case parse toks of + case parse dflags str of Nothing -> do tell [ "doc comment parse failed: " ++ str ] return Nothing - Just doc -> return (Just (rename dflags gre doc)) + Just doc -> do + return (Just (rename dflags gre doc)) processModuleHeader :: DynFlags -> GlobalRdrEnv -> SafeHaskellMode -> Maybe LHsDocString diff --git a/src/Haddock/Interface/ParseModuleHeader.hs b/src/Haddock/Interface/ParseModuleHeader.hs index 5087affe..2e4fe73b 100644 --- a/src/Haddock/Interface/ParseModuleHeader.hs +++ b/src/Haddock/Interface/ParseModuleHeader.hs @@ -12,8 +12,7 @@ module Haddock.Interface.ParseModuleHeader (parseModuleHeader) where import Haddock.Types -import Haddock.Lex -import Haddock.Parse +import Haddock.Parser import RdrName import DynFlags @@ -47,15 +46,13 @@ parseModuleHeader dflags str0 = description1 :: Either String (Maybe (Doc RdrName)) description1 = case descriptionOpt of Nothing -> Right Nothing - -- TODO: pass real file position - Just description -> case parseString $ tokenise dflags description (0,0) of + Just description -> case parseString dflags description of Nothing -> Left ("Cannot parse Description: " ++ description) Just doc -> Right (Just doc) in case description1 of Left mess -> Left mess - -- TODO: pass real file position - Right docOpt -> case parseParas $ tokenise dflags str8 (0,0) of + Right docOpt -> case parseParas dflags str8 of Nothing -> Left "Cannot parse header documentation paragraphs" Just doc -> Right (HaddockModInfo { hmi_description = docOpt, -- cgit v1.2.3