X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fparser%2FHaddockLex.x;h=52a2673597ce23ff8a009b8da004aa6fa6fe0c91;hb=4c6a3f787abcaed009a574196d82237d9ae64fc8;hp=e4c2d2d933679be01d3bf206156c0eccd7ad4e0e;hpb=190f24892156953d73b55401d0467a6f1a88ce5d;p=ghc-hetmet.git diff --git a/compiler/parser/HaddockLex.x b/compiler/parser/HaddockLex.x index e4c2d2d..52a2673 100644 --- a/compiler/parser/HaddockLex.x +++ b/compiler/parser/HaddockLex.x @@ -7,20 +7,24 @@ -- { +{-# OPTIONS -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 +-- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings +-- for details + module HaddockLex ( Token(..), tokenise ) where -import HsSyn import Lexer hiding (Token) import Parser ( parseIdentifier ) import StringBuffer -import OccName import RdrName import SrcLoc import DynFlags -import DynFlags import Char import Numeric @@ -30,7 +34,7 @@ import System.IO.Unsafe $ws = $white # \n $digit = [0-9] $hexdigit = [0-9a-fA-F] -$special = [\"\@\/] +$special = [\"\@] $alphanum = [A-Za-z0-9] $ident = [$alphanum \'\_\.\!\#\$\%\&\*\+\/\<\=\>\?\@\\\\\^\|\-\~] @@ -63,17 +67,19 @@ $ident = [$alphanum \'\_\.\!\#\$\%\&\*\+\/\<\=\>\?\@\\\\\^\|\-\~] { $special { strtoken $ \s -> TokSpecial (head s) } + \<\<.*\>\> { strtoken $ \s -> TokPic (init $ init $ tail $ tail s) } \<.*\> { strtoken $ \s -> TokURL (init (tail s)) } \#.*\# { strtoken $ \s -> TokAName (init (tail s)) } + \/ [^\/]* \/ { strtoken $ \s -> TokEmphasis (init (tail s)) } [\'\`] $ident+ [\'\`] { ident } \\ . { strtoken (TokString . tail) } "&#" $digit+ \; { strtoken $ \s -> TokString [chr (read (init (drop 2 s)))] } "&#" [xX] $hexdigit+ \; { strtoken $ \s -> case readHex (init (drop 3 s)) of [(n,_)] -> TokString [chr n] } -- 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 \'\` \& \\ \]]+ { strtoken TokString } + [\/\'\`\<\#\&\\] { strtoken TokString } + [^ $special \/ \< \# \n \'\` \& \\ \]]* \n { strtoken TokString `andBegin` line } + [^ $special \/ \< \# \n \'\` \& \\ \]]+ { strtoken TokString } } { @@ -97,6 +103,8 @@ data Token | TokIdent [RdrName] | TokString String | TokURL String + | TokPic String + | TokEmphasis String | TokAName String | TokBirdTrack String -- deriving Show