summaryrefslogtreecommitdiff
path: root/libraries/base/Text
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/base/Text')
-rw-r--r--libraries/base/Text/Read/Lex.hs11
1 files changed, 10 insertions, 1 deletions
diff --git a/libraries/base/Text/Read/Lex.hs b/libraries/base/Text/Read/Lex.hs
index 7054be9d79..d0d39c6648 100644
--- a/libraries/base/Text/Read/Lex.hs
+++ b/libraries/base/Text/Read/Lex.hs
@@ -253,7 +253,16 @@ lexLitChar =
return (Char c)
lexChar :: ReadP Char
-lexChar = do { (c,_) <- lexCharE; return c }
+lexChar = do { (c,_) <- lexCharE; consumeEmpties; return c }
+ where
+ -- Consumes the string "\&" repeatedly and greedily (will only produce one match)
+ consumeEmpties :: ReadP ()
+ consumeEmpties = do
+ rest <- look
+ case rest of
+ ('\\':'&':_) -> string "\\&" >> consumeEmpties
+ _ -> return ()
+
lexCharE :: ReadP (Char, Bool) -- "escaped or not"?
lexCharE =