summaryrefslogtreecommitdiff
path: root/compiler/parser
diff options
context:
space:
mode:
authorDavid Waern <david.waern@gmail.com>2007-11-12 02:38:56 +0000
committerDavid Waern <david.waern@gmail.com>2007-11-12 02:38:56 +0000
commit70e996b9a6cd657d441cba95014304a588c0fd7c (patch)
treeb8def5032ed61ed2dc5526d34725ea5fc3523c1c /compiler/parser
parent92e7ecbcc393caab7f0d8883a51cbfca42767cb1 (diff)
downloadhaskell-70e996b9a6cd657d441cba95014304a588c0fd7c.tar.gz
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.
Diffstat (limited to 'compiler/parser')
-rw-r--r--compiler/parser/HaddockLex.hs-boot1
-rw-r--r--compiler/parser/HaddockLex.x10
-rw-r--r--compiler/parser/HaddockParse.y3
3 files changed, 9 insertions, 5 deletions
diff --git a/compiler/parser/HaddockLex.hs-boot b/compiler/parser/HaddockLex.hs-boot
index abfc2d6667..3144744348 100644
--- a/compiler/parser/HaddockLex.hs-boot
+++ b/compiler/parser/HaddockLex.hs-boot
@@ -14,5 +14,6 @@ data Token
| TokIdent [RdrName]
| TokString String
| TokURL String
+ | TokEmphasis String
| TokAName String
| TokBirdTrack String
diff --git a/compiler/parser/HaddockLex.x b/compiler/parser/HaddockLex.x
index f395976d0b..acc04d68ac 100644
--- a/compiler/parser/HaddockLex.x
+++ b/compiler/parser/HaddockLex.x
@@ -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
diff --git a/compiler/parser/HaddockParse.y b/compiler/parser/HaddockParse.y
index ded4dbe394..d59195716c 100644
--- a/compiler/parser/HaddockParse.y
+++ b/compiler/parser/HaddockParse.y
@@ -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 }