[Git][ghc/ghc][master] Accumulate Haddock comments in P (#17544, #17561, #8944)

Ben Gamari gitlab at gitlab.haskell.org
Tue Jul 21 18:50:11 UTC 2020



Ben Gamari pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
19e80b9a by Vladislav Zavialov at 2020-07-21T14:50:01-04:00
Accumulate Haddock comments in P (#17544, #17561, #8944)

Haddock comments are, first and foremost, comments. It's very annoying
to incorporate them into the grammar. We can take advantage of an
important property: adding a Haddock comment does not change the parse
tree in any way other than wrapping some nodes in HsDocTy and the like
(and if it does, that's a bug).

This patch implements the following:

* Accumulate Haddock comments with their locations in the P monad.
  This is handled in the lexer.

* After parsing, do a pass over the AST to associate Haddock comments
  with AST nodes using location info.

* Report the leftover comments to the user as a warning (-Winvalid-haddock).

- - - - -


23 changed files:

- compiler/GHC/Driver/Backpack.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Hs.hs
- compiler/GHC/Hs/Decls.hs
- compiler/GHC/Hs/Doc.hs
- compiler/GHC/Hs/Stats.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/Lexer.x
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Parser/PostProcess/Haddock.hs
- compiler/GHC/Tc/Module.hs
- compiler/GHC/ThToHs.hs
- compiler/GHC/Types/SrcLoc.hs
- compiler/GHC/Utils/Misc.hs
- docs/users_guide/8.12.1-notes.rst
- docs/users_guide/using-warnings.rst
- testsuite/tests/ghc-api/T11579.hs
- testsuite/tests/ghc-api/T11579.stdout
- testsuite/tests/ghc-api/annotations/comments.stdout
- testsuite/tests/haddock/should_compile_flag_haddock/T11768.hs
- testsuite/tests/haddock/should_compile_flag_haddock/T11768.stderr
- + testsuite/tests/haddock/should_compile_flag_haddock/T17544.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/19e80b9af252eee760dc047765a9930ef00067ec

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/19e80b9af252eee760dc047765a9930ef00067ec
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/20200721/f7157cef/attachment-0001.html>


More information about the ghc-commits mailing list