]> git.rmz.io Git - my-scheme.git/commitdiff
Support escaped quotes
authorSamir Benmendil <me@rmz.io>
Sat, 20 Jan 2018 22:32:20 +0000 (22:32 +0000)
committerSamir Benmendil <me@rmz.io>
Sat, 20 Jan 2018 22:32:50 +0000 (22:32 +0000)
`innerChar` matches a char that is not a backslash or a quote. If it is
either, it will match a backslash, capture a following quote and lift a
quote char into the `innerChar` monad.

This will not support anything other than quote after the backslash char.

app/Main.hs

index cea4c9b2f5e9f08230d49f837338d1e9cce484a7..0c0d29c7a4acf3351624522b2e96080c4b4c1fc5 100644 (file)
@@ -22,7 +22,10 @@ parseString = do char '"'
                  x <- many innerChar
                  char '"'
                  return $ String x
-              where innerChar = noneOf "\""
+              where innerChar = noneOf ['\\', '\"'] <|> escapeChar
+                    escapeChar = do char '\\'
+                                    c <- oneOf "\""
+                                    return $ '\"'
 
 parseAtom :: Parser LispVal
 parseAtom = do