aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsimonmar <unknown>2003-08-18 11:48:46 +0000
committersimonmar <unknown>2003-08-18 11:48:46 +0000
commitea54ebc01fc0a448ed523530a3a52271191337f1 (patch)
treeaa3342c63081c4392eb6f77869111ccb2fdf87f4 /src
parent8f9a1146972021379eadad3fc2a005871db882c8 (diff)
[haddock @ 2003-08-18 11:48:46 by simonmar]
Fixes to the new lexer.
Diffstat (limited to 'src')
-rw-r--r--src/HaddockLex.x12
-rw-r--r--src/HaddockParse.y10
2 files changed, 15 insertions, 7 deletions
diff --git a/src/HaddockLex.x b/src/HaddockLex.x
index d888aeff..0c606bdf 100644
--- a/src/HaddockLex.x
+++ b/src/HaddockLex.x
@@ -19,7 +19,7 @@ import Debug.Trace
$ws = $white # \n
$digit = [0-9]
-$special = [\"\@\/\#]
+$special = [\"\@\/]
$alphanum = [A-Za-z0-9]
$ident = [$alphanum \_\.\!\#\$\%\&\*\+\/\<\=\>\?\@\\\\\^\|\-\~]
@@ -47,10 +47,13 @@ $ident = [$alphanum \_\.\!\#\$\%\&\*\+\/\<\=\>\?\@\\\\\^\|\-\~]
<string> {
$special { strtoken $ \s -> TokSpecial (head s) }
\<.*\> { strtoken $ \s -> TokURL (init (tail s)) }
+ \#.*\# { strtoken $ \s -> TokAName (init (tail s)) }
[\'\`] $ident+ [\'\`] { ident }
\\ . { strtoken (TokString . tail) }
- [^ $special \< \n \'\` \\]* \n { strtoken TokString `andBegin` line }
- [^ $special \< \n \'\` \\]+ { strtoken TokString }
+ -- allow single-quotes to be literal if they don't surround identifiers
+ [\'\`] { strtoken TokString }
+ [^ $special \< \# \n \'\` \\]* \n { strtoken TokString `andBegin` line }
+ [^ $special \< \# \n \'\` \\]+ { strtoken TokString }
}
{
@@ -62,6 +65,7 @@ data Token
| TokIdent [HsQName]
| TokString String
| TokURL String
+ | TokAName String
| TokBirdTrack String
deriving Show
@@ -79,7 +83,7 @@ alexGetChar (_, c:cs) = Just (c, (c,cs))
alexInputPrevChar (c,_) = c
tokenise :: String -> [Token]
-tokenise str = let toks = go ('\n',str) para in trace (show toks) toks
+tokenise str = let toks = go ('\n',str) para in {- trace (show toks) -} toks
where go inp@(_,str) sc =
case alexScan inp sc of
AlexEOF -> []
diff --git a/src/HaddockParse.y b/src/HaddockParse.y
index db712c42..e1a1cb8c 100644
--- a/src/HaddockParse.y
+++ b/src/HaddockParse.y
@@ -10,8 +10,8 @@ import HsSyn
%token '/' { TokSpecial '/' }
'@' { TokSpecial '@' }
DQUO { TokSpecial '\"' }
- '#' { TokSpecial '#' }
URL { TokURL $$ }
+ ANAME { TokAName $$ }
'*' { TokBullet }
'(n)' { TokNumber }
'>..' { TokBirdTrack $$ }
@@ -65,12 +65,16 @@ seq1 :: { Doc }
elem1 :: { Doc }
: STRING { DocString $1 }
- | '/' STRING '/' { DocEmphasis (DocString $2) }
- | '#' STRING '#' { DocAName $2 }
+ | '/' strings '/' { DocEmphasis $2 }
| URL { DocURL $1 }
+ | ANAME { DocAName $1 }
| IDENT { DocIdentifier $1 }
| DQUO STRING DQUO { DocModule $2 }
+strings :: { Doc }
+ : STRING { DocString $1 }
+ | STRING strings { docAppend (DocString $1) $2 }
+
{
happyError :: [Token] -> Either String a
happyError toks =