aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsimonmar <unknown>2002-04-10 16:28:05 +0000
committersimonmar <unknown>2002-04-10 16:28:05 +0000
commit1c052b0e301f27f7ed4c682b86aae33b3450cc45 (patch)
treef9afc874b872eba98ca79b4ff04118bc6575da2e /src
parent86c2a026f62fb6f6ab6ff1db30b9ea530eeeb631 (diff)
[haddock @ 2002-04-10 16:28:05 by simonmar]
Parse errors in doc strings are now reported as warnings rather that causing the whole thing to fall over. It still needs cleaning up (the warning is emitted with trace) but this will do for the time being.
Diffstat (limited to 'src')
-rw-r--r--src/HaddockParse.y8
-rw-r--r--src/Main.hs8
2 files changed, 13 insertions, 3 deletions
diff --git a/src/HaddockParse.y b/src/HaddockParse.y
index 668e7d28..0c5ebf49 100644
--- a/src/HaddockParse.y
+++ b/src/HaddockParse.y
@@ -3,6 +3,8 @@ module HaddockParse (parseParas, parseString) where
import HaddockLex
import HaddockTypes
+
+import MonadError
}
%tokentype { Token }
@@ -18,6 +20,8 @@ import HaddockTypes
PARA { TokPara }
STRING { TokString $$ }
+%monad { Either String }
+
%name parseParas doc
%name parseString seq
@@ -53,5 +57,7 @@ elem :: { ParsedDoc }
| '[' seq ']' { DocMonospaced $2 }
{
-happyError toks = error ("parse error in doc string: " ++ show (take 3 toks))
+happyError :: [Token] -> Either String a
+happyError toks =
+ throwError ("parse error in doc string: " ++ show (take 3 toks))
}
diff --git a/src/Main.hs b/src/Main.hs
index 796f4939..19941ed1 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -465,12 +465,16 @@ formatDocString :: (String -> Maybe HsQName) -> DocString
-> (Doc,[String])
formatDocString lookup string = format parseParas lookup string
-format :: ([Token] -> ParsedDoc)
+format :: ([Token] -> Either String ParsedDoc)
-> (String -> Maybe HsQName)
-> DocString
-> (Doc, [String])
format parse lookup string
- = runRn lookup $ resolveDoc $ parse $ tokenise $ string
+ = case parse (tokenise string) of
+ Left error -> trace ("Warning: parse error in doc string beginning:\n\
+ \ " ++ take 40 string) (DocEmpty, [])
+ Right doc -> runRn lookup (resolveDoc doc)
+
-- ---------------------------------------------------------------------------
-- Looking up names in documentation