diff options
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/Haddock.hs | 6 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Haddock/Lex.x | 3 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Haddock/Parse.y | 6 |
3 files changed, 9 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Readers/Haddock.hs b/src/Text/Pandoc/Readers/Haddock.hs index 49154b0ca..081ec7b5e 100644 --- a/src/Text/Pandoc/Readers/Haddock.hs +++ b/src/Text/Pandoc/Readers/Haddock.hs @@ -24,8 +24,10 @@ readHaddock :: ReaderOptions -- ^ Reader options readHaddock _ s = Pandoc (Meta [] [] []) blocks where blocks = case parseParas (tokenise s (0,0)) of - Nothing -> [] - Just x -> mergeLists (toList x) + Left [] -> error "parse failure" + Left (tok:_) -> error $ "parse failure " ++ pos (tokenPos tok) + where pos (l, c) = "(line " ++ show l ++ ", column " ++ show c ++ ")" + Right x -> mergeLists (toList x) -- similar to 'docAppend' in Haddock.Doc mergeLists :: [Block] -> [Block] diff --git a/src/Text/Pandoc/Readers/Haddock/Lex.x b/src/Text/Pandoc/Readers/Haddock/Lex.x index 902ac84c0..9d686c885 100644 --- a/src/Text/Pandoc/Readers/Haddock/Lex.x +++ b/src/Text/Pandoc/Readers/Haddock/Lex.x @@ -19,7 +19,8 @@ module Text.Pandoc.Readers.Haddock.Lex ( Token(..), LToken, - tokenise + tokenise, + tokenPos ) where import Data.Char diff --git a/src/Text/Pandoc/Readers/Haddock/Parse.y b/src/Text/Pandoc/Readers/Haddock/Parse.y index 26d7c287d..c45e09113 100644 --- a/src/Text/Pandoc/Readers/Haddock/Parse.y +++ b/src/Text/Pandoc/Readers/Haddock/Parse.y @@ -46,7 +46,7 @@ import Data.Sequence (viewr, ViewR(..)) PARA { (TokPara,_) } STRING { (TokString $$,_) } -%monad { Maybe } +%monad { Either [LToken] } %name parseParas doc %name parseString seq @@ -126,8 +126,8 @@ strings :: { String } | STRING strings { $1 ++ $2 } { -happyError :: [LToken] -> Maybe a -happyError toks = Nothing +happyError :: [LToken] -> Either [LToken] a +happyError toks = Left toks para' :: Inlines -> Blocks para' (Many ils) = |