[Git][ghc/ghc][wip/haddock-accum] Accumulate Haddock comments in P (#17544, #17561, #8944)

Vladislav Zavialov gitlab at gitlab.haskell.org
Wed Jul 1 15:56:36 UTC 2020



Vladislav Zavialov pushed to branch wip/haddock-accum at Glasgow Haskell Compiler / GHC


Commits:
1c26dc4c by Vladislav Zavialov at 2020-07-01T18:56:09+03: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).

- - - - -


22 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/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/1c26dc4caab798d9e1b70782841276e7702e76c3

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1c26dc4caab798d9e1b70782841276e7702e76c3
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/20200701/91a8ebb9/attachment.html>


More information about the ghc-commits mailing list