summaryrefslogtreecommitdiff
path: root/compiler/parser/HaddockLex.x
diff options
context:
space:
mode:
authorDavid Waern <david.waern@gmail.com>2009-02-28 14:53:51 +0000
committerDavid Waern <david.waern@gmail.com>2009-02-28 14:53:51 +0000
commit1b9618c37bb254e1d16aa286ceedc9a81f41e871 (patch)
treeca043b186be7753bd42451024cfcacaeae67ede5 /compiler/parser/HaddockLex.x
parent911860671d3f35a52b54869a7a3e7730d7c631dd (diff)
downloadhaskell-1b9618c37bb254e1d16aa286ceedc9a81f41e871.tar.gz
Filter out carriage returns in doc strings
We want the internal format to contain LFs only. This makes it easier to work with the doc strings for clients of the GHC API.
Diffstat (limited to 'compiler/parser/HaddockLex.x')
-rw-r--r--compiler/parser/HaddockLex.x9
1 files changed, 6 insertions, 3 deletions
diff --git a/compiler/parser/HaddockLex.x b/compiler/parser/HaddockLex.x
index d9b4c03b19..7ed365f9ba 100644
--- a/compiler/parser/HaddockLex.x
+++ b/compiler/parser/HaddockLex.x
@@ -63,7 +63,7 @@ $ident = [$alphanum \'\_\.\!\#\$\%\&\*\+\/\<\=\>\?\@\\\\\^\|\-\~]
() { begin string }
}
-<birdtrack> .* \n? { strtoken TokBirdTrack `andBegin` line }
+<birdtrack> .* \n? { strtokenNL TokBirdTrack `andBegin` line }
<string,def> {
$special { strtoken $ \s -> TokSpecial (head s) }
@@ -78,7 +78,7 @@ $ident = [$alphanum \'\_\.\!\#\$\%\&\*\+\/\<\=\>\?\@\\\\\^\|\-\~]
-- 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 \'\` \& \\ \]]* \n { strtokenNL TokString `andBegin` line }
[^ $special \/ \< \# \n \'\` \& \\ \]]+ { strtoken TokString }
}
@@ -141,8 +141,11 @@ andBegin act new_sc = \str _ cont -> act str new_sc cont
token :: Token -> Action
token t = \_ sc cont -> t : cont sc
-strtoken :: (String -> Token) -> Action
+strtoken, strtokenNL :: (String -> Token) -> Action
strtoken t = \str sc cont -> t str : cont sc
+strtokenNL t = \str sc cont -> t (filter (/= '\r') str) : cont sc
+-- ^ We only want LF line endings in our internal doc string format, so we
+-- filter out all CRs.
begin :: StartCode -> Action
begin sc = \_ _ cont -> cont sc