aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorDavid Lazar <lazar6@illinois.edu>2013-03-29 10:22:11 -0700
committerDavid Lazar <lazar6@illinois.edu>2013-03-29 10:22:11 -0700
commit7424454acef153176a14c3f95e925d5edd6b2e87 (patch)
treefda104aae2a4b7ba3fc2747a844faafea4358c22 /src/Text
parent7cb8b60910ede36bba3598f85a06ddde6fc545d0 (diff)
downloadpandoc-7424454acef153176a14c3f95e925d5edd6b2e87.tar.gz
Haddock reader: improved error reporting.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/Haddock.hs6
-rw-r--r--src/Text/Pandoc/Readers/Haddock/Lex.x3
-rw-r--r--src/Text/Pandoc/Readers/Haddock/Parse.y6
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) =