diff options
author | Marvin Borner | 2022-08-10 22:24:34 +0200 |
---|---|---|
committer | Marvin Borner | 2022-08-10 22:24:34 +0200 |
commit | b3cf49974e8af4e35ffc01fbe2f8e181d38de03a (patch) | |
tree | c66d64154439b87d97b57a4b4f146c344b596eff /src/Parser.hs | |
parent | 792534b3888bc1b9c33047f1c312c4e17a720885 (diff) |
Extestation and humanification
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 |