X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fparser%2FHaddockParse.y;h=e3f45f9475e1cf543b2ba7db9f9110ed4ef34c83;hb=87c0577a410487fb1255fa5015c6b4f8eaa66ca0;hp=ded4dbe3941ab01b14fcad61a27e37953446d2f8;hpb=92e7ecbcc393caab7f0d8883a51cbfca42767cb1;p=ghc-hetmet.git diff --git a/compiler/parser/HaddockParse.y b/compiler/parser/HaddockParse.y index ded4dbe..e3f45f9 100644 --- a/compiler/parser/HaddockParse.y +++ b/compiler/parser/HaddockParse.y @@ -6,7 +6,11 @@ -- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings -- for details -module HaddockParse (parseHaddockParagraphs, parseHaddockString) where +module HaddockParse ( + parseHaddockParagraphs, + parseHaddockString, + MyEither(..) +) where import {-# SOURCE #-} HaddockLex import HsSyn @@ -21,7 +25,9 @@ import RdrName ']' { TokDefEnd } DQUO { TokSpecial '\"' } URL { TokURL $$ } + PIC { TokPic $$ } ANAME { TokAName $$ } + '/../' { TokEmphasis $$ } '-' { TokBullet } '(n)' { TokNumber } '>..' { TokBirdTrack $$ } @@ -29,7 +35,7 @@ import RdrName PARA { TokPara } STRING { TokString $$ } -%monad { Either String } +%monad { MyEither String } %name parseHaddockParagraphs doc %name parseHaddockString seq @@ -80,8 +86,9 @@ seq1 :: { HsDoc RdrName } elem1 :: { HsDoc RdrName } : STRING { DocString $1 } - | '/' strings '/' { DocEmphasis (DocString $2) } + | '/../' { DocEmphasis (DocString $1) } | URL { DocURL $1 } + | PIC { DocPic $1 } | ANAME { DocAName $1 } | IDENT { DocIdentifier $1 } | DQUO strings DQUO { DocModule $2 } @@ -91,16 +98,17 @@ strings :: { String } | STRING strings { $1 ++ $2 } { -happyError :: [Token] -> Either String a -happyError toks = --- Left ("parse error in doc string: " ++ show (take 3 toks)) - Left ("parse error in doc string") - --- Either monad (we can't use MonadError because GHC < 5.00 has --- an older incompatible version). -instance Monad (Either String) where - return = Right - Left l >>= _ = Left l - Right r >>= k = k r - fail msg = Left msg +happyError :: [Token] -> MyEither String a +happyError toks = MyLeft ("parse error in doc string") + +-- We don't want to make an instance for Either String, +-- since every user of the GHC API would get that instance + +data MyEither a b = MyLeft a | MyRight b + +instance Monad (MyEither String) where + return = MyRight + MyLeft l >>= _ = MyLeft l + MyRight r >>= k = k r + fail msg = MyLeft msg }