From 9911c1f1358df059c6694c31a5b2452a35c8d748 Mon Sep 17 00:00:00 2001 From: simonpj Date: Wed, 28 Aug 2002 14:30:12 +0000 Subject: [PATCH] [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 --- Text/Read/Lex.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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' -- 1.7.10.4