language-haskell icon indicating copy to clipboard operation
language-haskell copied to clipboard

Repeated Haskell-style comments in Happy quotations are treated as comments

Open typedrat opened this issue 2 years ago • 3 comments

To take a few lines out of GHC's Parser.y (because it's where I'm facing this error), consider the following code:

 '{-# INLINE'             { L _ (ITinline_prag _ _ _) } -- INLINE or INLINABLE
 '{-# SPECIALISE'         { L _ (ITspec_prag _) }
 '{-# SPECIALISE_INLINE'  { L _ (ITspec_inline_prag _ _) }

While the syntax highlighting continues correctly for the line containing '{-# INLINE', the subsequent opening comment is interpreted as an actual comment, rather than as the use of the syntax within a literal token, and leads to the rest of the file being treated as a comment.

typedrat avatar Mar 05 '22 20:03 typedrat

I don't think this is (easily) fixable, because this is not Haskell syntax, but Happy syntax. It is outside the scope of the Haskell syntax highlighting to also fully support Happy. It probably is possible but it probably makes more sense to create an own Happy parser file that parses the Happy part of the syntax and embeds the Haskell highlighting for the contents of the Haskell blocks.

I do not have time to work on this but I'd be happy to merge a PR that adds this feature.

JustusAdam avatar Mar 14 '22 16:03 JustusAdam

Actually I just realized that someone added support for Happy that is unreleased. I will try to get a new release out as soon as possible, please let me know if the update fixes this issue for you.

JustusAdam avatar Mar 14 '22 16:03 JustusAdam

I don't think the current Happy grammar handles the lines in the OP, unfortunately.

sheaf avatar Mar 14 '22 16:03 sheaf