X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Fparser%2FHaddockLex.x;h=d5e40f257726923768c8d3eb426418b9cc57b07a;hp=52a2673597ce23ff8a009b8da004aa6fa6fe0c91;hb=24d49415d2833a1338dfb5fd8c5c1c84df6c282b;hpb=c6b0a84d8a3aec97086e5316b321dad9594a4fac diff --git a/compiler/parser/HaddockLex.x b/compiler/parser/HaddockLex.x index 52a2673..d5e40f2 100644 --- a/compiler/parser/HaddockLex.x +++ b/compiler/parser/HaddockLex.x @@ -7,7 +7,7 @@ -- { -{-# OPTIONS -w #-} +{-# OPTIONS -Wwarn -w #-} -- The above warning supression flag is a temporary kludge. -- While working on this module you are encouraged to remove it and fix -- any warnings in the module. See @@ -63,7 +63,7 @@ $ident = [$alphanum \'\_\.\!\#\$\%\&\*\+\/\<\=\>\?\@\\\\\^\|\-\~] () { begin string } } - .* \n? { strtoken TokBirdTrack `andBegin` line } + .* \n? { strtokenNL TokBirdTrack `andBegin` line } { $special { strtoken $ \s -> TokSpecial (head s) } @@ -78,7 +78,7 @@ $ident = [$alphanum \'\_\.\!\#\$\%\&\*\+\/\<\=\>\?\@\\\\\^\|\-\~] -- allow special characters through if they don't fit one of the previous -- patterns. [\/\'\`\<\#\&\\] { strtoken TokString } - [^ $special \/ \< \# \n \'\` \& \\ \]]* \n { strtoken TokString `andBegin` line } + [^ $special \/ \< \# \n \'\` \& \\ \]]* \n { strtokenNL TokString `andBegin` line } [^ $special \/ \< \# \n \'\` \& \\ \]]+ { strtoken TokString } } @@ -128,7 +128,7 @@ tokenise str = let toks = go ('\n', eofHack str) para in {-trace (show toks)-} t case alexScan inp sc of AlexEOF -> [] AlexError _ -> error "lexical error" - AlexSkip inp' len -> go inp' sc + AlexSkip inp' _ -> go inp' sc AlexToken inp' len act -> act (take len str) sc (\sc -> go inp' sc) -- NB. we add a final \n to the string, (see comment in the beginning of line @@ -136,16 +136,19 @@ tokenise str = let toks = go ('\n', eofHack str) para in {-trace (show toks)-} t eofHack str = str++"\n" andBegin :: Action -> StartCode -> Action -andBegin act new_sc = \str sc cont -> act str new_sc cont +andBegin act new_sc = \str _ cont -> act str new_sc cont token :: Token -> Action -token t = \str sc cont -> t : cont sc +token t = \_ sc cont -> t : cont sc -strtoken :: (String -> Token) -> Action +strtoken, strtokenNL :: (String -> Token) -> Action strtoken t = \str sc cont -> t str : cont sc +strtokenNL t = \str sc cont -> t (filter (/= '\r') str) : cont sc +-- ^ We only want LF line endings in our internal doc string format, so we +-- filter out all CRs. begin :: StartCode -> Action -begin sc = \str _ cont -> cont sc +begin sc = \_ _ cont -> cont sc -- ----------------------------------------------------------------------------- -- Lex a string as a Haskell identifier @@ -161,7 +164,6 @@ strToHsQNames :: String -> Maybe [RdrName] strToHsQNames str0 = let buffer = unsafePerformIO (stringToStringBuffer str0) pstate = mkPState buffer noSrcLoc defaultDynFlags - lex = lexer (\t -> return t) result = unP parseIdentifier pstate in case result of POk _ name -> Just [unLoc name]