[Git][ghc/ghc][master] Implement MultilineStrings (#24390)
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Sat Aug 3 09:59:30 UTC 2024
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
66e7f57d by Brandon Chinn at 2024-08-01T21:50:58-07:00
Implement MultilineStrings (#24390)
This commit adds support for multiline strings, proposed at
https://github.com/ghc-proposals/ghc-proposals/pull/569.
Multiline strings can now be written as:
myString =
"""
this is a
multiline string
"""
The multiline string will have leading indentation stripped away.
Full details of this post-processing may be found at the new
GHC.Parser.String module.
In order to cleanly implement this and maximize reusability, I
broke out the lexing logic for strings out of Lexer.x into a
new GHC.Parser.String module, which lexes strings with any
provided "get next character" function. This also gave us the
opportunity to clean up this logic, and even optimize it a bit.
With this change, parsing string literals now takes 25% less
time and 25% less space.
- - - - -
30 changed files:
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Hs/Lit.hs
- compiler/GHC/Hs/Syn/Type.hs
- compiler/GHC/HsToCore/Match/Literal.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/CharClass.hs
- compiler/GHC/Parser/Lexer.x
- + compiler/GHC/Parser/String.hs
- compiler/GHC/Rename/Expr.hs
- compiler/Language/Haskell/Syntax/Extension.hs
- compiler/Language/Haskell/Syntax/Lit.hs
- compiler/ghc.cabal.in
- docs/users_guide/9.12.1-notes.rst
- docs/users_guide/exts/literals.rst
- + docs/users_guide/exts/multiline_strings.rst
- libraries/ghc-internal/src/GHC/Internal/LanguageExtensions.hs
- testsuite/tests/count-deps/CountDepsParser.stdout
- testsuite/tests/driver/T4437.hs
- testsuite/tests/interface-stability/template-haskell-exports.stdout
- + testsuite/tests/parser/should_fail/MultilineStringsError.hs
- + testsuite/tests/parser/should_fail/MultilineStringsError.stderr
- + testsuite/tests/parser/should_fail/MultilineStringsInnerTab.hs
- + testsuite/tests/parser/should_fail/MultilineStringsInnerTab.stderr
- + testsuite/tests/parser/should_fail/MultilineStringsSmartQuotes.hs
- + testsuite/tests/parser/should_fail/MultilineStringsSmartQuotes.stderr
- testsuite/tests/parser/should_fail/all.T
- + testsuite/tests/parser/should_run/MultilineStrings.hs
- + testsuite/tests/parser/should_run/MultilineStrings.stdout
- + testsuite/tests/parser/should_run/MultilineStringsOverloaded.hs
- + testsuite/tests/parser/should_run/MultilineStringsOverloaded.stdout
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/66e7f57d0fa2fdc87f7ab8b14d530eda7111ac19
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/66e7f57d0fa2fdc87f7ab8b14d530eda7111ac19
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240803/01a05711/attachment.html>
More information about the ghc-commits
mailing list