aboutsummaryrefslogtreecommitdiff
path: root/src/HaddockLex.x
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/HaddockLex.x
parent8f9a1146972021379eadad3fc2a005871db882c8 (diff)
[haddock @ 2003-08-18 11:48:46 by simonmar]
Fixes to the new lexer.
Diffstat (limited to 'src/HaddockLex.x')
-rw-r--r--src/HaddockLex.x12
1 files changed, 8 insertions, 4 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 -> []