summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-01-28 23:28:32 +0100
committertomsmeding <tom.smeding@gmail.com>2017-01-28 23:32:17 +0100
commite06b4824c381d10d06f73c7bbc5a65a285eda30b (patch)
treedc42b17dfeb0167d24d092b0909cd07c33bd8118
parent8ed3b8933aa41626664d8577d598526cf1b7b66b (diff)
Fix string parsing
-rw-r--r--parser.hs7
1 files 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'