aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Parser.hs
diff options
context:
space:
mode:
authorMarvin Borner2022-08-10 22:24:34 +0200
committerMarvin Borner2022-08-10 22:24:34 +0200
commitb3cf49974e8af4e35ffc01fbe2f8e181d38de03a (patch)
treec66d64154439b87d97b57a4b4f146c344b596eff /src/Parser.hs
parent792534b3888bc1b9c33047f1c312c4e17a720885 (diff)
Extestation and humanification
Diffstat (limited to 'src/Parser.hs')
-rw-r--r--src/Parser.hs9
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