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

Commit 372ed98

Browse files
committed
Avoid rolling our own string literal parser.
🎩 @patrickt.
1 parent 78bd32e commit 372ed98

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,8 @@ lit = let x `given` n = x <$ reserved n in choice
110110
, Core.bool False `given` "#false"
111111
, Core.unit `given` "#unit"
112112
, record
113-
, token (between (string "\"") (string "\"") (Core.string . fromString <$> many (escape <|> (noneOf "\"" <?> "non-escaped character"))))
113+
, Core.string <$> stringLiteral
114114
] <?> "literal"
115-
where escape = char '\\' *> choice
116-
[ '"' <$ string "\""
117-
, '\n' <$ string "n"
118-
, '\r' <$ string "r"
119-
, '\t' <$ string "t"
120-
] <?> "escape sequence"
121115

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

0 commit comments

Comments
 (0)