diff options
author | tomsmeding <tom.smeding@gmail.com> | 2017-01-28 23:28:32 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2017-01-28 23:32:17 +0100 |
commit | e06b4824c381d10d06f73c7bbc5a65a285eda30b (patch) | |
tree | dc42b17dfeb0167d24d092b0909cd07c33bd8118 | |
parent | 8ed3b8933aa41626664d8577d598526cf1b7b66b (diff) |
Fix string parsing
-rw-r--r-- | parser.hs | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -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' |