mirror of
https://github.com/mrkkrp/megaparsec.git
synced 2024-12-25 09:12:29 +03:00
parent
dd2386aafc
commit
86cca77cf5
@ -361,6 +361,14 @@ lineFold sc action =
|
||||
-- string literals:
|
||||
--
|
||||
-- > stringLiteral = char '"' >> manyTill L.charLiteral (char '"')
|
||||
--
|
||||
-- If you want to write @stringLiteral@ that adheres to the Haskell report
|
||||
-- though, you'll need to take care of the @\\&@ combination which is not a
|
||||
-- character, but can be used to separate characters (as in @\"\\291\\&4\"@
|
||||
-- which is two characters long):
|
||||
--
|
||||
-- > stringLiteral = catMaybes <$> (char '"' >> manyTill ch (char '"'))
|
||||
-- > where ch = (Just <$> L.charLiteral) <|> (Nothing <$ string "\\&")
|
||||
|
||||
charLiteral :: (MonadParsec e s m, Token s ~ Char) => m Char
|
||||
charLiteral = label "literal character" $ do
|
||||
|
Loading…
Reference in New Issue
Block a user