Commit 70e996b9 authored by waern's avatar waern
Browse files

Merge from Haddock: Modify lexing of /../

  Tue Aug 28 11:19:54 CEST 2007  Simon Marlow <simonmar@microsoft.com>
    * Modify lexing of /../ 
    This makes /../ more like '..', so that a single / on a line doesn't
    trigger a parse error.  This should reduce the causes of accidental
    parse errors in Haddock comments; apparently stray / characters are
    a common source of failures.

Please merge this to the 6.8.2 branch.
parent 92e7ecbc
......@@ -14,5 +14,6 @@ data Token
| TokIdent [RdrName]
| TokString String
| TokURL String
| TokEmphasis String
| TokAName String
| TokBirdTrack String
......@@ -34,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 \'\_\.\!\#\$\%\&\*\+\/\<\=\>\?\@\\\\\^\|\-\~]
......@@ -69,15 +69,16 @@ $ident = [$alphanum \'\_\.\!\#\$\%\&\*\+\/\<\=\>\?\@\\\\\^\|\-\~]
$special { strtoken $ \s -> TokSpecial (head 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 }
}
<def> {
......@@ -101,6 +102,7 @@ data Token
| TokIdent [RdrName]
| TokString String
| TokURL String
| TokEmphasis String
| TokAName String
| TokBirdTrack String
-- deriving Show
......
......@@ -22,6 +22,7 @@ import RdrName
DQUO { TokSpecial '\"' }
URL { TokURL $$ }
ANAME { TokAName $$ }
'/../' { TokEmphasis $$ }
'-' { TokBullet }
'(n)' { TokNumber }
'>..' { TokBirdTrack $$ }
......@@ -80,7 +81,7 @@ seq1 :: { HsDoc RdrName }
elem1 :: { HsDoc RdrName }
: STRING { DocString $1 }
| '/' strings '/' { DocEmphasis (DocString $2) }
| '/../' { DocEmphasis (DocString $1) }
| URL { DocURL $1 }
| ANAME { DocAName $1 }
| IDENT { DocIdentifier $1 }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment