stil4m/elm-syntax

Collect documentation comments for declarations while parsing

Closed this issue · 2 comments

Currently, all comments are collected in the state. This includes -- xyz and {- xyz -} comments, but also {-| xyz -} comments that are used for declaration comments (top-level declarations only, it's a syntax error anywhere else, probably worth turning into a parsing error).

Then, in the post-processing done in Elm.Processing, we get the list of comments from the file, then we loop through the declarations and attach the comment to the declaration. This is wasteful, and we should be able to get rid of this post-processing step.

For context, removing this post-processing step was the main purpose for the pratt-parser branch, because re-balancing the tree based around the use of operators was also done here. Now that that is gone, I think we should do the next step. And at that point, I hope we can see a performance improvement over the non-pratt-parser version.

Note: port declarations can't have a documentation comment in the current v7 API, so they should be ignored. We'll want to do that later in the v8 branch where that field has been added.

cc @jiegillet I already had a go at it but was unsuccessful so far. Would you like to have a look at this?

With pleasure :)

Fixed in #219