tfausak / purple-yolk

:hatching_chick: A Haskell IDE for Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=taylorfausak.purple-yolk
MIT License
26 stars 2 forks source link

Line comments misidentified #9

Closed tfausak closed 3 years ago

tfausak commented 4 years ago

Line comments in Haskell are complicated. They're made up of at least two hyphens in a row. Sounds easy enough. But they can't form a valid lexeme. In other words, --- is a comment, but <--- and ---> aren't. Purple Yolk doesn't currently handle this correctly:

image

I'm curious to see how GitHub's syntax highlighter handles this:

are these comments?
--    yes
--|   no
|--   no
---   yes
---|  shouldn't be
|---  shouldn't be
tfausak commented 4 years ago

Oops, I meant to link the report: https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-170002.3

An ordinary comment begins with a sequence of two or more consecutive dashes (e.g. --) and extends to the following newline. The sequence of dashes must not form part of a legal lexeme. For example, “-->” or “|--” do not begin a comment, because both of these are legal lexemes; however “--foo” does start a comment.

tfausak commented 4 years ago

https://github.com/tfausak/purple-yolk/blob/3041fe83de5f63e2e2a37fb4e792e332cbc3ad6e/grammars/haskell-grammar.json#L56-L59