From 92baa0e82dd8e78568cd56f72508b48ebfdfdfdb Mon Sep 17 00:00:00 2001 From: simonmar Date: Tue, 28 May 2002 11:17:55 +0000 Subject: [haddock @ 2002-05-28 11:17:55 by simonmar] If an identifier doesn't lex, then just replace it by a DocString. --- src/HaddockParse.y | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/HaddockParse.y b/src/HaddockParse.y index 37ceff4f..f74d2b69 100644 --- a/src/HaddockParse.y +++ b/src/HaddockParse.y @@ -69,7 +69,7 @@ elem1 :: { Doc } : STRING { DocString $1 } | '/' STRING '/' { DocEmphasis (DocString $2) } | URL { DocURL $1 } - | squo STRING squo { DocIdentifier (strToHsQNames $2) } + | squo STRING squo { strToHsQNames $2 } | DQUO STRING DQUO { DocModule $2 } squo :: { () } @@ -89,28 +89,29 @@ instance Monad (Either String) where Right r >>= k = k r fail msg = Left msg -strToHsQNames :: String -> [ HsQName ] +strToHsQNames :: String -> Doc strToHsQNames str = case lexer (\t -> returnP t) str (SrcLoc 1 1) 1 1 [] of Ok _ (VarId str) - -> [ UnQual (HsVarName (HsIdent str)) ] + -> DocIdentifier [ UnQual (HsVarName (HsIdent str)) ] Ok _ (QVarId (mod,str)) - -> [ Qual (Module mod) (HsVarName (HsIdent str)) ] + -> DocIdentifier [ Qual (Module mod) (HsVarName (HsIdent str)) ] Ok _ (ConId str) - -> [ UnQual (HsTyClsName (HsIdent str)), - UnQual (HsVarName (HsIdent str)) ] + -> DocIdentifier [ UnQual (HsTyClsName (HsIdent str)), + UnQual (HsVarName (HsIdent str)) ] Ok _ (QConId (mod,str)) - -> [ Qual (Module mod) (HsTyClsName (HsIdent str)), - Qual (Module mod) (HsVarName (HsIdent str)) ] + -> DocIdentifier [ Qual (Module mod) (HsTyClsName (HsIdent str)), + Qual (Module mod) (HsVarName (HsIdent str)) ] Ok _ (VarSym str) - -> [ UnQual (HsVarName (HsSymbol str)) ] + -> DocIdentifier [ UnQual (HsVarName (HsSymbol str)) ] Ok _ (ConSym str) - -> [ UnQual (HsTyClsName (HsSymbol str)), - UnQual (HsVarName (HsSymbol str)) ] + -> DocIdentifier [ UnQual (HsTyClsName (HsSymbol str)), + UnQual (HsVarName (HsSymbol str)) ] Ok _ (QVarSym (mod,str)) - -> [ Qual (Module mod) (HsVarName (HsSymbol str)) ] + -> DocIdentifier [ Qual (Module mod) (HsVarName (HsSymbol str)) ] Ok _ (QConSym (mod,str)) - -> [ Qual (Module mod) (HsTyClsName (HsSymbol str)), - Qual (Module mod) (HsVarName (HsSymbol str)) ] - other -> [] + -> DocIdentifier [ Qual (Module mod) (HsTyClsName (HsSymbol str)), + Qual (Module mod) (HsVarName (HsSymbol str)) ] + other + -> DocString str } -- cgit v1.2.3