Skip to content

Commit e023044

Browse files
Haskell: Improvements (#2535)
1 parent c51abab commit e023044

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

components/prism-haskell.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
Prism.languages.haskell = {
22
'comment': {
3-
pattern: /(^|[^-!#$%*+=?&@|~.:<>^\\\/])(?:--[^-!#$%*+=?&@|~.:<>^\\\/].*|{-[\s\S]*?-})/m,
3+
pattern: /(^|[^-!#$%*+=?&@|~.:<>^\\\/])(?:--(?:(?=.)[^-!#$%*+=?&@|~.:<>^\\\/].*|$)|{-[\s\S]*?-})/m,
44
lookbehind: true
55
},
6-
'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]+))'/,
6+
'char': {
7+
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]+))'/,
8+
alias: 'string'
9+
},
710
'string': {
8-
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+\\)*"/,
11+
pattern: /"(?:[^\\"]|\\(?:\S|\s+\\))*"/,
912
greedy: true
1013
},
1114
'keyword': /\b(?:case|class|data|deriving|do|else|if|in|infixl|infixr|instance|let|module|newtype|of|primitive|then|type|where)\b/,
12-
'import_statement': {
15+
'import-statement': {
1316
// The imported or hidden names are not included in this import
1417
// statement. This is because we want to highlight those exactly like
1518
// we do for the names in the program.
16-
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,
19+
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,
1720
lookbehind: true,
1821
inside: {
1922
'keyword': /\b(?:import|qualified|as|hiding)\b/

components/prism-haskell.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1+
--
12
-- foo
23
{- foo
34
bar -}
5+
{--}
46

57
----------------------------------------------------
68

79
[
10+
["comment", "--"],
811
["comment", "-- foo"],
9-
["comment", "{- foo\r\nbar -}"]
12+
["comment", "{- foo\r\nbar -}"],
13+
["comment", "{--}"]
1014
]
1115

1216
----------------------------------------------------
1317

14-
Checks for single-line and multi-line comments.
18+
Checks for single-line and multi-line comments.

tests/languages/haskell/import_statement_feature.test

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@ import Foo.Bar as Foo.Baz hiding
66
----------------------------------------------------
77

88
[
9-
["import_statement", [
9+
["import-statement", [
1010
["keyword", "import"],
1111
" Foo"
1212
]],
13-
["import_statement", [
13+
["import-statement", [
1414
["keyword", "import"],
1515
["keyword", "qualified"],
1616
" Foobar"
1717
]],
18-
["import_statement", [
18+
["import-statement", [
1919
["keyword", "import"],
2020
" Foo_42.Bar ",
2121
["keyword", "as"],
2222
" Foobar"
2323
]],
24-
["import_statement", [
24+
["import-statement", [
2525
["keyword", "import"],
2626
" Foo.Bar ",
2727
["keyword", "as"],
@@ -32,4 +32,4 @@ import Foo.Bar as Foo.Baz hiding
3232

3333
----------------------------------------------------
3434

35-
Checks for import statement.
35+
Checks for import statement.

0 commit comments

Comments
 (0)