diff --git a/Text/Megaparsec/Lexer.hs b/Text/Megaparsec/Lexer.hs index e54cc09..ff383d0 100644 --- a/Text/Megaparsec/Lexer.hs +++ b/Text/Megaparsec/Lexer.hs @@ -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