Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 0254bc9

Browse files
committed
Parse more escape sequences.
1 parent f10cbb2 commit 0254bc9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

semantic-core/src/Data/Core/Parser.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,14 @@ lit = let x `given` n = x <$ reserved n in choice
109109
, Core.bool False `given` "#false"
110110
, Core.unit `given` "#unit"
111111
, record
112-
, between (string "\"") (string "\"") (Core.string . fromString <$> many ('"' <$ string "\\\"" <|> noneOf "\""))
112+
, between (string "\"") (string "\"") (Core.string . fromString <$> many (escape <|> (noneOf "\"" <?> "non-escaped character")))
113113
] <?> "literal"
114+
where escape = char '\\' *> choice
115+
[ '"' <$ string "\""
116+
, '\n' <$ string "n"
117+
, '\r' <$ string "r"
118+
, '\t' <$ string "t"
119+
] <?> "escape sequence"
114120

115121
record :: (TokenParsing m, Monad m) => m (Term Core User)
116122
record = Core.record <$ reserved "#record" <*> braces (sepEndBy ((,) <$> identifier <* symbolic ':' <*> expr) comma)

0 commit comments

Comments
 (0)