diff options
Diffstat (limited to 'src/Parser.hs')
-rw-r--r-- | src/Parser.hs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Parser.hs b/src/Parser.hs index 1d889d3..4237db7 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -73,9 +73,16 @@ parseNumeral = do number :: Parser Integer number = ap sign nat +specialEscape :: Parser Char +specialEscape = + choice (zipWith (\c r -> r <$ char c) "bnfrt\\\"/" "\b\n\f\r\t\\\"/") + parseString :: Parser Expression parseString = do - str <- between (char '\"') (char '\"') (some $ satisfy (`notElem` "\"\\")) + str <- between + (char '\"') + (char '\"') + (some $ (char '\\' *> specialEscape) <|> (satisfy (`notElem` "\"\\"))) pure (stringToExpression str) <?> "string" parseChar :: Parser Expression |