From: simonpj Date: Wed, 28 Aug 2002 14:30:12 +0000 (+0000) Subject: [project @ 2002-08-28 14:30:12 by simonpj] X-Git-Tag: nhc98-1-18-release~900 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=9911c1f1358df059c6694c31a5b2452a35c8d748;p=haskell-directory.git [project @ 2002-08-28 14:30:12 by simonpj] Fix a lexing bug: "\SOH" could mean "\SO" followed by "H" or "\SOH". The Report specifies the latter. MERGE TO STABLE --- diff --git a/Text/Read/Lex.hs b/Text/Read/Lex.hs index 01ca6ac..e9b7635 100644 --- a/Text/Read/Lex.hs +++ b/Text/Read/Lex.hs @@ -217,8 +217,14 @@ lexChar = lexAscii = do choice - [ string "NUL" >> return '\NUL' - , string "SOH" >> return '\SOH' + [ do { string "SO" ; s <- look; + case s of + 'H' : _ -> do { get ; return '\SOH' } + other -> return '\SO' + } + -- \SO and \SOH need maximal-munch treatment + -- See the Haskell report Sect 2.6 + , string "NUL" >> return '\NUL' , string "STX" >> return '\STX' , string "ETX" >> return '\ETX' , string "EOT" >> return '\EOT' @@ -231,7 +237,6 @@ lexChar = , string "VT" >> return '\VT' , string "FF" >> return '\FF' , string "CR" >> return '\CR' - , string "SO" >> return '\SO' , string "SI" >> return '\SI' , string "DLE" >> return '\DLE' , string "DC1" >> return '\DC1'