Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,249
    • Issues 5,249
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 573
    • Merge requests 573
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #17544
Closed
Open
Issue created Dec 04, 2019 by Vladislav Zavialov@int-indexDeveloper

Parse Haddock comments outside of Parser.y

My goal is to make Parser.y simpler.

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).

Here's the design I propose instead:

  1. Accumulate Haddock comments with their locations in the P monad. This logic will be very easy to add in the lexer.
  2. After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info.
  3. Report the leftover comments to the user as a warning or an error.

This means the happy grammar won't even have the notion of a Haddock comment. Also, it is conceivable we could move the logic of associating comments with AST nodes from GHC to Haddock itself.

Edited Dec 04, 2019 by Vladislav Zavialov
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking