We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 488948e commit 6dc17e1Copy full SHA for 6dc17e1
src/CodeGen/SExpr.hs
@@ -37,7 +37,16 @@ prettySexp t = flatPrint printer . toSexp t
37
ANode kw -> kw
38
AInt i -> pack $ show i
39
ABool b -> if b then "true" else "false"
40
- AString str -> pack $ show str
+ AString str -> pack $ quote str
41
+
42
+ -- wraps a string between double quotes, and escapes it
43
+ -- NOTE: there probably never are double quotes in the string, but regardless
44
+ quote :: String -> String
45
+ quote s = "\"" <> escape s <> "\""
46
+ where
47
+ escape [] = []
48
+ escape ('"':cs) = "\\\"" <> escape cs
49
+ escape (c :cs) = c : escape cs
50
51
52
class ToSexp t a where
0 commit comments