1
1
mirror of https://github.com/github/semantic.git synced 2024-12-25 16:02:43 +03:00

Avoid rolling our own string literal parser.

🎩 @patrickt.
This commit is contained in:
Rob Rix 2019-08-06 12:25:05 -04:00
parent 78bd32e0b0
commit 372ed98b5e
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -110,14 +110,8 @@ lit = let x `given` n = x <$ reserved n in choice
, Core.bool False `given` "#false"
, Core.unit `given` "#unit"
, record
, token (between (string "\"") (string "\"") (Core.string . fromString <$> many (escape <|> (noneOf "\"" <?> "non-escaped character"))))
, Core.string <$> stringLiteral
] <?> "literal"
where escape = char '\\' *> choice
[ '"' <$ string "\""
, '\n' <$ string "n"
, '\r' <$ string "r"
, '\t' <$ string "t"
] <?> "escape sequence"
record :: (TokenParsing m, Monad m) => m (Term Core User)
record = Core.record <$ reserved "#record" <*> braces (sepEndBy ((,) <$> identifier <* symbolic ':' <*> expr) comma)