From e06b4824c381d10d06f73c7bbc5a65a285eda30b Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sat, 28 Jan 2017 23:28:32 +0100 Subject: Fix string parsing --- parser.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/parser.hs b/parser.hs index f488762..46bd3d0 100644 --- a/parser.hs +++ b/parser.hs @@ -206,14 +206,15 @@ pInteger = (read <$> many1 (satisfy isDigit)) << pWhiteComment pString :: Parser String pString = do void $ char '"' - s <- many (pEscape <|> anyChar) + s <- many (pEscape <|> satisfy (/='"')) symbol "\"" return s where pEscape :: Parser Char - pEscape = char '\\' >> (pEscapeN <|> pEscapeR <|> pEscapeT <|> pEscapeHex) + pEscape = char '\\' >> (pEscapeQuote <|> pEscapeN <|> pEscapeR <|> pEscapeT <|> pEscapeHex) - pEscapeN, pEscapeR, pEscapeT :: Parser Char + pEscapeQuote, pEscapeN, pEscapeR, pEscapeT :: Parser Char + pEscapeQuote = '"' <$ char '"' pEscapeN = '\n' <$ char 'n' pEscapeR = '\r' <$ char 'r' pEscapeT = '\t' <$ char 't' -- cgit v1.2.3-70-g09d2