Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Haskell: Improvements #2535

Merged
merged 1 commit into from
Aug 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions components/prism-haskell.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
Prism.languages.haskell = {
'comment': {
pattern: /(^|[^-!#$%*+=?&@|~.:<>^\\\/])(?:--[^-!#$%*+=?&@|~.:<>^\\\/].*|{-[\s\S]*?-})/m,
pattern: /(^|[^-!#$%*+=?&@|~.:<>^\\\/])(?:--(?:(?=.)[^-!#$%*+=?&@|~.:<>^\\\/].*|$)|{-[\s\S]*?-})/m,
lookbehind: true
},
'char': /'(?:[^\\']|\\(?:[abfnrtv\\"'&]|\^[A-Z@[\]^_]|NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS|US|SP|DEL|\d+|o[0-7]+|x[0-9a-fA-F]+))'/,
'char': {
pattern: /'(?:[^\\']|\\(?:[abfnrtv\\"'&]|\^[A-Z@[\]^_]|NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS|US|SP|DEL|\d+|o[0-7]+|x[0-9a-fA-F]+))'/,
alias: 'string'
},
'string': {
pattern: /"(?:[^\\"]|\\(?:[abfnrtv\\"'&]|\^[A-Z@[\]^_]|NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS|US|SP|DEL|\d+|o[0-7]+|x[0-9a-fA-F]+)|\\\s+\\)*"/,
pattern: /"(?:[^\\"]|\\(?:\S|\s+\\))*"/,
greedy: true
},
'keyword': /\b(?:case|class|data|deriving|do|else|if|in|infixl|infixr|instance|let|module|newtype|of|primitive|then|type|where)\b/,
'import_statement': {
'import-statement': {
// The imported or hidden names are not included in this import
// statement. This is because we want to highlight those exactly like
// we do for the names in the program.
pattern: /((?:\r?\n|\r|^)\s*)import\s+(?:qualified\s+)?(?:[A-Z][\w']*)(?:\.[A-Z][\w']*)*(?:\s+as\s+(?:[A-Z][_a-zA-Z0-9']*)(?:\.[A-Z][\w']*)*)?(?:\s+hiding\b)?/m,
pattern: /(^\s*)import\s+(?:qualified\s+)?(?:[A-Z][\w']*)(?:\.[A-Z][\w']*)*(?:\s+as\s+(?:[A-Z][\w']*)(?:\.[A-Z][\w']*)*)?(?:\s+hiding\b)?/m,
lookbehind: true,
inside: {
'keyword': /\b(?:import|qualified|as|hiding)\b/
Expand Down
2 changes: 1 addition & 1 deletion components/prism-haskell.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions tests/languages/haskell/comment_feature.test
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
--
-- foo
{- foo
bar -}
{--}

----------------------------------------------------

[
["comment", "--"],
["comment", "-- foo"],
["comment", "{- foo\r\nbar -}"]
["comment", "{- foo\r\nbar -}"],
["comment", "{--}"]
]

----------------------------------------------------

Checks for single-line and multi-line comments.
Checks for single-line and multi-line comments.
10 changes: 5 additions & 5 deletions tests/languages/haskell/import_statement_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ import Foo.Bar as Foo.Baz hiding
----------------------------------------------------

[
["import_statement", [
["import-statement", [
["keyword", "import"],
" Foo"
]],
["import_statement", [
["import-statement", [
["keyword", "import"],
["keyword", "qualified"],
" Foobar"
]],
["import_statement", [
["import-statement", [
["keyword", "import"],
" Foo_42.Bar ",
["keyword", "as"],
" Foobar"
]],
["import_statement", [
["import-statement", [
["keyword", "import"],
" Foo.Bar ",
["keyword", "as"],
Expand All @@ -32,4 +32,4 @@ import Foo.Bar as Foo.Baz hiding

----------------------------------------------------

Checks for import statement.
Checks for import statement.