From f6e6c8d8ac32bdba4c542c41273f563ae8d93891 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Tue, 22 Dec 2020 20:43:39 +0100 Subject: [PATCH 001/178] [Haskell] Fix comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #2670 According to https://www.haskell.org/onlinereport/haskell2010/haskellch10.html a comment starts with at least 2 dashes followed by `any` character but symbols with some exceptions. The relevant rules are: comment -> -- {-} [ any⟨symbol⟩ {any} ] newline symbol -> ascSymbol | uniSymbol⟨special|_|"|'⟩ special -> ( | ) | , | ; | [ | ] | ` | { | } ascSymbol -> ! | # | $ | % | & | ⋆ | + | . | / | < | = | > | ? | @ | \ | ^ | | | - | ~ | : uniSymbol -> any Unicode symbol or punctuation With: any -> graphic | space | tab graphic -> small | large | symbol | digit | special | " | ' we can say: comment -> -- {-} [ space | tab | small | large | digit | special | " | ' {any} ] newline This simplified pattern is implemented in this commit. Additionally `(--)` and `(---)` are excluded from infix operators. --- Haskell/Haskell.sublime-syntax | 14 ++--- Haskell/syntax_test_haskell.hs | 94 ++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 9 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index dade44762f..3eeeae672e 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -13,7 +13,7 @@ variables: # such as $%^&*. operator_char: '[*|!%&$@#?~+:\-.=\\]' operator_infix: '{{operator_char}}+' - operator_parens: '(?:{{operator_infix}}|,+)' + operator_parens: '(?:(?!--+\)){{operator_infix}}|,+)' module_name: (?:[A-Z][A-Za-z._']*) escape_chars: |- (?x:NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI @@ -329,14 +329,10 @@ contexts: scope: meta.name.haskell comment: - # As of build 4079 the [:punct:] class is missing some ASCII chars that - # Unicode considers part of the Symbol category. - - match: '--(?![[:punct:]!-/:-@\[-`{-~])' - scope: punctuation.definition.comment.haskell - push: - - meta_scope: comment.line.double-dash.haskell - - match: $\n? - pop: true + - match: '(--+)(?:[ \t\w"''(),;\[\]`{}].*)?$\n?' + scope: comment.line.double-dash.haskell + captures: + 1: punctuation.definition.comment.haskell - include: block_comment block_comment: diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 170c341b52..4187097675 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -42,6 +42,85 @@ -- ^^ punctuation.definition.comment.end.haskell -- ^ - comment.block.haskell + +-- COMMENTS STARTING WITH SPECIAL SYMBOL CHARS + + -- +-- ^^^ comment + --_ +-- ^^^ comment + --" +-- ^^^ comment + --' +-- ^^^ comment + --( +-- ^^^ comment + --) +-- ^^^ comment + --, +-- ^^^ comment + --- +-- ^^^ comment + --; +-- ^^^ comment + --[ +-- ^^^ comment + --] +-- ^^^ comment + --` +-- ^^^ comment + --{ +-- ^^^ comment + --} +-- ^^^ comment + + +-- NO COMMENTS + + --! +-- ^^^ - comment + --# +-- ^^^ - comment + --$ +-- ^^^ - comment + --% +-- ^^^ - comment + --& +-- ^^^ - comment + --* +-- ^^^ - comment + --+ +-- ^^^ - comment + --. +-- ^^^ - comment + --. +-- ^^^ - comment + --/ +-- ^^^ - comment + --: +-- ^^^ - comment + --< +-- ^^^ - comment + --= +-- ^^^ - comment + --> +-- ^^^ - comment + --? +-- ^^^ - comment + --\ +-- ^^^ - comment + --\ +-- ^^^ - comment + --^ +-- ^^^ - comment + --| +-- ^^^ - comment + --~ +-- ^^^ - comment + --~ +-- ^^^ - comment + + --DECLARATIONS module Name where @@ -138,6 +217,21 @@ -- ^^^ variable.function.infix.haskell -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell + a a = (--) a 2 +-- ^ keyword.operator.haskell +-- ^^^^ - variable.function.infix +-- ^ punctuation.section.group.begin.haskell +-- ^^^^^^^^ comment.line.double-dash.haskell + ) +-- ^ punctuation.section.group.end.haskell + + a a = (---) a 2 +-- ^ keyword.operator.haskell +-- ^^^^^ - variable.function.infix +-- ^ punctuation.section.group.begin.haskell +-- ^^^^^^^^^ comment.line.double-dash.haskell + ) +-- ^ punctuation.section.group.end.haskell a `member` x -- ^^^^^^^^ keyword.operator.function.infix.haskell From dc7b6dab7961f53b94462b0d6488d5c8b572a876 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 23 Dec 2020 15:13:36 +0100 Subject: [PATCH 002/178] [Haskell] Fix comments in strings A comment terminates string and character literals. --- Haskell/Haskell.sublime-syntax | 18 ++++++++++++------ Haskell/syntax_test_haskell.hs | 21 +++++++++++++++++++++ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 3eeeae672e..26a49f53d8 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -7,13 +7,19 @@ file_extensions: scope: source.haskell variables: + # Comments + no_comment_ahead: '(?!{{comment_begin}})' + comment_ahead: '(?={{comment_begin}})' + comment_begin: '--+(?:{{comment_first_char}}|$)' + comment_first_char: '[ \t\w"''(),;\[\]`{}]' + # In case this regex seems overly general, # note that Haskell permits the definition of new operators # which can be nearly any string of punctuation characters, # such as $%^&*. operator_char: '[*|!%&$@#?~+:\-.=\\]' operator_infix: '{{operator_char}}+' - operator_parens: '(?:(?!--+\)){{operator_infix}}|,+)' + operator_parens: '(?:{{no_comment_ahead}}{{operator_infix}}|,+)' module_name: (?:[A-Z][A-Za-z._']*) escape_chars: |- (?x:NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI @@ -227,12 +233,12 @@ contexts: - include: pragma string: - - match: '"' + - match: \" scope: punctuation.definition.string.begin.haskell push: - meta_include_prototype: false - meta_scope: string.quoted.double.haskell - - match: $|" + - match: \"|$|{{comment_ahead}} scope: punctuation.definition.string.end.haskell pop: true - match: '{{escape_sequence}}' @@ -249,8 +255,8 @@ contexts: [\ -\[\]-~] # Basic Char | {{escape_sequence}} # Escapes ) - ([^']*) - (') + ([^']*?) + (?:(')|{{comment_ahead}}) scope: string.quoted.single.haskell captures: 1: punctuation.definition.string.begin.haskell @@ -329,7 +335,7 @@ contexts: scope: meta.name.haskell comment: - - match: '(--+)(?:[ \t\w"''(),;\[\]`{}].*)?$\n?' + - match: '(--+)(?:{{comment_first_char}}.*)?$\n?' scope: comment.line.double-dash.haskell captures: 1: punctuation.definition.comment.haskell diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 4187097675..32a3325844 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -416,6 +416,12 @@ main = do -- ^^^^ string.quoted.single.haskell -- ^ punctuation.definition.string.begin.haskell -- ^ invalid.illegal.expected-closing-quotation.haskell +-- ^ punctuation.definition.string.end.haskell + + '\'' +-- ^^^^ string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.haskell -- ^ punctuation.definition.string.end.haskell '\129x' @@ -424,6 +430,12 @@ main = do -- ^ invalid.illegal.expected-closing-quotation.haskell -- ^ punctuation.definition.string.end.haskell + 'a--' +-- ^^ string.quoted.single.haskell - comment +-- ^ punctuation.definition.string.begin.haskell +-- ^^^^ comment.line.double-dash.haskell - string +-- ^^ punctuation.definition.comment.haskell + "\o129x\NUL" -- ^^^^^^^^^^^^ string.quoted.double.haskell -- ^^^^ constant.character.escape.octal.haskell @@ -431,8 +443,17 @@ main = do -- ^ punctuation.definition.string.end.haskell -- ^^^^ constant.character.escape.haskell + "ok\"()--"'ab' +-- ^^^^^^^ string.quoted.double.haskell - comment +-- ^^^^^^^^ comment.line.double-dash.haskell - string +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.haskell +-- ^^ punctuation.definition.comment.haskell + a' = b' -- ^^ meta.name.haskell - string +-- ^ keyword.operator.haskell +-- ^^ meta.name.haskell - string -- Infix operators in context From 7ccb72c709913bdb408ce8056b8d641de8255dcc Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 23 Dec 2020 15:15:10 +0100 Subject: [PATCH 003/178] [Haskell] Add meta.string This commit adds `meta.string` scope to align with other syntax definitions. --- Haskell/Haskell.sublime-syntax | 4 ++-- Haskell/syntax_test_haskell.hs | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 26a49f53d8..ab7ca26916 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -237,7 +237,7 @@ contexts: scope: punctuation.definition.string.begin.haskell push: - meta_include_prototype: false - - meta_scope: string.quoted.double.haskell + - meta_scope: meta.string.haskell string.quoted.double.haskell - match: \"|$|{{comment_ahead}} scope: punctuation.definition.string.end.haskell pop: true @@ -257,7 +257,7 @@ contexts: ) ([^']*?) (?:(')|{{comment_ahead}}) - scope: string.quoted.single.haskell + scope: meta.string.haskell string.quoted.single.haskell captures: 1: punctuation.definition.string.begin.haskell 2: constant.character.escape.haskell diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 32a3325844..bedcc98568 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -413,38 +413,38 @@ main = do 'ab' --- ^^^^ string.quoted.single.haskell +-- ^^^^ meta.string.haskell string.quoted.single.haskell -- ^ punctuation.definition.string.begin.haskell -- ^ invalid.illegal.expected-closing-quotation.haskell -- ^ punctuation.definition.string.end.haskell '\'' --- ^^^^ string.quoted.single.haskell +-- ^^^^ meta.string.haskell string.quoted.single.haskell -- ^ punctuation.definition.string.begin.haskell -- ^^ constant.character.escape.haskell -- ^ punctuation.definition.string.end.haskell '\129x' --- ^^^^ string.quoted.single.haskell +-- ^^^^ meta.string.haskell string.quoted.single.haskell -- ^^^^ constant.character.escape.decimal.haskell -- ^ invalid.illegal.expected-closing-quotation.haskell -- ^ punctuation.definition.string.end.haskell 'a--' --- ^^ string.quoted.single.haskell - comment +-- ^^ meta.string.haskell string.quoted.single.haskell - comment -- ^ punctuation.definition.string.begin.haskell -- ^^^^ comment.line.double-dash.haskell - string -- ^^ punctuation.definition.comment.haskell "\o129x\NUL" --- ^^^^^^^^^^^^ string.quoted.double.haskell +-- ^^^^^^^^^^^^ meta.string.haskell string.quoted.double.haskell -- ^^^^ constant.character.escape.octal.haskell -- ^ - constant -- ^ punctuation.definition.string.end.haskell -- ^^^^ constant.character.escape.haskell "ok\"()--"'ab' --- ^^^^^^^ string.quoted.double.haskell - comment +-- ^^^^^^^ meta.string.haskell string.quoted.double.haskell - comment -- ^^^^^^^^ comment.line.double-dash.haskell - string -- ^ punctuation.definition.string.begin.haskell -- ^^ constant.character.escape.haskell From 2a56101c5805bde205a017e8411442ce650216c3 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 23 Dec 2020 15:18:45 +0100 Subject: [PATCH 004/178] [Haskell] Scope character literals This commit scopes single quoted literal characters `constant.character.literal` to align with recent changes with C#, ... . That's not directly related with the issue to fix in the PR but test cases would cause merge conflicts otherwise. --- Haskell/Haskell.sublime-syntax | 17 +++++++++-------- Haskell/syntax_test_haskell.hs | 2 ++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index ab7ca26916..c4c7f682ee 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -252,7 +252,7 @@ contexts: (?x) (') (?: - [\ -\[\]-~] # Basic Char + ([\ -\[\]-~]) # Basic Char | {{escape_sequence}} # Escapes ) ([^']*?) @@ -260,13 +260,14 @@ contexts: scope: meta.string.haskell string.quoted.single.haskell captures: 1: punctuation.definition.string.begin.haskell - 2: constant.character.escape.haskell - 3: constant.character.escape.decimal.haskell - 4: constant.character.escape.octal.haskell - 5: constant.character.escape.hexadecimal.haskell - 6: constant.character.escape.control.haskell - 7: invalid.illegal.expected-closing-quotation.haskell - 8: punctuation.definition.string.end.haskell + 2: constant.character.literal.haskell + 3: constant.character.escape.haskell + 4: constant.character.escape.decimal.haskell + 5: constant.character.escape.octal.haskell + 6: constant.character.escape.hexadecimal.haskell + 7: constant.character.escape.control.haskell + 8: invalid.illegal.expected-closing-quotation.haskell + 9: punctuation.definition.string.end.haskell splice: - match: '\[(?:|e|d|t|p)\|' diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index bedcc98568..670a239e2a 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -415,6 +415,7 @@ main = do 'ab' -- ^^^^ meta.string.haskell string.quoted.single.haskell -- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell -- ^ invalid.illegal.expected-closing-quotation.haskell -- ^ punctuation.definition.string.end.haskell @@ -433,6 +434,7 @@ main = do 'a--' -- ^^ meta.string.haskell string.quoted.single.haskell - comment -- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell -- ^^^^ comment.line.double-dash.haskell - string -- ^^ punctuation.definition.comment.haskell From 709f33dd7d6aa79950db395908fff22264234923 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 23 Dec 2020 15:29:18 +0100 Subject: [PATCH 005/178] [Haskell] Fix comments in imports --- Haskell/Haskell.sublime-syntax | 2 +- Haskell/syntax_test_haskell.hs | 58 ++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index c4c7f682ee..6c3e4e1377 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -372,7 +372,7 @@ contexts: - match: ',' scope: punctuation.separator.comma.haskell - include: operator_paren - - match: \(.*?\) + - match: \({{no_comment_ahead}}.*?\) comment: So named because I don't know what to call this. scope: meta.other.unknown.haskell diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 670a239e2a..c8885a5fde 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -308,6 +308,64 @@ import Data.List.Split (splitOn) -- ^ punctuation.section.group.begin.haskell -- ^^^^^^^ variable.function.haskell -- ^ punctuation.section.group.end.haskell +import Data.List.Split (()) +-- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^ keyword.control.import.haskell +-- ^^^^^^^^^^^^^^^ support.other.module.haskell +-- ^^^^ meta.declaration.exports.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^^ meta.other.unknown.haskell +-- ^ punctuation.section.group.end.haskell +import Data.List.Split (-- +-- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^ keyword.control.import.haskell +-- ^^^^^^^^^^^^^^^ support.other.module.haskell +-- ^^^^^ meta.declaration.exports.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^^^ comment.line.double-dash.haskell +-- ^^ punctuation.definition.comment.haskell + ) +-- ^ punctuation.section.group.end.haskell +import Data.List.Split (--) +-- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^ keyword.control.import.haskell +-- ^^^^^^^^^^^^^^^ support.other.module.haskell +-- ^^^^^ meta.declaration.exports.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^^^^ comment.line.double-dash.haskell +-- ^^ punctuation.definition.comment.haskell + ) +-- ^ punctuation.section.group.end.haskell +import Data.List.Split ((--)) +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^ keyword.control.import.haskell +-- ^^^^^^^^^^^^^^^ support.other.module.haskell +-- ^^^^^^^ meta.declaration.exports.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^^^^^ comment.line.double-dash.haskell +-- ^^ punctuation.definition.comment.haskell + ) +-- ^ punctuation.section.group.end.haskell +import Data.List.Split ((--]) +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^ keyword.control.import.haskell +-- ^^^^^^^^^^^^^^^ support.other.module.haskell +-- ^^^^^^^ meta.declaration.exports.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^^^^^ comment.line.double-dash.haskell +-- ^^ punctuation.definition.comment.haskell + ) +-- ^ punctuation.section.group.end.haskell +import Data.List.Split ((--") +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^ keyword.control.import.haskell +-- ^^^^^^^^^^^^^^^ support.other.module.haskell +-- ^^^^^^^ meta.declaration.exports.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^^^^^ comment.line.double-dash.haskell +-- ^^ punctuation.definition.comment.haskell + ) +-- ^ punctuation.section.group.end.haskell deriving instance FromJSON Amount -- ^^^^^^^^ keyword.declaration.data.haskell From 390ee8d72721bc7eea1fc51149cea4462d13ab47 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 23 Dec 2020 19:33:54 +0100 Subject: [PATCH 006/178] [Haskell] Fix illegal infix operator highlighting This commit addresses one issue of #2672. --- Haskell/Haskell.sublime-syntax | 2 ++ Haskell/syntax_test_haskell.hs | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 6c3e4e1377..9ae4bde655 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -203,6 +203,8 @@ contexts: captures: 1: punctuation.definition.function.begin.haskell 2: punctuation.definition.function.end.haskell + - match: (`)[^`]*?(?:(`)|{{comment_ahead}}) + scope: invalid.illegal.operator.haskell - match: '\binfix[lr]?\b' scope: keyword.operator.haskell - match: \b(\d+)(?:(\.)(\d+)([eE][-+]?\d+)?|([eE][-+]?\d+))\b diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index c8885a5fde..a8fb109306 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -242,6 +242,28 @@ -- ^ punctuation.definition.function.begin.haskell -- ^ punctuation.definition.function.end.haskell + 5 `f `7`f`"3 'ab'" +-- ^ constant.numeric.value.haskell +-- ^^^^ invalid.illegal.operator.haskell +-- ^ constant.numeric.value.haskell +-- ^^^ keyword.operator.function.infix.haskell +-- ^ punctuation.definition.function.begin.haskell +-- ^ punctuation.definition.function.end.haskell +-- ^^^^^^^^ meta.string.haskell string.quoted.double.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^^^^^ - constant - punctuation +-- ^ punctuation.definition.string.end.haskell + + a ` f` b +-- ^^^^ invalid.illegal.operator.haskell + + a `--` b +-- ^ invalid.illegal.operator.haskell +-- ^^^^^^ comment.line.double-dash.haskell + + a ` +-- ^ - keyword - operator - punctuation + -- Tests for #1320, #1880. From 4bf8b228c7d8d18fcd8d1b961c5e0d6897fc53ba Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 23 Dec 2020 22:13:27 +0100 Subject: [PATCH 007/178] [Haskell] Allow space in infix operators It appears Haskell compiler allows whitespace between backticks. It's not very obvious but it looks like the specification includes that as well. --- Haskell/Haskell.sublime-syntax | 2 +- Haskell/syntax_test_haskell.hs | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 9ae4bde655..b3580163df 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -196,7 +196,7 @@ contexts: 3: keyword.control.conditional.else.haskell operator: - - match: (`)[a-zA-Z_'.\d]+(`) + - match: (`)[ \w'.]+(`) # Haskell allows any ordinary function application (elem 4 [1..10]) # to be rewritten as an infix expression (4 `elem` [1..10])." scope: keyword.operator.function.infix.haskell diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index a8fb109306..d9d5eda51a 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -244,7 +244,9 @@ 5 `f `7`f`"3 'ab'" -- ^ constant.numeric.value.haskell --- ^^^^ invalid.illegal.operator.haskell +-- ^^^^ keyword.operator.function.infix.haskell +-- ^ punctuation.definition.function.begin.haskell +-- ^ punctuation.definition.function.end.haskell -- ^ constant.numeric.value.haskell -- ^^^ keyword.operator.function.infix.haskell -- ^ punctuation.definition.function.begin.haskell @@ -255,7 +257,9 @@ -- ^ punctuation.definition.string.end.haskell a ` f` b --- ^^^^ invalid.illegal.operator.haskell +-- ^^^^ keyword.operator.function.infix.haskell +-- ^ punctuation.definition.function.begin.haskell +-- ^ punctuation.definition.function.end.haskell a `--` b -- ^ invalid.illegal.operator.haskell From 513e00bc7f5b6048d55a3c3ee5215bd522b918d5 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 23 Dec 2020 21:31:59 +0100 Subject: [PATCH 008/178] [Haskell] Fix identifier patterns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit... 1. addresses one issue of #2672: -> Lines 8,9: the ' not highlighted as part of A According to https://www.haskell.org/onlinereport/haskell2010/haskellch10.html an identifier may contain any kind of ascii or unicode word character including the `'`, which was not implemented before this commit. varid → (small {small | large | digit | ' })⟨reservedid⟩ conid → large {small | large | digit | ' } This also means `\b` must not be used to terminate patterns as this prevents trailing `'` to be matched as part of the identifier. 2. scopes the `.` between module names `punctuation.accessor` 3. scopes the module name itself `variable.namespace` Note: Fully qualified identifiers are not scoped `meta.path` at this point. --- Haskell/Haskell.sublime-syntax | 49 ++++++++++++++++++++---------- Haskell/syntax_test_haskell.hs | 55 ++++++++++++++++++++++++++++------ 2 files changed, 79 insertions(+), 25 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index b3580163df..b9f4b3f587 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -20,7 +20,19 @@ variables: operator_char: '[*|!%&$@#?~+:\-.=\\]' operator_infix: '{{operator_char}}+' operator_parens: '(?:{{no_comment_ahead}}{{operator_infix}}|,+)' - module_name: (?:[A-Z][A-Za-z._']*) + + # Identifiers + con_id: (?:\b[[:upper:]][\w']*) + var_id: (?:\b(?!{{reserved_id}})[[:lower:]][\w']*) + reserved_id: |- + (?x: + case | class | data | default | deriving | do | else + | foreign | if | import | in | infix | infixl + | infixr | instance | let | module | newtype | of + | then | type | where | _ + )\b + + # Escaped Characters escape_chars: |- (?x: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 @@ -84,10 +96,10 @@ contexts: constant: - match: \(\) scope: constant.language.unit.haskell - - match: '\[\]' + - match: \[\] scope: constant.language.empty-list.haskell - include: number - - match: '\b[A-Z]\w*\b' + - match: '{{con_id}}' scope: constant.other.haskell number: @@ -112,7 +124,11 @@ contexts: - match: \bwhere\b scope: keyword.control.context.haskell pop: true - - match: \b{{module_name}}\b + - match: ({{con_id}})(\.) + captures: + 1: variable.namespace.haskell + 2: punctuation.accessor.dot.haskell + - match: '{{con_id}}' scope: entity.name.namespace.haskell - include: module_exports - match: \bclass\b @@ -127,9 +143,9 @@ contexts: |Eq|Ord|Read|Show|Num|Fractional|Rational|Enum|Bounded |Real|RealFrac|RealFloat|Integral|Floating)\b scope: support.class.prelude.haskell - - match: '[A-Z][A-Za-z_'']*' + - match: '{{con_id}}' scope: entity.other.inherited-class.haskell - - match: '\b[a-z][a-zA-Z0-9_'']*\b' + - match: '{{var_id}}' scope: variable.other.generic-type.haskell - match: \binstance\b scope: keyword.declaration.haskell @@ -139,7 +155,7 @@ contexts: scope: keyword.control.context.haskell pop: true - include: type_signature - - match: '^(\s*)([a-z_][a-zA-Z0-9_'']*|\(({{operator_parens}})\))\s*(::|∷)' + - match: '^(\s*)({{var_id}}|\(({{operator_parens}})\))\s*(::|∷)' captures: 2: entity.name.function.haskell 3: keyword.operator.infix.haskell @@ -156,10 +172,9 @@ contexts: - meta_scope: meta.deriving.haskell - match: \) pop: true - - match: '\b[A-Z][a-zA-Z_'']*' + - match: '{{con_id}}' scope: entity.other.inherited-class.haskell - import: - match: \bimport\b scope: keyword.control.import.haskell @@ -291,7 +306,7 @@ contexts: - match: \$\( comment: Highlight the beginning of a splice. scope: keyword.other.splice.haskell - - match: '\[[a-zA-Z0-9_'']*\|' + - match: '\[[\w'']*\|' scope: keyword.other.quasibracket.haskell push: - meta_scope: meta.other.quasiquote.haskell @@ -367,9 +382,9 @@ contexts: - match: \) scope: punctuation.section.group.end.haskell pop: true - - match: '\b[a-z][a-zA-Z_''0-9]*' + - match: '{{var_id}}' scope: variable.function.haskell - - match: '\b[A-Z][A-Za-z_''0-9]*' + - match: '{{con_id}}' scope: storage.type.haskell - match: ',' scope: punctuation.separator.comma.haskell @@ -379,8 +394,10 @@ contexts: scope: meta.other.unknown.haskell module_name: - - match: '\b{{module_name}}\b' - scope: support.other.module.haskell + - match: ({{con_id}})(\.)? + captures: + 1: variable.namespace.haskell + 2: punctuation.accessor.dot.haskell type_signature: - include: pragma @@ -388,9 +405,9 @@ contexts: scope: keyword.other.arrow.haskell - match: '(?:=>|⇒)' scope: keyword.other.big-arrow.haskell - - match: '\b[a-z][a-zA-Z0-9_'']*\b' + - match: '{{var_id}}' scope: variable.other.generic-type.haskell - - match: '\b[A-Z][a-zA-Z0-9_'']*\b' + - match: '{{con_id}}' scope: storage.type.haskell - match: \(\) scope: support.constant.unit.haskell diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index d9d5eda51a..4ab1461821 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -323,13 +323,21 @@ import qualified Data.Vector.Mutable as MutableVector -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^ keyword.control.import.haskell -- ^^^^^^^^^ keyword.control.import.haskell --- ^^^^^^^^^^^^^^^^^^^ support.other.module.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^^^ variable.namespace.haskell - punctuation -- ^^ keyword.control.import.haskell --- ^^^^^^^^^^^^^ support.other.module.haskell +-- ^^^^^^^^^^^^^ variable.namespace.haskell import Data.List.Split (splitOn) -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^ keyword.control.import.haskell --- ^^^^^^^^^^^^^^^ support.other.module.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^ variable.namespace.haskell - punctuation -- ^^^^^^^^^ meta.declaration.exports.haskell -- ^ punctuation.section.group.begin.haskell -- ^^^^^^^ variable.function.haskell @@ -337,7 +345,11 @@ import Data.List.Split (splitOn) import Data.List.Split (()) -- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^ keyword.control.import.haskell --- ^^^^^^^^^^^^^^^ support.other.module.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^ variable.namespace.haskell - punctuation -- ^^^^ meta.declaration.exports.haskell -- ^ punctuation.section.group.begin.haskell -- ^^ meta.other.unknown.haskell @@ -345,7 +357,11 @@ import Data.List.Split (()) import Data.List.Split (-- -- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^ keyword.control.import.haskell --- ^^^^^^^^^^^^^^^ support.other.module.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^ variable.namespace.haskell - punctuation -- ^^^^^ meta.declaration.exports.haskell -- ^ punctuation.section.group.begin.haskell -- ^^^ comment.line.double-dash.haskell @@ -355,7 +371,11 @@ import Data.List.Split (-- import Data.List.Split (--) -- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^ keyword.control.import.haskell --- ^^^^^^^^^^^^^^^ support.other.module.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^ variable.namespace.haskell - punctuation -- ^^^^^ meta.declaration.exports.haskell -- ^ punctuation.section.group.begin.haskell -- ^^^^ comment.line.double-dash.haskell @@ -365,7 +385,11 @@ import Data.List.Split (--) import Data.List.Split ((--)) -- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^ keyword.control.import.haskell --- ^^^^^^^^^^^^^^^ support.other.module.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^ variable.namespace.haskell - punctuation -- ^^^^^^^ meta.declaration.exports.haskell -- ^ punctuation.section.group.begin.haskell -- ^^^^^ comment.line.double-dash.haskell @@ -375,7 +399,11 @@ import Data.List.Split ((--)) import Data.List.Split ((--]) -- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^ keyword.control.import.haskell --- ^^^^^^^^^^^^^^^ support.other.module.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^ variable.namespace.haskell - punctuation -- ^^^^^^^ meta.declaration.exports.haskell -- ^ punctuation.section.group.begin.haskell -- ^^^^^ comment.line.double-dash.haskell @@ -385,7 +413,11 @@ import Data.List.Split ((--]) import Data.List.Split ((--") -- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^ keyword.control.import.haskell --- ^^^^^^^^^^^^^^^ support.other.module.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^ variable.namespace.haskell - punctuation -- ^^^^^^^ meta.declaration.exports.haskell -- ^ punctuation.section.group.begin.haskell -- ^^^^^ comment.line.double-dash.haskell @@ -536,6 +568,11 @@ main = do -- ^^ constant.character.escape.haskell -- ^^ punctuation.definition.comment.haskell + A' = A' +-- ^^ constant.other.haskell - string +-- ^ keyword.operator.haskell +-- ^^ constant.other.haskell - string + a' = b' -- ^^ meta.name.haskell - string -- ^ keyword.operator.haskell From 2e4c0befe5e3761508a570030b563e54ff769597 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 23 Dec 2020 21:44:37 +0100 Subject: [PATCH 009/178] [Haskell] Fix arrow operator in class definition This commit addresses one issue of #2672: -> Line 10: the => context operator not highlighted --- Haskell/Haskell.sublime-syntax | 15 +++++++++++---- Haskell/syntax_test_haskell.hs | 3 +++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index b9f4b3f587..d525d0c108 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -147,6 +147,7 @@ contexts: scope: entity.other.inherited-class.haskell - match: '{{var_id}}' scope: variable.other.generic-type.haskell + - include: operator_big_arrow - match: \binstance\b scope: keyword.declaration.haskell push: @@ -234,6 +235,14 @@ contexts: scope: keyword.operator.haskell - include: operator_paren + operator_arrow: + - match: '(?:->|→)' + scope: keyword.other.arrow.haskell + + operator_big_arrow: + - match: '(?:=>|⇒)' + scope: keyword.other.big-arrow.haskell + operator_paren: - match: \(({{operator_parens}})\) scope: variable.function.infix.haskell @@ -401,10 +410,8 @@ contexts: type_signature: - include: pragma - - match: '(?:->|→)' - scope: keyword.other.arrow.haskell - - match: '(?:=>|⇒)' - scope: keyword.other.big-arrow.haskell + - include: operator_arrow + - include: operator_big_arrow - match: '{{var_id}}' scope: variable.other.generic-type.haskell - match: '{{con_id}}' diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 4ab1461821..31e01c2dce 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -132,6 +132,9 @@ class (Functor t, Foldable t) => Traversable t where -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell -- ^^^^^ keyword.declaration.class.haskell +-- ^^ keyword.other.big-arrow.haskell +-- ^^^^^^^^^^^ support.class.prelude.haskell +-- ^ variable.other.generic-type.haskell -- ^^^^^ keyword.control.context.haskell {-# MINIMAL traverse | sequenceA LANGUAGE #-} -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.haskell From bc3ee6ec7edc515bd588540de5ec8a4160963b6d Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 23 Dec 2020 21:57:51 +0100 Subject: [PATCH 010/178] [Haskell] Create ident contexts This commit is to reduce duplicated patterns by moving those candidates into contexts which can be included wherever needed. --- Haskell/Haskell.sublime-syntax | 37 +++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index d525d0c108..5397d23db2 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -143,10 +143,8 @@ contexts: |Eq|Ord|Read|Show|Num|Fractional|Rational|Enum|Bounded |Real|RealFrac|RealFloat|Integral|Floating)\b scope: support.class.prelude.haskell - - match: '{{con_id}}' - scope: entity.other.inherited-class.haskell - - match: '{{var_id}}' - scope: variable.other.generic-type.haskell + - include: ident_inherited_class + - include: ident_generic_type - include: operator_big_arrow - match: \binstance\b scope: keyword.declaration.haskell @@ -173,8 +171,7 @@ contexts: - meta_scope: meta.deriving.haskell - match: \) pop: true - - match: '{{con_id}}' - scope: entity.other.inherited-class.haskell + - include: ident_inherited_class import: - match: \bimport\b @@ -361,6 +358,22 @@ contexts: - match: '[[:lower:]][^\s{{operator_char}}),\]{}]+' scope: meta.name.haskell + ident_function: + - match: '{{var_id}}' + scope: variable.function.haskell + + ident_inherited_class: + - match: '{{con_id}}' + scope: entity.other.inherited-class.haskell + + ident_generic_type: + - match: '{{var_id}}' + scope: variable.other.generic-type.haskell + + ident_type: + - match: '{{con_id}}' + scope: storage.type.haskell + comment: - match: '(--+)(?:{{comment_first_char}}.*)?$\n?' scope: comment.line.double-dash.haskell @@ -391,10 +404,8 @@ contexts: - match: \) scope: punctuation.section.group.end.haskell pop: true - - match: '{{var_id}}' - scope: variable.function.haskell - - match: '{{con_id}}' - scope: storage.type.haskell + - include: ident_function + - include: ident_type - match: ',' scope: punctuation.separator.comma.haskell - include: operator_paren @@ -412,10 +423,8 @@ contexts: - include: pragma - include: operator_arrow - include: operator_big_arrow - - match: '{{var_id}}' - scope: variable.other.generic-type.haskell - - match: '{{con_id}}' - scope: storage.type.haskell + - include: ident_generic_type + - include: ident_type - match: \(\) scope: support.constant.unit.haskell From e4e9ed5e42f9299c0c5b292f2ce2d0c9633eca57 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 23 Dec 2020 22:21:02 +0100 Subject: [PATCH 011/178] [Haskell] Highlight C-style directive keywords This commit ... 1. addresses one issue of #2672: -> Lines 3,4: directives #if and #endif not highlighted It adds a capture group to scope keywords of C-style preprocessor directives. Note: This commit doesn't modify the quite simplistic approach to match those. So don't expect much. Maybe it can be addressed once the C family has been upgraded. 2. The `keyword.other.preprocessor` scope is renamed to `keyword.directive.other`, which is the scope used by Erlang and some other recently changed syntaxes for such things. --- Haskell/Haskell.sublime-syntax | 5 +++-- Haskell/syntax_test_haskell.hs | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 5397d23db2..5a4d5a956d 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -249,10 +249,11 @@ contexts: preprocessor: # In addition to Haskell's "native" syntax, # GHC permits the C preprocessor to be run on a source file. - - match: ^\s*(#)\s*\w+ + - match: ^\s*(#)\s*(\w+) scope: meta.preprocessor.c captures: 1: punctuation.definition.preprocessor.c + 2: keyword.directive.other.c - include: pragma string: @@ -442,4 +443,4 @@ contexts: |SPECIALIZE|SPECIALISE )\b # https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#pragmas - scope: keyword.other.preprocessor.haskell + scope: keyword.directive.other.haskell diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 31e01c2dce..24116fcd09 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -139,12 +139,22 @@ {-# MINIMAL traverse | sequenceA LANGUAGE #-} -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.haskell -- ^ - meta.preprocessor.haskell --- ^^^^^^^ keyword.other.preprocessor.haskell +-- ^^^^^^^ keyword.directive.other.haskell {-# OPTIONS_HADDOCK not-home #-} -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.haskell -- ^ - meta.preprocessor.haskell --- ^^^^^^^^^^^^^^^ keyword.other.preprocessor.haskell +-- ^^^^^^^^^^^^^^^ keyword.directive.other.haskell + + #if 0 +-- ^^^ meta.preprocessor.c +-- ^ punctuation.definition.preprocessor.c +-- ^^ keyword.directive.other.c + + #endif +-- ^^^^^^ meta.preprocessor.c +-- ^ punctuation.definition.preprocessor.c +-- ^^^^^ keyword.directive.other.c -- | Map each element of a structure to an action, -- evaluate these actions from left to right, and From 38bdd9cbc8c93c42cfda5de608014c6928967fd3 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 23 Dec 2020 22:32:13 +0100 Subject: [PATCH 012/178] [Haskell] Avoid capture groups --- Haskell/Haskell.sublime-syntax | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 5a4d5a956d..0609eb4259 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -202,11 +202,12 @@ contexts: scope: keyword.control.flow.return.haskell - match: \b(?:default|otherwise)\b scope: keyword.other.haskell - - match: \b(?:(if)|(then)|(else))\b - captures: - 1: keyword.control.conditional.if.haskell - 2: keyword.control.conditional.then.haskell - 3: keyword.control.conditional.else.haskell + - match: \b(?:if)\b + scope: keyword.control.conditional.if.haskell + - match: \b(?:then)\b + scope: keyword.control.conditional.then.haskell + - match: \b(?:else)\b + scope: keyword.control.conditional.else.haskell operator: - match: (`)[ \w'.]+(`) From 45c1bb5cb5ab783ddfd9dc6aa2eb7956c256844d Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 23 Dec 2020 22:42:10 +0100 Subject: [PATCH 013/178] [Haskell] Fix word break pattern This commit replaces `\b` by `(?![\w'])` as `'` is a valid identifier character, which would otherwise be matched illegally. E.g.: `class'` is not a keyword followed by `'` but a normal identifier. --- Haskell/Haskell.sublime-settings | 4 ++ Haskell/Haskell.sublime-syntax | 68 ++++++++++++++++---------------- Haskell/syntax_test_haskell.hs | 8 ++++ 3 files changed, 47 insertions(+), 33 deletions(-) create mode 100644 Haskell/Haskell.sublime-settings diff --git a/Haskell/Haskell.sublime-settings b/Haskell/Haskell.sublime-settings new file mode 100644 index 0000000000..76c0385c00 --- /dev/null +++ b/Haskell/Haskell.sublime-settings @@ -0,0 +1,4 @@ +{ + // Default word boundaries except: ' + "word_separators": "./\\()\"-:,.;<>~!@#$%^&*|+=[]{}`~?", +} \ No newline at end of file diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 0609eb4259..4f5d7c563f 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -22,15 +22,17 @@ variables: operator_parens: '(?:{{no_comment_ahead}}{{operator_infix}}|,+)' # Identifiers - con_id: (?:\b[[:upper:]][\w']*) - var_id: (?:\b(?!{{reserved_id}})[[:lower:]][\w']*) + con_id: (?:[[:upper:]][\w']*) + var_id: (?:(?!{{reserved_id}})[[:lower:]][\w']*) reserved_id: |- (?x: case | class | data | default | deriving | do | else | foreign | if | import | in | infix | infixl | infixr | instance | let | module | newtype | of | then | type | where | _ - )\b + ){{break}} + + break: (?![\w']) # Escaped Characters escape_chars: |- @@ -103,25 +105,25 @@ contexts: scope: constant.other.haskell number: - - match: \b(0[oO])([0-7]+)\b + - match: (0[oO])([0-7]+){{break}} scope: meta.number.integer.octal.haskell captures: 1: constant.numeric.base.haskell 2: constant.numeric.value.haskell - - match: \b(0[xX])(\h+)\b + - match: (0[xX])(\h+){{break}} scope: meta.number.integer.hexadecimal.haskell captures: 1: constant.numeric.base.haskell 2: constant.numeric.value.haskell - - match: \b\d+\b + - match: \d+{{break}} scope: meta.number.integer.decimal.haskell constant.numeric.value.haskell declaration: - - match: \bmodule\b + - match: module{{break}} scope: keyword.declaration.namespace.haskell push: - meta_scope: meta.declaration.module.haskell - - match: \bwhere\b + - match: where{{break}} scope: keyword.control.context.haskell pop: true - match: ({{con_id}})(\.) @@ -131,26 +133,26 @@ contexts: - match: '{{con_id}}' scope: entity.name.namespace.haskell - include: module_exports - - match: \bclass\b + - match: class{{break}} scope: keyword.declaration.class.haskell push: - meta_scope: meta.declaration.class.haskell - - match: \bwhere\b + - match: where{{break}} scope: keyword.control.context.haskell pop: true - match: |- - \b(?x:Monad|Monadoid|Functor|Applicative|Foldableble|Traversable + (?x:Monad|Monadoid|Functor|Applicative|Foldableble|Traversable |Eq|Ord|Read|Show|Num|Fractional|Rational|Enum|Bounded - |Real|RealFrac|RealFloat|Integral|Floating)\b + |Real|RealFrac|RealFloat|Integral|Floating){{break}} scope: support.class.prelude.haskell - include: ident_inherited_class - include: ident_generic_type - include: operator_big_arrow - - match: \binstance\b + - match: instance{{break}} scope: keyword.declaration.haskell push: - meta_scope: meta.declaration.instance.haskell - - match: \bwhere\b|$ + - match: where|$ scope: keyword.control.context.haskell pop: true - include: type_signature @@ -174,39 +176,39 @@ contexts: - include: ident_inherited_class import: - - match: \bimport\b + - match: import{{break}} scope: keyword.control.import.haskell push: - meta_scope: meta.import.haskell - match: ($|;) pop: true - - match: (qualified|as|hiding) + - match: (?:qualified|as|hiding){{break}} scope: keyword.control.import.haskell - include: module_name - include: module_exports keyword: - - match: \b(?:do|in)\b + - match: (?:do|in){{break}} scope: keyword.control.context.haskell - - match: \b(?:newtype|type)\b + - match: (?:newtype|type){{break}} scope: keyword.declaration.type.haskell - - match: \b(?:data)\b + - match: (?:data){{break}} scope: keyword.declaration.data.haskell - - match: \b(?:deriving)\b + - match: (?:deriving){{break}} scope: keyword.declaration.data.haskell - - match: \b(?:case|of)\b + - match: (?:case|of){{break}} scope: keyword.control.conditional.select.haskell # the construct is commonly called "select" - - match: \b(?:let|where)\b + - match: (?:let|where){{break}} scope: keyword.declaration.variable.haskell - - match: \breturn\b + - match: (?:return){{break}} scope: keyword.control.flow.return.haskell - - match: \b(?:default|otherwise)\b + - match: (?:default|otherwise){{break}} scope: keyword.other.haskell - - match: \b(?:if)\b + - match: (?:if){{break}} scope: keyword.control.conditional.if.haskell - - match: \b(?:then)\b + - match: (?:then){{break}} scope: keyword.control.conditional.then.haskell - - match: \b(?:else)\b + - match: (?:else){{break}} scope: keyword.control.conditional.else.haskell operator: @@ -219,9 +221,9 @@ contexts: 2: punctuation.definition.function.end.haskell - match: (`)[^`]*?(?:(`)|{{comment_ahead}}) scope: invalid.illegal.operator.haskell - - match: '\binfix[lr]?\b' + - match: 'infix[lr]?{{break}}' scope: keyword.operator.haskell - - match: \b(\d+)(?:(\.)(\d+)([eE][-+]?\d+)?|([eE][-+]?\d+))\b + - match: (\d+)(?:(\.)(\d+)([eE][-+]?\d+)?|([eE][-+]?\d+)){{break}} scope: meta.number.float.decimal.haskell captures: 1: constant.numeric.value.haskell @@ -328,7 +330,7 @@ contexts: ident: - match: |- - (?x) \b + (?x) (abs|acos|acosh|all|and|any|appendFile|asTypeOf|asin|asinh|atan|atan2|atanh |break |ceiling|compare|concat|concatMap|const|cos|cosh|curry|cycle @@ -355,7 +357,7 @@ contexts: |undefined|unlines|until|unwords|unzip|unzip3|userError|words |writeFile |zip|zip3|zipWith|zipWith3 - ) \b + ){{break}} scope: support.function.prelude.haskell - match: '[[:lower:]][^\s{{operator_char}}),\]{}]+' scope: meta.name.haskell @@ -437,11 +439,11 @@ contexts: - match: '#-\}' pop: true - match: |- - \b(?x: + (?x: LANGUAGE|OPTIONS_GHC|OPTIONS_HADDOCK|INCLUDE|WARNING|DEPRECATED|MINIMAL |UNPACK|NOUNPACK|SOURCE|OVERLAPPING|OVERLAPPABLE|OVERLAPS |INCOHERENT|INLINE|NOINLINE|INLINABLE|CONLIKE|LINE|RULES |SPECIALIZE|SPECIALISE - )\b + ){{break}} # https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#pragmas scope: keyword.directive.other.haskell diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 24116fcd09..a144becd5c 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -281,6 +281,14 @@ a ` -- ^ - keyword - operator - punctuation + 'class +-- ^^^^^ keyword.declaration.class.haskell + + class' +-- ^^^^^^ - keyword + + if' +-- ^^^ - keyword -- Tests for #1320, #1880. From df35af4b91a5be0e0f8ad04e01151abf7bd0f3f7 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 23 Dec 2020 22:53:36 +0100 Subject: [PATCH 014/178] [Haskell] Tweak C-style directive keyword scope Include `#` into keyword scope. --- Haskell/Haskell.sublime-syntax | 6 +++--- Haskell/syntax_test_haskell.hs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 4f5d7c563f..aae8863c87 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -252,11 +252,11 @@ contexts: preprocessor: # In addition to Haskell's "native" syntax, # GHC permits the C preprocessor to be run on a source file. - - match: ^\s*(#)\s*(\w+) + - match: ^\s*((#)\s*\w+) scope: meta.preprocessor.c captures: - 1: punctuation.definition.preprocessor.c - 2: keyword.directive.other.c + 1: keyword.directive.other.c + 2: punctuation.definition.preprocessor.c - include: pragma string: diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index a144becd5c..ada79a7ddb 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -149,12 +149,12 @@ #if 0 -- ^^^ meta.preprocessor.c -- ^ punctuation.definition.preprocessor.c --- ^^ keyword.directive.other.c +-- ^^^ keyword.directive.other.c #endif -- ^^^^^^ meta.preprocessor.c -- ^ punctuation.definition.preprocessor.c --- ^^^^^ keyword.directive.other.c +-- ^^^^^^ keyword.directive.other.c -- | Map each element of a structure to an action, -- evaluate these actions from left to right, and From 044797e3d16c5de428ccf1f921e0161c73a6478c Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 23 Dec 2020 23:12:28 +0100 Subject: [PATCH 015/178] [Haskell] Fix unit scope consistency This commit makes sure to use the same scope for the same thing with regards to units. --- Haskell/Haskell.sublime-syntax | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index aae8863c87..feebf498b1 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -96,14 +96,17 @@ contexts: - include: expression constant: - - match: \(\) - scope: constant.language.unit.haskell - match: \[\] scope: constant.language.empty-list.haskell + - include: constant_unit - include: number - match: '{{con_id}}' scope: constant.other.haskell + constant_unit: + - match: \(\) + scope: constant.language.unit.haskell + number: - match: (0[oO])([0-7]+){{break}} scope: meta.number.integer.octal.haskell @@ -429,8 +432,7 @@ contexts: - include: operator_big_arrow - include: ident_generic_type - include: ident_type - - match: \(\) - scope: support.constant.unit.haskell + - include: constant_unit pragma: - match: '\{-#' From 1ce11046e13b0efc7e11a12c1f4ad3ced2867a65 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 23 Dec 2020 23:15:09 +0100 Subject: [PATCH 016/178] [Haskell] Fix test case Fixes a regression which broke some highlighting of following statements silently. --- Haskell/syntax_test_haskell.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index ada79a7ddb..4eb63a2cf5 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -281,8 +281,9 @@ a ` -- ^ - keyword - operator - punctuation - 'class + 'class TooMany where -- ^^^^^ keyword.declaration.class.haskell +-- ^ - punctuation - keyword class' -- ^^^^^^ - keyword From 8b841d6f7fa5b4b05ef82e09d441a433ee1a45ab Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 23 Dec 2020 23:19:06 +0100 Subject: [PATCH 017/178] [Haskell] Add missing {{break}} --- Haskell/Haskell.sublime-syntax | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index feebf498b1..29a862ea42 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -155,7 +155,7 @@ contexts: scope: keyword.declaration.haskell push: - meta_scope: meta.declaration.instance.haskell - - match: where|$ + - match: where{{break}}|$ scope: keyword.control.context.haskell pop: true - include: type_signature From 0babe572bee9148ab129670ab9d757819d9e33d4 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 10:47:45 +0100 Subject: [PATCH 018/178] [Haskell] Reorganize Comments --- Haskell/Haskell.sublime-syntax | 57 ++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 29a862ea42..e782504463 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -8,6 +8,7 @@ scope: source.haskell variables: # Comments + # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-170002.3 no_comment_ahead: '(?!{{comment_begin}})' comment_ahead: '(?={{comment_begin}})' comment_begin: '--+(?:{{comment_first_char}}|$)' @@ -50,7 +51,7 @@ variables: contexts: prototype: - - include: comment + - include: comments - include: preprocessor main: @@ -73,6 +74,38 @@ contexts: - match: ',' scope: punctuation.separator.comma.haskell +###[ COMMENTS ]################################################################ + + comments: + # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-170002.3 + - include: line-comments + - include: block-comments + + block-comments: + - match: \{-(?!#) + scope: punctuation.definition.comment.begin.haskell + push: block-comment-body + + block-comment-body: + - meta_scope: comment.block.haskell + - match: -\} + scope: punctuation.definition.comment.end.haskell + pop: true + - match: \{-# + push: block-comment-nested-body + - include: block-comments + + block-comment-nested-body: + - match: -\} + pop: true + - include: block-comments + + line-comments: + - match: (--+)(?:{{comment_first_char}}.*)?$\n? + scope: comment.line.double-dash.haskell + captures: + 1: punctuation.definition.comment.haskell + group: - match: \( scope: punctuation.section.group.begin.haskell @@ -381,28 +414,6 @@ contexts: - match: '{{con_id}}' scope: storage.type.haskell - comment: - - match: '(--+)(?:{{comment_first_char}}.*)?$\n?' - scope: comment.line.double-dash.haskell - captures: - 1: punctuation.definition.comment.haskell - - include: block_comment - - block_comment: - - match: '\{-(?!#)' - scope: punctuation.definition.comment.begin.haskell - push: - - meta_scope: comment.block.haskell - - match: '\{-#' - push: - - match: '-\}' - pop: true - - include: block_comment - - include: block_comment - - match: '-\}' - scope: punctuation.definition.comment.end.haskell - pop: true - module_exports: - match: \( scope: punctuation.section.group.begin.haskell From b0eca6f2a6f9cc0713a100a3b027ea7254088ae5 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 11:01:11 +0100 Subject: [PATCH 019/178] [Haskell] Reorganize preprocessor contexts This commit... 1. creates a PREPROCESSOR section 2. moves all relevant contexts into int 3. creates named contexts for all parts 4. moves predefined pragma keys into a variable 5. removes `pragma` context from `type_signature` because preprocessor contexts being included via prototype already. --- Haskell/Haskell.sublime-syntax | 63 ++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index e782504463..2e5496f536 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -35,6 +35,15 @@ variables: break: (?![\w']) + # https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#pragmas + pragma_keys: |- + (?x: + LANGUAGE | OPTIONS_GHC | OPTIONS_HADDOCK | INCLUDE | WARNING | DEPRECATED + | MINIMAL | UNPACK | NOUNPACK | SOURCE | OVERLAPPING | OVERLAPPABLE + | OVERLAPS | INCOHERENT | INLINE | NOINLINE | INLINABLE | CONLIKE | LINE + | RULES | SPECIALIZE | SPECIALISE + ){{break}} + # Escaped Characters escape_chars: |- (?x:NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI @@ -52,8 +61,9 @@ variables: contexts: prototype: - include: comments - - include: preprocessor - + - include: preprocessor-pragmas + - include: preprocessor-directives + main: - include: statement - include: expression @@ -106,6 +116,28 @@ contexts: captures: 1: punctuation.definition.comment.haskell +###[ PREPROCESSOR ]############################################################ + + preprocessor-directives: + # In addition to Haskell's "native" syntax, + # GHC permits the C preprocessor to be run on a source file. + - match: ^\s*((#)\s*\w+) + scope: meta.preprocessor.c + captures: + 1: keyword.directive.other.c + 2: punctuation.definition.preprocessor.c + + preprocessor-pragmas: + - match: \{-# + push: preprocessor-pragma-body + + preprocessor-pragma-body: + - meta_scope: meta.preprocessor.haskell + - match: '#-\}' + pop: true + - match: '{{pragma_keys}}' + scope: keyword.directive.other.haskell + group: - match: \( scope: punctuation.section.group.begin.haskell @@ -285,16 +317,6 @@ contexts: captures: 1: keyword.operator.haskell - preprocessor: - # In addition to Haskell's "native" syntax, - # GHC permits the C preprocessor to be run on a source file. - - match: ^\s*((#)\s*\w+) - scope: meta.preprocessor.c - captures: - 1: keyword.directive.other.c - 2: punctuation.definition.preprocessor.c - - include: pragma - string: - match: \" scope: punctuation.definition.string.begin.haskell @@ -438,25 +460,8 @@ contexts: 2: punctuation.accessor.dot.haskell type_signature: - - include: pragma - include: operator_arrow - include: operator_big_arrow - include: ident_generic_type - include: ident_type - include: constant_unit - - pragma: - - match: '\{-#' - push: - - meta_scope: meta.preprocessor.haskell - - match: '#-\}' - pop: true - - match: |- - (?x: - LANGUAGE|OPTIONS_GHC|OPTIONS_HADDOCK|INCLUDE|WARNING|DEPRECATED|MINIMAL - |UNPACK|NOUNPACK|SOURCE|OVERLAPPING|OVERLAPPABLE|OVERLAPS - |INCOHERENT|INLINE|NOINLINE|INLINABLE|CONLIKE|LINE|RULES - |SPECIALIZE|SPECIALISE - ){{break}} - # https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#pragmas - scope: keyword.directive.other.haskell From 1fe8c90fdad85f71fa02f5f66f7bd32d125f922d Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 11:16:06 +0100 Subject: [PATCH 020/178] [Haskell] Reorganize declaration contexts This commit... 1. creates sections for each kind of declaration 2. moves relevant contexts into those sections 3. splits the `declaration` context --- Haskell/Haskell.sublime-syntax | 186 +++++++++++++++++++-------------- 1 file changed, 109 insertions(+), 77 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 2e5496f536..7d8ab6a856 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -35,6 +35,13 @@ variables: break: (?![\w']) + class_names: |- + (?x: + Monad | Monadoid | Functor | Applicative | Foldableble | Traversable | Eq + | Ord | Read | Show | Num | Fractional | Rational | Enum | Bounded | Real + | RealFrac | RealFloat | Integral | Floating + ){{break}} + # https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#pragmas pragma_keys: |- (?x: @@ -69,8 +76,11 @@ contexts: - include: expression statement: - - include: declaration - - include: import + - include: functions + - include: instances + - include: classes + - include: imports + - include: modules expression: - include: keyword @@ -138,6 +148,103 @@ contexts: - match: '{{pragma_keys}}' scope: keyword.directive.other.haskell +###[ MODULE DECLARATIONS ]##################################################### + + modules: + - match: module{{break}} + scope: keyword.declaration.namespace.haskell + push: module-body + + module-body: + - meta_scope: meta.declaration.module.haskell + - match: where{{break}} + scope: keyword.control.context.haskell + pop: true + - match: ({{con_id}})(\.) + captures: + 1: variable.namespace.haskell + 2: punctuation.accessor.dot.haskell + - match: '{{con_id}}' + scope: entity.name.namespace.haskell + - include: module_exports + +###[ IMPORT DECLARATIONS ]##################################################### + + imports: + - match: import{{break}} + scope: keyword.control.import.haskell + push: import-body + + import-body: + - meta_scope: meta.import.haskell + - match: ($|;) + pop: true + - match: (?:qualified|as|hiding){{break}} + scope: keyword.control.import.haskell + - match: ({{con_id}})(\.)? + captures: + 1: variable.namespace.haskell + 2: punctuation.accessor.dot.haskell + - include: module_exports + +###[ CLASS DECLARATIONS ]###################################################### + + classes: + - match: class{{break}} + scope: keyword.declaration.class.haskell + push: class-body + - match: (deriving|via)\s*\( + captures: + 1: keyword.other.haskell + push: inherited-body + + class-body: + - meta_scope: meta.declaration.class.haskell + - match: where{{break}} + scope: keyword.control.context.haskell + pop: true + - match: '{{class_names}}' + scope: support.class.prelude.haskell + - include: ident_inherited_class + - include: ident_generic_type + - include: operator_big_arrow + + inherited-body: + - meta_scope: meta.deriving.haskell + - match: \) + pop: true + - include: ident_inherited_class + +###[ INSTANCE DECLARATIONS ]################################################### + + instances: + - match: instance{{break}} + scope: keyword.declaration.haskell + push: instance-body + + instance-body: + - meta_scope: meta.declaration.instance.haskell + - match: where{{break}}|$ + scope: keyword.control.context.haskell + pop: true + - include: type_signature + +###[ FUNCTION DECLARATIONS ]################################################### + + functions: + - match: '^(\s*)({{var_id}}|\(({{operator_parens}})\))\s*(::|∷)' + captures: + 2: entity.name.function.haskell + 3: keyword.operator.infix.haskell + 4: keyword.other.double-colon.haskell + push: function-body + + function-body: + - meta_scope: meta.function.type-declaration.haskell + - match: ^(?!\s*(?:--|{-|$)|\1\s) + pop: true + - include: type_signature + group: - match: \( scope: punctuation.section.group.begin.haskell @@ -186,75 +293,6 @@ contexts: - match: \d+{{break}} scope: meta.number.integer.decimal.haskell constant.numeric.value.haskell - declaration: - - match: module{{break}} - scope: keyword.declaration.namespace.haskell - push: - - meta_scope: meta.declaration.module.haskell - - match: where{{break}} - scope: keyword.control.context.haskell - pop: true - - match: ({{con_id}})(\.) - captures: - 1: variable.namespace.haskell - 2: punctuation.accessor.dot.haskell - - match: '{{con_id}}' - scope: entity.name.namespace.haskell - - include: module_exports - - match: class{{break}} - scope: keyword.declaration.class.haskell - push: - - meta_scope: meta.declaration.class.haskell - - match: where{{break}} - scope: keyword.control.context.haskell - pop: true - - match: |- - (?x:Monad|Monadoid|Functor|Applicative|Foldableble|Traversable - |Eq|Ord|Read|Show|Num|Fractional|Rational|Enum|Bounded - |Real|RealFrac|RealFloat|Integral|Floating){{break}} - scope: support.class.prelude.haskell - - include: ident_inherited_class - - include: ident_generic_type - - include: operator_big_arrow - - match: instance{{break}} - scope: keyword.declaration.haskell - push: - - meta_scope: meta.declaration.instance.haskell - - match: where{{break}}|$ - scope: keyword.control.context.haskell - pop: true - - include: type_signature - - match: '^(\s*)({{var_id}}|\(({{operator_parens}})\))\s*(::|∷)' - captures: - 2: entity.name.function.haskell - 3: keyword.operator.infix.haskell - 4: keyword.other.double-colon.haskell - push: - - meta_scope: meta.function.type-declaration.haskell - - match: ^(?!\s*(?:--|{-|$)|\1\s) - pop: true - - include: type_signature - - match: (deriving|via)\s*\( - captures: - 1: keyword.other.haskell - push: - - meta_scope: meta.deriving.haskell - - match: \) - pop: true - - include: ident_inherited_class - - import: - - match: import{{break}} - scope: keyword.control.import.haskell - push: - - meta_scope: meta.import.haskell - - match: ($|;) - pop: true - - match: (?:qualified|as|hiding){{break}} - scope: keyword.control.import.haskell - - include: module_name - - include: module_exports - keyword: - match: (?:do|in){{break}} scope: keyword.control.context.haskell @@ -453,12 +491,6 @@ contexts: comment: So named because I don't know what to call this. scope: meta.other.unknown.haskell - module_name: - - match: ({{con_id}})(\.)? - captures: - 1: variable.namespace.haskell - 2: punctuation.accessor.dot.haskell - type_signature: - include: operator_arrow - include: operator_big_arrow From 78fd92194a5f03da220e087623207959b5d44441 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 11:23:54 +0100 Subject: [PATCH 021/178] [Haskell] Tweak import identifier scopes This commit scopes the last part of a qualified import module `entity`. --- Haskell/Haskell.sublime-syntax | 4 +++- Haskell/syntax_test_haskell.hs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 7d8ab6a856..bacd7888cd 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -181,10 +181,12 @@ contexts: pop: true - match: (?:qualified|as|hiding){{break}} scope: keyword.control.import.haskell - - match: ({{con_id}})(\.)? + - match: ({{con_id}})\s*(?:(\.)|(?=\(|as{{break}})) captures: 1: variable.namespace.haskell 2: punctuation.accessor.dot.haskell + - match: '{{con_id}}' + scope: entity.name.namespace.haskell - include: module_exports ###[ CLASS DECLARATIONS ]###################################################### diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 4eb63a2cf5..d21a8b50a1 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -351,7 +351,7 @@ import qualified Data.Vector.Mutable as MutableVector -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^^^^ variable.namespace.haskell - punctuation -- ^^ keyword.control.import.haskell --- ^^^^^^^^^^^^^ variable.namespace.haskell +-- ^^^^^^^^^^^^^ entity.name.namespace.haskell import Data.List.Split (splitOn) -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^ keyword.control.import.haskell From f088faef6ac8cedb7d50efef5ae05c720d7471c9 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 11:46:30 +0100 Subject: [PATCH 022/178] [Haskell] Reorganize export/import symbols This commit... 1. renames `module_exports` into `symbols` 2. moves it into a dedicated section 3. creates named context for the body part 4. scopes it `meta.sequence.symbols` as it feels weird to have a meta.declaration.export in a meta.import statement. --- Haskell/Haskell.sublime-syntax | 43 +++++++++++++++++++--------------- Haskell/syntax_test_haskell.hs | 42 ++++++++++++++++----------------- 2 files changed, 45 insertions(+), 40 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index bacd7888cd..3589c7f1f0 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -166,7 +166,7 @@ contexts: 2: punctuation.accessor.dot.haskell - match: '{{con_id}}' scope: entity.name.namespace.haskell - - include: module_exports + - include: symbols ###[ IMPORT DECLARATIONS ]##################################################### @@ -187,7 +187,28 @@ contexts: 2: punctuation.accessor.dot.haskell - match: '{{con_id}}' scope: entity.name.namespace.haskell - - include: module_exports + - include: symbols + +###[ SYMBOL DECLARATIONS ]##################################################### + + symbols: + - match: \( + scope: punctuation.section.sequence.begin.haskell + push: symbol-body + + symbol-body: + - meta_scope: meta.sequence.symbols.haskell + - match: \) + scope: punctuation.section.sequence.end.haskell + pop: true + - include: ident_function + - include: ident_type + - match: ',' + scope: punctuation.separator.sequence.haskell + - include: operator_paren + - match: \({{no_comment_ahead}}.*?\) + comment: So named because I don't know what to call this. + scope: meta.other.unknown.haskell ###[ CLASS DECLARATIONS ]###################################################### @@ -476,23 +497,7 @@ contexts: - match: '{{con_id}}' scope: storage.type.haskell - module_exports: - - match: \( - scope: punctuation.section.group.begin.haskell - push: - - meta_scope: meta.declaration.exports.haskell - - match: \) - scope: punctuation.section.group.end.haskell - pop: true - - include: ident_function - - include: ident_type - - match: ',' - scope: punctuation.separator.comma.haskell - - include: operator_paren - - match: \({{no_comment_ahead}}.*?\) - comment: So named because I don't know what to call this. - scope: meta.other.unknown.haskell - + type_signature: - include: operator_arrow - include: operator_big_arrow diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index d21a8b50a1..f2618c7cd2 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -360,10 +360,10 @@ import Data.List.Split (splitOn) -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^^^^^ meta.declaration.exports.haskell --- ^ punctuation.section.group.begin.haskell +-- ^^^^^^^^^ meta.sequence.symbols.haskell +-- ^ punctuation.section.sequence.begin.haskell -- ^^^^^^^ variable.function.haskell --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.section.sequence.end.haskell import Data.List.Split (()) -- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^ keyword.control.import.haskell @@ -372,10 +372,10 @@ import Data.List.Split (()) -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^ meta.declaration.exports.haskell --- ^ punctuation.section.group.begin.haskell +-- ^^^^ meta.sequence.symbols.haskell +-- ^ punctuation.section.sequence.begin.haskell -- ^^ meta.other.unknown.haskell --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.section.sequence.end.haskell import Data.List.Split (-- -- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^ keyword.control.import.haskell @@ -384,12 +384,12 @@ import Data.List.Split (-- -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^ meta.declaration.exports.haskell --- ^ punctuation.section.group.begin.haskell +-- ^^^^^ meta.sequence.symbols.haskell +-- ^ punctuation.section.sequence.begin.haskell -- ^^^ comment.line.double-dash.haskell -- ^^ punctuation.definition.comment.haskell ) --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.section.sequence.end.haskell import Data.List.Split (--) -- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^ keyword.control.import.haskell @@ -398,12 +398,12 @@ import Data.List.Split (--) -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^ meta.declaration.exports.haskell --- ^ punctuation.section.group.begin.haskell +-- ^^^^^ meta.sequence.symbols.haskell +-- ^ punctuation.section.sequence.begin.haskell -- ^^^^ comment.line.double-dash.haskell -- ^^ punctuation.definition.comment.haskell ) --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.section.sequence.end.haskell import Data.List.Split ((--)) -- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^ keyword.control.import.haskell @@ -412,12 +412,12 @@ import Data.List.Split ((--)) -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^^^ meta.declaration.exports.haskell --- ^ punctuation.section.group.begin.haskell +-- ^^^^^^^ meta.sequence.symbols.haskell +-- ^ punctuation.section.sequence.begin.haskell -- ^^^^^ comment.line.double-dash.haskell -- ^^ punctuation.definition.comment.haskell ) --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.section.sequence.end.haskell import Data.List.Split ((--]) -- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^ keyword.control.import.haskell @@ -426,12 +426,12 @@ import Data.List.Split ((--]) -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^^^ meta.declaration.exports.haskell --- ^ punctuation.section.group.begin.haskell +-- ^^^^^^^ meta.sequence.symbols.haskell +-- ^ punctuation.section.sequence.begin.haskell -- ^^^^^ comment.line.double-dash.haskell -- ^^ punctuation.definition.comment.haskell ) --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.section.sequence.end.haskell import Data.List.Split ((--") -- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^ keyword.control.import.haskell @@ -440,12 +440,12 @@ import Data.List.Split ((--") -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^^^ meta.declaration.exports.haskell --- ^ punctuation.section.group.begin.haskell +-- ^^^^^^^ meta.sequence.symbols.haskell +-- ^ punctuation.section.sequence.begin.haskell -- ^^^^^ comment.line.double-dash.haskell -- ^^ punctuation.definition.comment.haskell ) --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.section.sequence.end.haskell deriving instance FromJSON Amount -- ^^^^^^^^ keyword.declaration.data.haskell From 93d98475e8fa71e405bcfeb59188b4b778270580 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 12:02:50 +0100 Subject: [PATCH 023/178] [Haskell] Improve module declaration bailouts This commit ensures to maintain highlighting with incomplete module declaration statements. --- Haskell/Haskell.sublime-syntax | 2 ++ Haskell/syntax_test_haskell.hs | 38 +++++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 3589c7f1f0..992f635b0b 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -167,6 +167,8 @@ contexts: - match: '{{con_id}}' scope: entity.name.namespace.haskell - include: symbols + - match: (?=\S) + pop: true ###[ IMPORT DECLARATIONS ]##################################################### diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index f2618c7cd2..45d71bce2d 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -121,7 +121,16 @@ -- ^^^ - comment ---DECLARATIONS +--MODULE DECLARATIONS + + module +-- ^^^^^^^ meta.declaration.module.haskell +-- ^^^^^^ keyword.declaration.namespace.haskell + + module Name +-- ^^^^^^^^^^^^ meta.declaration.module.haskell +-- ^^^^^^ keyword.declaration.namespace.haskell +-- ^^^^ entity.name.namespace.haskell module Name where -- ^^^^^^^^^^^^^^^^^ meta.declaration.module.haskell @@ -129,6 +138,33 @@ -- ^^^^ entity.name.namespace.haskell -- ^^^^^ keyword.control.context.haskell + module () +-- ^^^^^^^ meta.declaration.module.haskell - meta.sequence +-- ^^ meta.declaration.module.haskell meta.sequence.symbols.haskell +-- ^^^^^^ keyword.declaration.namespace.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell + + module Name () +-- ^^^^^^^^^^^^ meta.declaration.module.haskell - meta.sequence +-- ^^ meta.declaration.module.haskell meta.sequence.symbols.haskell +-- ^^^^^^ keyword.declaration.namespace.haskell +-- ^^^^ entity.name.namespace.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell + + module Name () where +-- ^^^^^^^^^^^^ meta.declaration.module.haskell - meta.sequence +-- ^^ meta.declaration.module.haskell meta.sequence.symbols.haskell +-- ^^^^^ meta.declaration.module.haskell - meta.sequence +-- ^^^^^^ keyword.declaration.namespace.haskell +-- ^^^^ entity.name.namespace.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^^^^ keyword.control.context.haskell + +--DECLARATIONS + class (Functor t, Foldable t) => Traversable t where -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell -- ^^^^^ keyword.declaration.class.haskell From 3805d01f3eb2edf6287d44ccd2202e511836527b Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 12:08:22 +0100 Subject: [PATCH 024/178] [Haskell] Reorganize type signatures context --- Haskell/Haskell.sublime-syntax | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 992f635b0b..d22ad43f01 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -94,6 +94,13 @@ contexts: - match: ',' scope: punctuation.separator.comma.haskell + type-signatures: + - include: operator_arrow + - include: operator_big_arrow + - include: ident_generic_type + - include: ident_type + - include: constant_unit + ###[ COMMENTS ]################################################################ comments: @@ -252,7 +259,7 @@ contexts: - match: where{{break}}|$ scope: keyword.control.context.haskell pop: true - - include: type_signature + - include: type-signatures ###[ FUNCTION DECLARATIONS ]################################################### @@ -268,7 +275,7 @@ contexts: - meta_scope: meta.function.type-declaration.haskell - match: ^(?!\s*(?:--|{-|$)|\1\s) pop: true - - include: type_signature + - include: type-signatures group: - match: \( @@ -499,10 +506,3 @@ contexts: - match: '{{con_id}}' scope: storage.type.haskell - - type_signature: - - include: operator_arrow - - include: operator_big_arrow - - include: ident_generic_type - - include: ident_type - - include: constant_unit From 70e438e310224c0f314d13b12e452f929bcab328 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 12:13:34 +0100 Subject: [PATCH 025/178] [Haskell] Reorganize groups and lists This commit ... 1. creates a dedicated section for groups and lists 2. renames groups and lists contexts to plural to express non-popping behavior 3. creates named contexts for body parts --- Haskell/Haskell.sublime-syntax | 42 +++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index d22ad43f01..f2b348d3ac 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -88,8 +88,8 @@ contexts: - include: constant - include: string - include: splice - - include: group - - include: list + - include: groups + - include: lists - include: ident - match: ',' scope: punctuation.separator.comma.haskell @@ -277,27 +277,33 @@ contexts: pop: true - include: type-signatures - group: +###[ GROUPS AND LISTS ]######################################################## + + groups: - match: \( scope: punctuation.section.group.begin.haskell - push: - - meta_scope: meta.group.haskell - - match: \) - scope: punctuation.section.group.end.haskell - pop: true - - include: expression + push: group-body + + group-body: + - meta_scope: meta.group.haskell + - match: \) + scope: punctuation.section.group.end.haskell + pop: true + - include: expression - list: + lists: - match: \[ scope: punctuation.section.sequence.begin.haskell - push: - - meta_scope: meta.sequence.haskell - - match: \] - scope: punctuation.section.sequence.end.haskell - pop: true - - match: ',' - scope: punctuation.separator.sequence.haskell - - include: expression + push: list-body + + list-body: + - meta_scope: meta.sequence.haskell + - match: \] + scope: punctuation.section.sequence.end.haskell + pop: true + - match: ',' + scope: punctuation.separator.sequence.haskell + - include: expression constant: - match: \[\] From 06b5e305f40fb159090031fbd1c3dc1f7c54534f Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 12:26:51 +0100 Subject: [PATCH 026/178] [Haskell] Reorganize identifiers This commit... 1. creates a dedicated section for identifier contexts 2. moves predefined function pattern into a variable 3. renames contexts to use `-` and plural. --- Haskell/Haskell.sublime-syntax | 101 +++++++++++++++++---------------- 1 file changed, 53 insertions(+), 48 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index f2b348d3ac..a04899d11c 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -42,6 +42,34 @@ variables: | RealFrac | RealFloat | Integral | Floating ){{break}} + function_names: |- + (?x: + abs | acos | acosh | all | and | any | appendFile | asTypeOf | asin + | asinh | atan | atan2 | atanh | break | ceiling | compare | concat + | concatMap | const | cos | cosh | curry | cycle | decodeFloat | div + | divMod | drop | dropWhile | either | elem | encodeFloat | enumFrom + | enumFromThen | enumFromThenTo | enumFromTo | error | errorWithoutStackTrace + | even | exp | exponent | fail | filter | flip | floatDigits | floatRadix + | floatRange | floor | fmap | foldMap | foldl | foldl1 | foldr | foldr1 + | fromEnum | fromInteger | fromIntegral | fromRational | fst | gcd | getChar + | getContents | getLine | head | id | init | interact | ioError + | isDenormalized | isIEEE | isInfinite | isNaN | isNegativeZero | iterate + | last | lcm | length | lex | lines | log | logBase | lookup | map | mapM + | mapM_ | mappend | max | maxBound | maximum | maybe | mconcat | mempty + | min | minBound | minimum | mod | negate | not | notElem | null | odd | or + | otherwise | pi | pred | print | product | properFraction | pure | putChar + | putStr | putStrLn | quot | quotRem | read | readFile | readIO | readList + | readLn | readParen | reads | readsPrec | realToFrac | recip | rem | repeat + | replicate | return | reverse | round | scaleFloat | scanl | scanl1 | scanr + | scanr1 | seq | sequence | sequenceA | sequence_ | show | showChar + | showList | showParen | showString | shows | showsPrec | significand + | signum | sin | sinh | snd | span | splitAt | sqrt | subtract | succ | sum + | tail | take | takeWhile | tan | tanh | toEnum | toInteger | toRational + | traverse | truncate | uncurry | undefined | unlines | until | unwords + | unzip | unzip3 | userError | words | writeFile | zip | zip3 | zipWith + | zipWith3 + ){{break}} + # https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#pragmas pragma_keys: |- (?x: @@ -90,15 +118,16 @@ contexts: - include: splice - include: groups - include: lists - - include: ident + - include: ident-builtin-functions + - include: ident-variables - match: ',' scope: punctuation.separator.comma.haskell type-signatures: - include: operator_arrow - include: operator_big_arrow - - include: ident_generic_type - - include: ident_type + - include: ident-generic-types + - include: ident-types - include: constant_unit ###[ COMMENTS ]################################################################ @@ -210,8 +239,9 @@ contexts: - match: \) scope: punctuation.section.sequence.end.haskell pop: true - - include: ident_function - - include: ident_type + - include: ident-builtin-functions + - include: ident-functions + - include: ident-types - match: ',' scope: punctuation.separator.sequence.haskell - include: operator_paren @@ -237,15 +267,15 @@ contexts: pop: true - match: '{{class_names}}' scope: support.class.prelude.haskell - - include: ident_inherited_class - - include: ident_generic_type + - include: ident-inherited-classs + - include: ident-generic-types - include: operator_big_arrow inherited-body: - meta_scope: meta.deriving.haskell - match: \) pop: true - - include: ident_inherited_class + - include: ident-inherited-classs ###[ INSTANCE DECLARATIONS ]################################################### @@ -462,53 +492,28 @@ contexts: - match: .* scope: string.quasiquoted.haskell - ident: - - match: |- - (?x) - (abs|acos|acosh|all|and|any|appendFile|asTypeOf|asin|asinh|atan|atan2|atanh - |break - |ceiling|compare|concat|concatMap|const|cos|cosh|curry|cycle - |decodeFloat|div|divMod|drop|dropWhile - |either|elem|encodeFloat|enumFrom|enumFromThen|enumFromThenTo|enumFromTo|error - |errorWithoutStackTrace|even|exp|exponent - |fail|filter|flip|floatDigits|floatRadix|floatRange|floor|fmap|foldMap|foldl|foldl1|foldr - |foldr1|fromEnum|fromInteger|fromIntegral|fromRational|fst - |gcd|getChar|getContents|getLine - |head - |id|init|interact|ioError|isDenormalized|isIEEE|isInfinite|isNaN|isNegativeZero|iterate - |last|lcm|length|lex|lines|log|logBase|lookup - |map|mapM|mapM_|mappend|max|maxBound|maximum|maybe|mconcat|mempty|min|minBound|minimum|mod - |negate|not|notElem|null - |odd|or|otherwise - |pi|pred|print|product|properFraction|pure|putChar|putStr|putStrLn - |quot|quotRem|read - |readFile|readIO|readList|readLn|readParen|reads|readsPrec|realToFrac|recip|rem|repeat - |replicate|return|reverse|round|scaleFloat - |scanl|scanl1|scanr|scanr1|seq|sequence|sequenceA|sequence_|show|showChar|showList - |showParen|showString|shows|showsPrec|significand|signum|sin|sinh|snd|span|splitAt|sqrt - |subtract|succ|sum|tail - |take|takeWhile|tan|tanh|toEnum|toInteger|toRational|traverse|truncate|uncurry - |undefined|unlines|until|unwords|unzip|unzip3|userError|words - |writeFile - |zip|zip3|zipWith|zipWith3 - ){{break}} - scope: support.function.prelude.haskell - - match: '[[:lower:]][^\s{{operator_char}}),\]{}]+' - scope: meta.name.haskell +###[ IDENTIFIERS ]############################################################# - ident_function: - - match: '{{var_id}}' - scope: variable.function.haskell - - ident_inherited_class: + ident-inherited-classs: - match: '{{con_id}}' scope: entity.other.inherited-class.haskell - ident_generic_type: + ident-generic-types: - match: '{{var_id}}' scope: variable.other.generic-type.haskell - ident_type: + ident-types: - match: '{{con_id}}' scope: storage.type.haskell + ident-builtin-functions: + - match: '{{function_names}}' + scope: support.function.prelude.haskell + + ident-functions: + - match: '{{var_id}}' + scope: variable.function.haskell + + ident-variables: + - match: '{{var_id}}' + scope: meta.name.haskell From 8a7335ee96fdefd4cabe9d9e6c7f59ca892dbed5 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 12:38:52 +0100 Subject: [PATCH 027/178] [Haskell] Reorganize literals This context... 1. creates a dedicated LITERALS section 2. moves contexts for chars,numbers,strings and language constants into the new section 3. renames the contexts to be prepended with `literal-` and use plural. --- Haskell/Haskell.sublime-syntax | 121 +++++++++++++++++---------------- 1 file changed, 64 insertions(+), 57 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index a04899d11c..d7ce167337 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -113,12 +113,15 @@ contexts: expression: - include: keyword - include: operator - - include: constant - - include: string + - include: literal-chars + - include: literal-strings + - include: literal-numbers + - include: literal-units - include: splice - include: groups - include: lists - include: ident-builtin-functions + - include: ident-constants - include: ident-variables - match: ',' scope: punctuation.separator.comma.haskell @@ -128,7 +131,7 @@ contexts: - include: operator_big_arrow - include: ident-generic-types - include: ident-types - - include: constant_unit + - include: literal-units ###[ COMMENTS ]################################################################ @@ -322,6 +325,8 @@ contexts: - include: expression lists: + - match: \[\] + scope: constant.language.empty-list.haskell - match: \[ scope: punctuation.section.sequence.begin.haskell push: list-body @@ -335,19 +340,21 @@ contexts: scope: punctuation.separator.sequence.haskell - include: expression - constant: - - match: \[\] - scope: constant.language.empty-list.haskell - - include: constant_unit - - include: number - - match: '{{con_id}}' - scope: constant.other.haskell +###[ LITERALS ]################################################################ - constant_unit: + literal-units: - match: \(\) scope: constant.language.unit.haskell - number: + literal-numbers: + - match: (\d+)(?:(\.)(\d+)([eE][-+]?\d+)?|([eE][-+]?\d+)){{break}} + scope: meta.number.float.decimal.haskell + captures: + 1: constant.numeric.value.haskell + 2: punctuation.separator.decimal.haskell + 3: constant.numeric.value.haskell + 4: constant.numeric.value.exponent.haskell + 5: constant.numeric.value.exponent.haskell - match: (0[oO])([0-7]+){{break}} scope: meta.number.integer.octal.haskell captures: @@ -361,6 +368,47 @@ contexts: - match: \d+{{break}} scope: meta.number.integer.decimal.haskell constant.numeric.value.haskell + literal-chars: + - match: |- + (?x) + (') + (?: + ([\ -\[\]-~]) # Basic Char + | {{escape_sequence}} # Escapes + ) + ([^']*?) + (?:(')|{{comment_ahead}}) + scope: meta.string.haskell string.quoted.single.haskell + captures: + 1: punctuation.definition.string.begin.haskell + 2: constant.character.literal.haskell + 3: constant.character.escape.haskell + 4: constant.character.escape.decimal.haskell + 5: constant.character.escape.octal.haskell + 6: constant.character.escape.hexadecimal.haskell + 7: constant.character.escape.control.haskell + 8: invalid.illegal.expected-closing-quotation.haskell + 9: punctuation.definition.string.end.haskell + + literal-strings: + - match: \" + scope: punctuation.definition.string.begin.haskell + push: literal-string-body + + literal-string-body: + - meta_include_prototype: false + - meta_scope: meta.string.haskell string.quoted.double.haskell + - match: \"|$|{{comment_ahead}} + scope: punctuation.definition.string.end.haskell + pop: true + - match: '{{escape_sequence}}' + captures: + 1: constant.character.escape.haskell + 2: constant.character.escape.decimal.haskell + 3: constant.character.escape.octal.haskell + 4: constant.character.escape.hexadecimal.haskell + 5: constant.character.escape.control.haskell + keyword: - match: (?:do|in){{break}} scope: keyword.control.context.haskell @@ -397,14 +445,6 @@ contexts: scope: invalid.illegal.operator.haskell - match: 'infix[lr]?{{break}}' scope: keyword.operator.haskell - - match: (\d+)(?:(\.)(\d+)([eE][-+]?\d+)?|([eE][-+]?\d+)){{break}} - scope: meta.number.float.decimal.haskell - captures: - 1: constant.numeric.value.haskell - 2: punctuation.separator.decimal.haskell - 3: constant.numeric.value.haskell - 4: constant.numeric.value.exponent.haskell - 5: constant.numeric.value.exponent.haskell - match: '{{operator_infix}}' scope: keyword.operator.haskell - include: operator_paren @@ -423,43 +463,6 @@ contexts: captures: 1: keyword.operator.haskell - string: - - match: \" - scope: punctuation.definition.string.begin.haskell - push: - - meta_include_prototype: false - - meta_scope: meta.string.haskell string.quoted.double.haskell - - match: \"|$|{{comment_ahead}} - scope: punctuation.definition.string.end.haskell - pop: true - - match: '{{escape_sequence}}' - captures: - 1: constant.character.escape.haskell - 2: constant.character.escape.decimal.haskell - 3: constant.character.escape.octal.haskell - 4: constant.character.escape.hexadecimal.haskell - 5: constant.character.escape.control.haskell - - match: |- - (?x) - (') - (?: - ([\ -\[\]-~]) # Basic Char - | {{escape_sequence}} # Escapes - ) - ([^']*?) - (?:(')|{{comment_ahead}}) - scope: meta.string.haskell string.quoted.single.haskell - captures: - 1: punctuation.definition.string.begin.haskell - 2: constant.character.literal.haskell - 3: constant.character.escape.haskell - 4: constant.character.escape.decimal.haskell - 5: constant.character.escape.octal.haskell - 6: constant.character.escape.hexadecimal.haskell - 7: constant.character.escape.control.haskell - 8: invalid.illegal.expected-closing-quotation.haskell - 9: punctuation.definition.string.end.haskell - splice: - match: '\[(?:|e|d|t|p)\|' comment: Points out splices in ast quotes @@ -506,6 +509,10 @@ contexts: - match: '{{con_id}}' scope: storage.type.haskell + ident-constants: + - match: '{{con_id}}' + scope: constant.other.haskell + ident-builtin-functions: - match: '{{function_names}}' scope: support.function.prelude.haskell From 26a367a67b98af489b8fd7bd0a58dce025fb50df Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 12:50:46 +0100 Subject: [PATCH 028/178] [Haskell] Reorganize keywords and operators --- Haskell/Haskell.sublime-syntax | 44 ++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index d7ce167337..1bcfcd5394 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -111,8 +111,8 @@ contexts: - include: modules expression: - - include: keyword - - include: operator + - include: keywords + - include: operators - include: literal-chars - include: literal-strings - include: literal-numbers @@ -123,12 +123,10 @@ contexts: - include: ident-builtin-functions - include: ident-constants - include: ident-variables - - match: ',' - scope: punctuation.separator.comma.haskell type-signatures: - - include: operator_arrow - - include: operator_big_arrow + - include: arrow-operators + - include: big-arrow-operators - include: ident-generic-types - include: ident-types - include: literal-units @@ -245,9 +243,8 @@ contexts: - include: ident-builtin-functions - include: ident-functions - include: ident-types - - match: ',' - scope: punctuation.separator.sequence.haskell - - include: operator_paren + - include: sequence-separators + - include: infix-parens-operators - match: \({{no_comment_ahead}}.*?\) comment: So named because I don't know what to call this. scope: meta.other.unknown.haskell @@ -272,7 +269,7 @@ contexts: scope: support.class.prelude.haskell - include: ident-inherited-classs - include: ident-generic-types - - include: operator_big_arrow + - include: big-arrow-operators inherited-body: - meta_scope: meta.deriving.haskell @@ -336,8 +333,6 @@ contexts: - match: \] scope: punctuation.section.sequence.end.haskell pop: true - - match: ',' - scope: punctuation.separator.sequence.haskell - include: expression ###[ LITERALS ]################################################################ @@ -409,7 +404,9 @@ contexts: 4: constant.character.escape.hexadecimal.haskell 5: constant.character.escape.control.haskell - keyword: +###[ KEYWORDS AND OPERATORS ]################################################## + + keywords: - match: (?:do|in){{break}} scope: keyword.control.context.haskell - match: (?:newtype|type){{break}} @@ -433,7 +430,7 @@ contexts: - match: (?:else){{break}} scope: keyword.control.conditional.else.haskell - operator: + operators: - match: (`)[ \w'.]+(`) # Haskell allows any ordinary function application (elem 4 [1..10]) # to be rewritten as an infix expression (4 `elem` [1..10])." @@ -443,26 +440,31 @@ contexts: 2: punctuation.definition.function.end.haskell - match: (`)[^`]*?(?:(`)|{{comment_ahead}}) scope: invalid.illegal.operator.haskell - - match: 'infix[lr]?{{break}}' + - match: infix[lr]?{{break}} scope: keyword.operator.haskell - match: '{{operator_infix}}' scope: keyword.operator.haskell - - include: operator_paren + - include: infix-parens-operators + - include: sequence-separators - operator_arrow: - - match: '(?:->|→)' + arrow-operators: + - match: (?:->|→) scope: keyword.other.arrow.haskell - operator_big_arrow: - - match: '(?:=>|⇒)' + big-arrow-operators: + - match: (?:=>|⇒) scope: keyword.other.big-arrow.haskell - operator_paren: + infix-parens-operators: - match: \(({{operator_parens}})\) scope: variable.function.infix.haskell captures: 1: keyword.operator.haskell + sequence-separators: + - match: ',' + scope: punctuation.separator.sequence.haskell + splice: - match: '\[(?:|e|d|t|p)\|' comment: Points out splices in ast quotes From 563aad65bbe9326368475ab6f7e0f4b2d9692737 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 13:46:32 +0100 Subject: [PATCH 029/178] [Haskell] Tweak reserved_id formatting --- Haskell/Haskell.sublime-syntax | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 1bcfcd5394..52db0de79e 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -23,14 +23,14 @@ variables: operator_parens: '(?:{{no_comment_ahead}}{{operator_infix}}|,+)' # Identifiers + # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-180002.4 con_id: (?:[[:upper:]][\w']*) var_id: (?:(?!{{reserved_id}})[[:lower:]][\w']*) reserved_id: |- (?x: - case | class | data | default | deriving | do | else - | foreign | if | import | in | infix | infixl - | infixr | instance | let | module | newtype | of - | then | type | where | _ + case | class | data | default | deriving | do | else | foreign | if + | import | in | infix | infixl | infixr | instance | let | module | newtype + | of | then | type | where | _ ){{break}} break: (?![\w']) From f005107e1aa98845235353c5d2da0cf56a96d10d Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 13:57:35 +0100 Subject: [PATCH 030/178] [Haskell] Reorganize escape_chars variables Moves them right after identifiers as this is the order of rules in the language specification and tweaks pattern formatting to match the rest. --- Haskell/Haskell.sublime-syntax | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 52db0de79e..157943ce06 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -32,9 +32,26 @@ variables: | import | in | infix | infixl | infixr | instance | let | module | newtype | of | then | type | where | _ ){{break}} - break: (?![\w']) + # Escaped Characters + # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-200002.6 + escape_chars: |- + (?x: + 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 + | [abfnrtv\\\"'\&] + ) + escape_sequence: |- + (?x: + (\\{{escape_chars}}) # Escapes + | (\\[0-9]+) # Decimal Escapes + | (\\o[0-7]+) # Octal Escapes + | (\\x[0-9A-Fa-f]+) # Hexadecimal Escapes + | (\^[A-Z@\[\]\\\^_]) # Control Chars + ) + class_names: |- (?x: Monad | Monadoid | Functor | Applicative | Foldableble | Traversable | Eq @@ -79,20 +96,6 @@ variables: | RULES | SPECIALIZE | SPECIALISE ){{break}} - # Escaped Characters - escape_chars: |- - (?x: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 - |[abfnrtv\\\"'\&]) - escape_sequence: |- - (?x: - (\\{{escape_chars}}) # Escapes - | (\\[0-9]+) # Decimal Escapes - | (\\o[0-7]+) # Octal Escapes - | (\\x[0-9A-Fa-f]+) # Hexadecimal Escapes - | (\^[A-Z@\[\]\\\^_]) # Control Chars - ) - contexts: prototype: - include: comments From 81b5f338c0b4cd750ef8f725c6cdcb112aa2d6b2 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 13:59:08 +0100 Subject: [PATCH 031/178] [Haskell] Rename statement and expression contexts Use plural to express non-popping behavior. --- Haskell/Haskell.sublime-syntax | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 157943ce06..de20b64a87 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -103,17 +103,17 @@ contexts: - include: preprocessor-directives main: - - include: statement - - include: expression + - include: statements + - include: expressions - statement: + statements: - include: functions - include: instances - include: classes - include: imports - include: modules - expression: + expressions: - include: keywords - include: operators - include: literal-chars @@ -322,7 +322,7 @@ contexts: - match: \) scope: punctuation.section.group.end.haskell pop: true - - include: expression + - include: expressions lists: - match: \[\] @@ -336,7 +336,7 @@ contexts: - match: \] scope: punctuation.section.sequence.end.haskell pop: true - - include: expression + - include: expressions ###[ LITERALS ]################################################################ From bc4397db38f91669816b952a55f6040e24797c10 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 14:10:19 +0100 Subject: [PATCH 032/178] [Haskell] Add statement terminators A semicolon may be used to terminate statement depending on coding style. It can be omitted if certain layout rules are respected. --- Haskell/Haskell.sublime-syntax | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index de20b64a87..6a72c24a91 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -112,6 +112,7 @@ contexts: - include: classes - include: imports - include: modules + - include: statement-terminators expressions: - include: keywords @@ -219,7 +220,7 @@ contexts: import-body: - meta_scope: meta.import.haskell - - match: ($|;) + - match: $|(?=;) pop: true - match: (?:qualified|as|hiding){{break}} scope: keyword.control.import.haskell @@ -464,6 +465,12 @@ contexts: captures: 1: keyword.operator.haskell + statement-terminators: + # Depending on layout, semicolon may be needed to terminate statements. + # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-210002.7 + - match: ';' + scope: punctuation.terminator.statement.haskell + sequence-separators: - match: ',' scope: punctuation.separator.sequence.haskell From a9ddabbd7d983e16eecdab2e014ee115c90de890 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 14:24:08 +0100 Subject: [PATCH 033/178] [Haskell] Tweak import declarations Import declaration statements may span multiple lines. Hence `$` is removed from bailouts to support that. Note: fully qualified identifiers still need some tweaks to properly scope the leaf. --- Haskell/Haskell.sublime-syntax | 4 +-- Haskell/syntax_test_haskell.hs | 45 +++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 6a72c24a91..ddba7a523c 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -220,8 +220,6 @@ contexts: import-body: - meta_scope: meta.import.haskell - - match: $|(?=;) - pop: true - match: (?:qualified|as|hiding){{break}} scope: keyword.control.import.haskell - match: ({{con_id}})\s*(?:(\.)|(?=\(|as{{break}})) @@ -231,6 +229,8 @@ contexts: - match: '{{con_id}}' scope: entity.name.namespace.haskell - include: symbols + - match: (?=\S) + pop: true ###[ SYMBOL DECLARATIONS ]##################################################### diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 45d71bce2d..b554eaba3b 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -375,7 +375,20 @@ -- ^^^^ meta.group.haskell support.function.prelude.haskell ---KEYWORDS +--IMPORT DECLARATIONS + +import import +-- ^^^^^^^^^^^ meta.import.haskell +-- ^^^ keyword.control.import.haskell +-- ^^^^^^ keyword.control.import.haskell + +import ; import +-- ^^^^ meta.import.haskell +-- ^ - meta.import +-- ^^^^^^^ meta.import.haskell +-- ^^^ keyword.control.import.haskell +-- ^ punctuation.terminator.statement.haskell +-- ^^^^^^ meta.import.haskell keyword.control.import.haskell import qualified Data.Vector.Mutable as MutableVector -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell @@ -388,6 +401,27 @@ import qualified Data.Vector.Mutable as MutableVector -- ^^^^^^^ variable.namespace.haskell - punctuation -- ^^ keyword.control.import.haskell -- ^^^^^^^^^^^^^ entity.name.namespace.haskell + +import +-- ^^^^ meta.import.haskell +-- ^^^ keyword.control.import.haskell + qualified +-- ^^^^^^^^^^ meta.import.haskell +-- ^^^^^^^^^ keyword.control.import.haskell + Data.Vector.Mutable +-- ^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^^^ entity.name.namespace.haskell - punctuation + as +-- ^^^ meta.import.haskell +-- ^^ keyword.control.import.haskell + MutableVector +-- ^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^^^^^^^^^^^ entity.name.namespace.haskell + import Data.List.Split (splitOn) -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^ keyword.control.import.haskell @@ -400,6 +434,7 @@ import Data.List.Split (splitOn) -- ^ punctuation.section.sequence.begin.haskell -- ^^^^^^^ variable.function.haskell -- ^ punctuation.section.sequence.end.haskell + import Data.List.Split (()) -- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^ keyword.control.import.haskell @@ -412,6 +447,7 @@ import Data.List.Split (()) -- ^ punctuation.section.sequence.begin.haskell -- ^^ meta.other.unknown.haskell -- ^ punctuation.section.sequence.end.haskell + import Data.List.Split (-- -- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^ keyword.control.import.haskell @@ -426,6 +462,7 @@ import Data.List.Split (-- -- ^^ punctuation.definition.comment.haskell ) -- ^ punctuation.section.sequence.end.haskell + import Data.List.Split (--) -- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^ keyword.control.import.haskell @@ -440,6 +477,7 @@ import Data.List.Split (--) -- ^^ punctuation.definition.comment.haskell ) -- ^ punctuation.section.sequence.end.haskell + import Data.List.Split ((--)) -- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^ keyword.control.import.haskell @@ -454,6 +492,7 @@ import Data.List.Split ((--)) -- ^^ punctuation.definition.comment.haskell ) -- ^ punctuation.section.sequence.end.haskell + import Data.List.Split ((--]) -- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^ keyword.control.import.haskell @@ -468,6 +507,7 @@ import Data.List.Split ((--]) -- ^^ punctuation.definition.comment.haskell ) -- ^ punctuation.section.sequence.end.haskell + import Data.List.Split ((--") -- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^ keyword.control.import.haskell @@ -483,6 +523,9 @@ import Data.List.Split ((--") ) -- ^ punctuation.section.sequence.end.haskell + +--KEYWORDS + deriving instance FromJSON Amount -- ^^^^^^^^ keyword.declaration.data.haskell deriving instance FromJSON Ask From f71e2f55e48fa403c361af4943525ff31f932f39 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 14:25:30 +0100 Subject: [PATCH 034/178] [Haskell] Move import declaration tests Move them right after module declaration tests as this is the order of contexts in the definition file. --- Haskell/syntax_test_haskell.hs | 299 +++++++++++++++++---------------- 1 file changed, 150 insertions(+), 149 deletions(-) diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index b554eaba3b..dc617cb629 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -163,6 +163,156 @@ -- ^ punctuation.section.sequence.end.haskell -- ^^^^^ keyword.control.context.haskell + +--IMPORT DECLARATIONS + +import import +-- ^^^^^^^^^^^ meta.import.haskell +-- ^^^ keyword.control.import.haskell +-- ^^^^^^ keyword.control.import.haskell + +import ; import +-- ^^^^ meta.import.haskell +-- ^ - meta.import +-- ^^^^^^^ meta.import.haskell +-- ^^^ keyword.control.import.haskell +-- ^ punctuation.terminator.statement.haskell +-- ^^^^^^ meta.import.haskell keyword.control.import.haskell + +import qualified Data.Vector.Mutable as MutableVector +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^ keyword.control.import.haskell +-- ^^^^^^^^^ keyword.control.import.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^^^ variable.namespace.haskell - punctuation +-- ^^ keyword.control.import.haskell +-- ^^^^^^^^^^^^^ entity.name.namespace.haskell + +import +-- ^^^^ meta.import.haskell +-- ^^^ keyword.control.import.haskell + qualified +-- ^^^^^^^^^^ meta.import.haskell +-- ^^^^^^^^^ keyword.control.import.haskell + Data.Vector.Mutable +-- ^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^^^ entity.name.namespace.haskell - punctuation + as +-- ^^^ meta.import.haskell +-- ^^ keyword.control.import.haskell + MutableVector +-- ^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^^^^^^^^^^^ entity.name.namespace.haskell + +import Data.List.Split (splitOn) +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^ keyword.control.import.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^^^^^ meta.sequence.symbols.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^^^ variable.function.haskell +-- ^ punctuation.section.sequence.end.haskell + +import Data.List.Split (()) +-- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^ keyword.control.import.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^ variable.namespace.haskell - punctuation +-- ^^^^ meta.sequence.symbols.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^ meta.other.unknown.haskell +-- ^ punctuation.section.sequence.end.haskell + +import Data.List.Split (-- +-- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^ keyword.control.import.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^ meta.sequence.symbols.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^ comment.line.double-dash.haskell +-- ^^ punctuation.definition.comment.haskell + ) +-- ^ punctuation.section.sequence.end.haskell + +import Data.List.Split (--) +-- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^ keyword.control.import.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^ meta.sequence.symbols.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^ comment.line.double-dash.haskell +-- ^^ punctuation.definition.comment.haskell + ) +-- ^ punctuation.section.sequence.end.haskell + +import Data.List.Split ((--)) +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^ keyword.control.import.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^^^ meta.sequence.symbols.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^ comment.line.double-dash.haskell +-- ^^ punctuation.definition.comment.haskell + ) +-- ^ punctuation.section.sequence.end.haskell + +import Data.List.Split ((--]) +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^ keyword.control.import.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^^^ meta.sequence.symbols.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^ comment.line.double-dash.haskell +-- ^^ punctuation.definition.comment.haskell + ) +-- ^ punctuation.section.sequence.end.haskell + +import Data.List.Split ((--") +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^ keyword.control.import.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^^^ meta.sequence.symbols.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^ comment.line.double-dash.haskell +-- ^^ punctuation.definition.comment.haskell + ) +-- ^ punctuation.section.sequence.end.haskell + + --DECLARATIONS class (Functor t, Foldable t) => Traversable t where @@ -375,155 +525,6 @@ -- ^^^^ meta.group.haskell support.function.prelude.haskell ---IMPORT DECLARATIONS - -import import --- ^^^^^^^^^^^ meta.import.haskell --- ^^^ keyword.control.import.haskell --- ^^^^^^ keyword.control.import.haskell - -import ; import --- ^^^^ meta.import.haskell --- ^ - meta.import --- ^^^^^^^ meta.import.haskell --- ^^^ keyword.control.import.haskell --- ^ punctuation.terminator.statement.haskell --- ^^^^^^ meta.import.haskell keyword.control.import.haskell - -import qualified Data.Vector.Mutable as MutableVector --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell --- ^^^ keyword.control.import.haskell --- ^^^^^^^^^ keyword.control.import.haskell --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^^ variable.namespace.haskell - punctuation --- ^^ keyword.control.import.haskell --- ^^^^^^^^^^^^^ entity.name.namespace.haskell - -import --- ^^^^ meta.import.haskell --- ^^^ keyword.control.import.haskell - qualified --- ^^^^^^^^^^ meta.import.haskell --- ^^^^^^^^^ keyword.control.import.haskell - Data.Vector.Mutable --- ^^^^^^^^^^^^^^^^^^^^ meta.import.haskell --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^^ entity.name.namespace.haskell - punctuation - as --- ^^^ meta.import.haskell --- ^^ keyword.control.import.haskell - MutableVector --- ^^^^^^^^^^^^^^ meta.import.haskell --- ^^^^^^^^^^^^^ entity.name.namespace.haskell - -import Data.List.Split (splitOn) --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell --- ^^^ keyword.control.import.haskell --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^^^^^ meta.sequence.symbols.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^^^^^^ variable.function.haskell --- ^ punctuation.section.sequence.end.haskell - -import Data.List.Split (()) --- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell --- ^^^ keyword.control.import.haskell --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^ meta.sequence.symbols.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^ meta.other.unknown.haskell --- ^ punctuation.section.sequence.end.haskell - -import Data.List.Split (-- --- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell --- ^^^ keyword.control.import.haskell --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^ meta.sequence.symbols.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^^ comment.line.double-dash.haskell --- ^^ punctuation.definition.comment.haskell - ) --- ^ punctuation.section.sequence.end.haskell - -import Data.List.Split (--) --- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell --- ^^^ keyword.control.import.haskell --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^ meta.sequence.symbols.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^^^ comment.line.double-dash.haskell --- ^^ punctuation.definition.comment.haskell - ) --- ^ punctuation.section.sequence.end.haskell - -import Data.List.Split ((--)) --- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell --- ^^^ keyword.control.import.haskell --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^^^ meta.sequence.symbols.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^^^^ comment.line.double-dash.haskell --- ^^ punctuation.definition.comment.haskell - ) --- ^ punctuation.section.sequence.end.haskell - -import Data.List.Split ((--]) --- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell --- ^^^ keyword.control.import.haskell --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^^^ meta.sequence.symbols.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^^^^ comment.line.double-dash.haskell --- ^^ punctuation.definition.comment.haskell - ) --- ^ punctuation.section.sequence.end.haskell - -import Data.List.Split ((--") --- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell --- ^^^ keyword.control.import.haskell --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^^^ meta.sequence.symbols.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^^^^ comment.line.double-dash.haskell --- ^^ punctuation.definition.comment.haskell - ) --- ^ punctuation.section.sequence.end.haskell - - --KEYWORDS deriving instance FromJSON Amount From a7679ed6673e45d4c81002b1e8bc6e36f61db077 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 14:31:30 +0100 Subject: [PATCH 035/178] [Haskell] Scope import keywords `keyword.declaration.import` --- Haskell/Haskell.sublime-syntax | 4 ++-- Haskell/syntax_test_haskell.hs | 34 +++++++++++++++++----------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index ddba7a523c..a69c4543a1 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -215,13 +215,13 @@ contexts: imports: - match: import{{break}} - scope: keyword.control.import.haskell + scope: keyword.declaration.import.haskell push: import-body import-body: - meta_scope: meta.import.haskell - match: (?:qualified|as|hiding){{break}} - scope: keyword.control.import.haskell + scope: keyword.declaration.import.haskell - match: ({{con_id}})\s*(?:(\.)|(?=\(|as{{break}})) captures: 1: variable.namespace.haskell diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index dc617cb629..54ce64337f 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -168,35 +168,35 @@ import import -- ^^^^^^^^^^^ meta.import.haskell --- ^^^ keyword.control.import.haskell --- ^^^^^^ keyword.control.import.haskell +-- ^^^ keyword.declaration.import.haskell +-- ^^^^^^ keyword.declaration.import.haskell import ; import -- ^^^^ meta.import.haskell -- ^ - meta.import -- ^^^^^^^ meta.import.haskell --- ^^^ keyword.control.import.haskell +-- ^^^ keyword.declaration.import.haskell -- ^ punctuation.terminator.statement.haskell --- ^^^^^^ meta.import.haskell keyword.control.import.haskell +-- ^^^^^^ meta.import.haskell keyword.declaration.import.haskell import qualified Data.Vector.Mutable as MutableVector -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell --- ^^^ keyword.control.import.haskell --- ^^^^^^^^^ keyword.control.import.haskell +-- ^^^ keyword.declaration.import.haskell +-- ^^^^^^^^^ keyword.declaration.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^^^^ variable.namespace.haskell - punctuation --- ^^ keyword.control.import.haskell +-- ^^ keyword.declaration.import.haskell -- ^^^^^^^^^^^^^ entity.name.namespace.haskell import -- ^^^^ meta.import.haskell --- ^^^ keyword.control.import.haskell +-- ^^^ keyword.declaration.import.haskell qualified -- ^^^^^^^^^^ meta.import.haskell --- ^^^^^^^^^ keyword.control.import.haskell +-- ^^^^^^^^^ keyword.declaration.import.haskell Data.Vector.Mutable -- ^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^^ variable.namespace.haskell - punctuation @@ -206,14 +206,14 @@ import -- ^^^^^^^ entity.name.namespace.haskell - punctuation as -- ^^^ meta.import.haskell --- ^^ keyword.control.import.haskell +-- ^^ keyword.declaration.import.haskell MutableVector -- ^^^^^^^^^^^^^^ meta.import.haskell -- ^^^^^^^^^^^^^ entity.name.namespace.haskell import Data.List.Split (splitOn) -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell --- ^^^ keyword.control.import.haskell +-- ^^^ keyword.declaration.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation @@ -226,7 +226,7 @@ import Data.List.Split (splitOn) import Data.List.Split (()) -- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell --- ^^^ keyword.control.import.haskell +-- ^^^ keyword.declaration.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation @@ -239,7 +239,7 @@ import Data.List.Split (()) import Data.List.Split (-- -- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell --- ^^^ keyword.control.import.haskell +-- ^^^ keyword.declaration.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation @@ -254,7 +254,7 @@ import Data.List.Split (-- import Data.List.Split (--) -- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell --- ^^^ keyword.control.import.haskell +-- ^^^ keyword.declaration.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation @@ -269,7 +269,7 @@ import Data.List.Split (--) import Data.List.Split ((--)) -- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell --- ^^^ keyword.control.import.haskell +-- ^^^ keyword.declaration.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation @@ -284,7 +284,7 @@ import Data.List.Split ((--)) import Data.List.Split ((--]) -- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell --- ^^^ keyword.control.import.haskell +-- ^^^ keyword.declaration.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation @@ -299,7 +299,7 @@ import Data.List.Split ((--]) import Data.List.Split ((--") -- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell --- ^^^ keyword.control.import.haskell +-- ^^^ keyword.declaration.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation From 2c4a6dbef08b578542d43dfb40ae8f7c654da9d1 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 14:34:55 +0100 Subject: [PATCH 036/178] [Haskell] Opt-in to sublime-syntax version 2 There are no incompatible contexts so far. Hence it seems safe to opt-in to sublime-syntax version 2 now. --- Haskell/Haskell.sublime-syntax | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index a69c4543a1..7d3691c6e7 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -1,10 +1,15 @@ %YAML 1.2 --- -# http://www.sublimetext.com/docs/3/syntax.html +# https://www.haskell.org/onlinereport/haskell2010 +# https://www.sublimetext.com/docs/syntax.html name: Haskell +scope: source.haskell +version: 2 + file_extensions: - hs -scope: source.haskell + +############################################################################### variables: # Comments @@ -96,6 +101,8 @@ variables: | RULES | SPECIALIZE | SPECIALISE ){{break}} +############################################################################### + contexts: prototype: - include: comments From c147a0a86149b6a0d14cc56aaf3ce0c3adfdc52a Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 14:36:08 +0100 Subject: [PATCH 037/178] [Haskell] Replace pop: true by pop: 1 Remove legacy stuff from version 2 syntax definitions. --- Haskell/Haskell.sublime-syntax | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 7d3691c6e7..3ae4343c41 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -158,14 +158,14 @@ contexts: - meta_scope: comment.block.haskell - match: -\} scope: punctuation.definition.comment.end.haskell - pop: true + pop: 1 - match: \{-# push: block-comment-nested-body - include: block-comments block-comment-nested-body: - match: -\} - pop: true + pop: 1 - include: block-comments line-comments: @@ -192,7 +192,7 @@ contexts: preprocessor-pragma-body: - meta_scope: meta.preprocessor.haskell - match: '#-\}' - pop: true + pop: 1 - match: '{{pragma_keys}}' scope: keyword.directive.other.haskell @@ -207,7 +207,7 @@ contexts: - meta_scope: meta.declaration.module.haskell - match: where{{break}} scope: keyword.control.context.haskell - pop: true + pop: 1 - match: ({{con_id}})(\.) captures: 1: variable.namespace.haskell @@ -216,7 +216,7 @@ contexts: scope: entity.name.namespace.haskell - include: symbols - match: (?=\S) - pop: true + pop: 1 ###[ IMPORT DECLARATIONS ]##################################################### @@ -237,7 +237,7 @@ contexts: scope: entity.name.namespace.haskell - include: symbols - match: (?=\S) - pop: true + pop: 1 ###[ SYMBOL DECLARATIONS ]##################################################### @@ -250,7 +250,7 @@ contexts: - meta_scope: meta.sequence.symbols.haskell - match: \) scope: punctuation.section.sequence.end.haskell - pop: true + pop: 1 - include: ident-builtin-functions - include: ident-functions - include: ident-types @@ -275,7 +275,7 @@ contexts: - meta_scope: meta.declaration.class.haskell - match: where{{break}} scope: keyword.control.context.haskell - pop: true + pop: 1 - match: '{{class_names}}' scope: support.class.prelude.haskell - include: ident-inherited-classs @@ -285,7 +285,7 @@ contexts: inherited-body: - meta_scope: meta.deriving.haskell - match: \) - pop: true + pop: 1 - include: ident-inherited-classs ###[ INSTANCE DECLARATIONS ]################################################### @@ -299,7 +299,7 @@ contexts: - meta_scope: meta.declaration.instance.haskell - match: where{{break}}|$ scope: keyword.control.context.haskell - pop: true + pop: 1 - include: type-signatures ###[ FUNCTION DECLARATIONS ]################################################### @@ -315,7 +315,7 @@ contexts: function-body: - meta_scope: meta.function.type-declaration.haskell - match: ^(?!\s*(?:--|{-|$)|\1\s) - pop: true + pop: 1 - include: type-signatures ###[ GROUPS AND LISTS ]######################################################## @@ -329,7 +329,7 @@ contexts: - meta_scope: meta.group.haskell - match: \) scope: punctuation.section.group.end.haskell - pop: true + pop: 1 - include: expressions lists: @@ -343,7 +343,7 @@ contexts: - meta_scope: meta.sequence.haskell - match: \] scope: punctuation.section.sequence.end.haskell - pop: true + pop: 1 - include: expressions ###[ LITERALS ]################################################################ @@ -406,7 +406,7 @@ contexts: - meta_scope: meta.string.haskell string.quoted.double.haskell - match: \"|$|{{comment_ahead}} scope: punctuation.definition.string.end.haskell - pop: true + pop: 1 - match: '{{escape_sequence}}' captures: 1: constant.character.escape.haskell @@ -492,7 +492,7 @@ contexts: captures: 1: string.quasiquoted.haskell 2: keyword.other.quasibracket.haskell - pop: true + pop: 1 - match: \$\( scope: keyword.other.splice.haskell - match: \$ @@ -510,7 +510,7 @@ contexts: captures: 1: string.quasiquoted.haskell 2: keyword.other.quasibracket.haskell - pop: true + pop: 1 - match: .* scope: string.quasiquoted.haskell From 61f01b0b578e726e6b0844a1c8650c2f8b0285c3 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 15:03:53 +0100 Subject: [PATCH 038/178] [Haskell] Add support for code blocks Depending on code style curly braces may be used to denote block boundaries. --- Haskell/Haskell.sublime-syntax | 16 ++++++++++++++++ Haskell/syntax_test_haskell.hs | 29 +++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 3ae4343c41..98644c79c5 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -114,6 +114,7 @@ contexts: - include: expressions statements: + - include: blocks - include: functions - include: instances - include: classes @@ -318,6 +319,21 @@ contexts: pop: 1 - include: type-signatures +###[ BLOCKS ]################################################################## + + blocks: + # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-210002.7 + - match: \{ + scope: punctuation.section.block.begin.haskell + push: block-body + + block-body: + - meta_scope: meta.block.haskell + - match: \} + scope: punctuation.section.block.end.haskell + pop: 1 + - include: statements + ###[ GROUPS AND LISTS ]######################################################## groups: diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 54ce64337f..bab88c9eb8 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -163,6 +163,35 @@ -- ^ punctuation.section.sequence.end.haskell -- ^^^^^ keyword.control.context.haskell + module Ns.Name (sym1, sym2) where { import Ns.Other; import Ns.Other2 } +-- ^^^^^^^^^^^^^^^ meta.declaration.module.haskell - meta.sequence +-- ^^^^^^^^^^^^ meta.declaration.module.haskell meta.sequence.symbols.haskell +-- ^^^^^^ meta.declaration.module.haskell - meta.sequence +-- ^ - meta.declaration.module - meta.block +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.haskell - meta.declaration.module +-- ^ - meta.block +-- ^^^^^^ keyword.declaration.namespace.haskell +-- ^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^ entity.name.namespace.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^ variable.function.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^ variable.function.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^^^^ keyword.control.context.haskell +-- ^ punctuation.section.block.begin.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^ entity.name.namespace.haskell +-- ^ punctuation.terminator.statement.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ entity.name.namespace.haskell +-- ^ punctuation.section.block.end.haskell + --IMPORT DECLARATIONS From cda0a2cc4799e6a85f140c49d0a9b61fcb77758d Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 15:05:45 +0100 Subject: [PATCH 039/178] [Haskell] Introduce else-pop context --- Haskell/Haskell.sublime-syntax | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 98644c79c5..2d5dae2beb 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -216,8 +216,7 @@ contexts: - match: '{{con_id}}' scope: entity.name.namespace.haskell - include: symbols - - match: (?=\S) - pop: 1 + - include: else-pop ###[ IMPORT DECLARATIONS ]##################################################### @@ -237,8 +236,7 @@ contexts: - match: '{{con_id}}' scope: entity.name.namespace.haskell - include: symbols - - match: (?=\S) - pop: 1 + - include: else-pop ###[ SYMBOL DECLARATIONS ]##################################################### @@ -298,10 +296,11 @@ contexts: instance-body: - meta_scope: meta.declaration.instance.haskell - - match: where{{break}}|$ + - match: where{{break}} scope: keyword.control.context.haskell pop: 1 - include: type-signatures + - include: else-pop ###[ FUNCTION DECLARATIONS ]################################################### @@ -559,3 +558,9 @@ contexts: ident-variables: - match: '{{var_id}}' scope: meta.name.haskell + +###[ PROTOTYPES ]############################################################## + + else-pop: + - match: (?=\S) + pop: 1 From 5e2cff72a8257203ef672163bf7e81df2bd3d6de Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 15:08:35 +0100 Subject: [PATCH 040/178] [Haskell] Fix floating point number scopes Addresses #2630 This commit applies `constant.numeric.value` to the whole value part of floating point numbers without interrupting by decimal point and moves the pattern to the `number` context. --- Haskell/Haskell.sublime-syntax | 12 ++++-------- Haskell/syntax_test_haskell.hs | 17 ++++------------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 2d5dae2beb..703ace10c5 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -331,7 +331,7 @@ contexts: - match: \} scope: punctuation.section.block.end.haskell pop: 1 - - include: statements + - include: main ###[ GROUPS AND LISTS ]######################################################## @@ -368,14 +368,10 @@ contexts: scope: constant.language.unit.haskell literal-numbers: - - match: (\d+)(?:(\.)(\d+)([eE][-+]?\d+)?|([eE][-+]?\d+)){{break}} - scope: meta.number.float.decimal.haskell + - match: \d+(?:(\.)\d+(?:[eE][-+]?\d+)?|[eE][-+]?\d+){{break}} + scope: meta.number.float.decimal.haskell constant.numeric.value.haskell captures: - 1: constant.numeric.value.haskell - 2: punctuation.separator.decimal.haskell - 3: constant.numeric.value.haskell - 4: constant.numeric.value.exponent.haskell - 5: constant.numeric.value.exponent.haskell + 1: punctuation.separator.decimal.haskell - match: (0[oO])([0-7]+){{break}} scope: meta.number.integer.octal.haskell captures: diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index bab88c9eb8..288ab2065f 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -625,27 +625,18 @@ main = do -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell 12.345 --- ^^^^^^ meta.number.float.decimal.haskell --- ^^ constant.numeric.value.haskell +-- ^^^^^^ meta.number.float.decimal.haskell constant.numeric.value.haskell -- ^ punctuation.separator.decimal --- ^^^ constant.numeric.value.haskell 1e10 --- ^^^^ meta.number.float.decimal.haskell --- ^ constant.numeric.value.haskell --- ^^^ constant.numeric.value.exponent.haskell +-- ^^^^ meta.number.float.decimal.haskell constant.numeric.value.haskell 0.5e+0 --- ^^^^^^ meta.number.float.decimal.haskell --- ^ constant.numeric.value.haskell +-- ^^^^^^ meta.number.float.decimal.haskell constant.numeric.value.haskell -- ^ punctuation.separator.decimal.haskell --- ^ constant.numeric.value.haskell --- ^^^ constant.numeric.value.exponent.haskell 9e-1 --- ^^^^ meta.number.float.decimal.haskell --- ^ constant.numeric.value.haskell --- ^^^ constant.numeric.value.exponent.haskell +-- ^^^^ meta.number.float.decimal.haskell constant.numeric.value.haskell 0x0 -- ^^^ meta.number.integer.hexadecimal.haskell From 4ba2b93f303f4d4de675e807fc293da59acc976e Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 16:01:35 +0100 Subject: [PATCH 041/178] [Haskell] Fix derived statements This commit ... 1. Creates a dedicated context for inherited entities 2. fixes sequence scopes --- Haskell/Haskell.sublime-syntax | 27 ++++++++++++++++++++------- Haskell/syntax_test_haskell.hs | 31 +++++++++++++++++++++++++++---- 2 files changed, 47 insertions(+), 11 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 703ace10c5..76dc9cb2fa 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -116,6 +116,7 @@ contexts: statements: - include: blocks - include: functions + - include: inherited - include: instances - include: classes - include: imports @@ -265,10 +266,6 @@ contexts: - match: class{{break}} scope: keyword.declaration.class.haskell push: class-body - - match: (deriving|via)\s*\( - captures: - 1: keyword.other.haskell - push: inherited-body class-body: - meta_scope: meta.declaration.class.haskell @@ -281,10 +278,26 @@ contexts: - include: ident-generic-types - include: big-arrow-operators - inherited-body: +###[ INHERITED DECLARATIONS ]################################################## + + inherited: + - match: (?:deriving|via){{break}} + scope: storage.modifier.haskell + push: inherited-sequence + + inherited-sequence: - meta_scope: meta.deriving.haskell + - match: \( + scope: punctuation.section.sequence.begin.haskell + push: inherited-sequence-body + - include: else-pop + + inherited-sequence-body: + - meta_scope: meta.sequence.tuple.haskell - match: \) - pop: 1 + scope: punctuation.section.sequence.end.haskell + pop: 2 + - include: sequence-separators - include: ident-inherited-classs ###[ INSTANCE DECLARATIONS ]################################################### @@ -436,7 +449,7 @@ contexts: - match: (?:data){{break}} scope: keyword.declaration.data.haskell - match: (?:deriving){{break}} - scope: keyword.declaration.data.haskell + scope: storage.modifier.haskell - match: (?:case|of){{break}} scope: keyword.control.conditional.select.haskell # the construct is commonly called "select" - match: (?:let|where){{break}} diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 288ab2065f..b91fb25303 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -384,13 +384,36 @@ import Data.List.Split ((--") , recordDouble :: Double , recordRational :: Rational } deriving (Eq, Ord, Generic) --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.deriving.haskell +-- ^^^^^^^^^ meta.deriving.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^ meta.deriving.haskell meta.sequence.tuple.haskell +-- ^ - meta.deriving - meta.sequence +-- ^^^^^^^^ storage.modifier.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^ entity.other.inherited-class.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^ entity.other.inherited-class.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^ entity.other.inherited-class.haskell +-- ^ punctuation.section.sequence.end.haskell deriving (Read, Show) via (Quiet Record) --- ^^^ keyword.other.haskell --- ^^^^^^^^^^^^^^^^^^ meta.deriving.haskell +-- ^^^^^^^^^ meta.deriving.haskell - meta.sequence +-- ^^^^^^^^^^^^ meta.deriving.haskell meta.sequence.tuple.haskell +-- ^ - meta.deriving - meta.sequence +-- ^^^^ meta.deriving.haskell - meta.sequence +-- ^^^^^^^^^^^^^^ meta.deriving.haskell meta.sequence.tuple.haskell +-- ^ - meta.deriving - meta.sequence +-- ^^^^^^^^ storage.modifier.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^ entity.other.inherited-class.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^ entity.other.inherited-class.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^^ storage.modifier.haskell +-- ^ punctuation.section.sequence.begin.haskell -- ^^^^^ entity.other.inherited-class.haskell -- ^ - entity -- ^^^^^^ entity.other.inherited-class.haskell +-- ^ punctuation.section.sequence.end.haskell traverse :: Applicative f => -- ^^^^^^^^ entity.name.function.haskell @@ -557,7 +580,7 @@ import Data.List.Split ((--") --KEYWORDS deriving instance FromJSON Amount --- ^^^^^^^^ keyword.declaration.data.haskell +-- ^^^^^^^^ storage.modifier.haskell deriving instance FromJSON Ask -- ^^^^^^^^ meta.declaration.instance.haskell keyword.declaration.haskell From 472b89a85f9d21ded71a1f9d9a66bc91a32f219c Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 18:28:19 +0100 Subject: [PATCH 042/178] [Haskell] Add preprocessor punctuation scopes --- Haskell/Haskell.sublime-syntax | 2 ++ Haskell/syntax_test_haskell.hs | 47 ++++++++++++++++++++-------------- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 76dc9cb2fa..724181a3c6 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -189,11 +189,13 @@ contexts: preprocessor-pragmas: - match: \{-# + scope: punctuation.section.preprocessor.begin.haskell push: preprocessor-pragma-body preprocessor-pragma-body: - meta_scope: meta.preprocessor.haskell - match: '#-\}' + scope: punctuation.section.preprocessor.end.haskell pop: 1 - match: '{{pragma_keys}}' scope: keyword.directive.other.haskell diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index b91fb25303..f63c47dc47 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -121,6 +121,34 @@ -- ^^^ - comment +--PREPROCESSOR + + {-# MINIMAL traverse | sequenceA LANGUAGE #-} +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.haskell +-- ^ - meta.preprocessor.haskell +-- ^^^ punctuation.section.preprocessor.begin.haskell +-- ^^^^^^^ keyword.directive.other.haskell +-- ^^^^^^^ keyword.directive.other.haskell +-- ^^^ punctuation.section.preprocessor.end.haskell + + {-# OPTIONS_HADDOCK not-home #-} +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.haskell +-- ^ - meta.preprocessor.haskell +-- ^^^ punctuation.section.preprocessor.begin.haskell +-- ^^^^^^^^^^^^^^^ keyword.directive.other.haskell +-- ^^^ punctuation.section.preprocessor.end.haskell + + #if 0 +-- ^^^ meta.preprocessor.c +-- ^ punctuation.definition.preprocessor.c +-- ^^^ keyword.directive.other.c + + #endif +-- ^^^^^^ meta.preprocessor.c +-- ^ punctuation.definition.preprocessor.c +-- ^^^^^^ keyword.directive.other.c + + --MODULE DECLARATIONS module @@ -351,25 +379,6 @@ import Data.List.Split ((--") -- ^^^^^^^^^^^ support.class.prelude.haskell -- ^ variable.other.generic-type.haskell -- ^^^^^ keyword.control.context.haskell - {-# MINIMAL traverse | sequenceA LANGUAGE #-} --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.haskell --- ^ - meta.preprocessor.haskell --- ^^^^^^^ keyword.directive.other.haskell - - {-# OPTIONS_HADDOCK not-home #-} --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.haskell --- ^ - meta.preprocessor.haskell --- ^^^^^^^^^^^^^^^ keyword.directive.other.haskell - - #if 0 --- ^^^ meta.preprocessor.c --- ^ punctuation.definition.preprocessor.c --- ^^^ keyword.directive.other.c - - #endif --- ^^^^^^ meta.preprocessor.c --- ^ punctuation.definition.preprocessor.c --- ^^^^^^ keyword.directive.other.c -- | Map each element of a structure to an action, -- evaluate these actions from left to right, and From a25e174ad445fdb301b64ad6594711a08b3002a1 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 19:07:45 +0100 Subject: [PATCH 043/178] [Haskell] Refactor type signature contexts Declarations may contain so called contexts `[context =>]`. That's what this commit starts to implement in a simplistic way by adding support for context tuples in general. They are applied to class declarations as a first step. --- Haskell/Haskell.sublime-syntax | 70 ++++++++++++++++++++++++----- Haskell/syntax_test_haskell.hs | 81 +++++++++++++++++++++++++++++++--- 2 files changed, 132 insertions(+), 19 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 724181a3c6..afb95b4077 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -137,13 +137,6 @@ contexts: - include: ident-constants - include: ident-variables - type-signatures: - - include: arrow-operators - - include: big-arrow-operators - - include: ident-generic-types - - include: ident-types - - include: literal-units - ###[ COMMENTS ]################################################################ comments: @@ -274,11 +267,8 @@ contexts: - match: where{{break}} scope: keyword.control.context.haskell pop: 1 - - match: '{{class_names}}' - scope: support.class.prelude.haskell - - include: ident-inherited-classs - - include: ident-generic-types - - include: big-arrow-operators + - include: type-signatures + - include: else-pop ###[ INHERITED DECLARATIONS ]################################################## @@ -333,6 +323,49 @@ contexts: pop: 1 - include: type-signatures +###[ TYPE SIGNATURES ]######################################################### + + type-signatures: + # 4.1.2 Syntax of Types + # https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-750004.3 + - include: big-arrow-operators + - include: type-content + + type-content: + - include: type-lists + - include: type-tuples + - include: arrow-operators + - include: sequence-separators + - include: ident-namespaces + - include: ident-types + - include: ident-generic-types + + type-lists: + - match: \[ + scope: punctuation.section.sequence.begin.haskell + push: type-list-body + + type-list-body: + - meta_scope: meta.sequence.list.haskell + - match: \] + scope: punctuation.section.sequence.end.haskell + pop: 1 + - include: type-content + + type-tuples: + # 4.1.3 Syntax of Class Assertions and Contexts + # https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-630004.1 + - match: \( + scope: punctuation.section.sequence.begin.haskell + push: type-tuple-body + + type-tuple-body: + - meta_scope: meta.sequence.tuple.haskell + - match: \) + scope: punctuation.section.sequence.end.haskell + pop: 1 + - include: type-content + ###[ BLOCKS ]################################################################## blocks: @@ -351,6 +384,7 @@ contexts: ###[ GROUPS AND LISTS ]######################################################## groups: + # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-380003.9 - match: \( scope: punctuation.section.group.begin.haskell push: group-body @@ -542,7 +576,12 @@ contexts: ###[ IDENTIFIERS ]############################################################# + ident-builtin-classes: + - match: '{{class_names}}' + scope: support.class.prelude.haskell + ident-inherited-classs: + - include: ident-builtin-classes - match: '{{con_id}}' scope: entity.other.inherited-class.haskell @@ -550,7 +589,14 @@ contexts: - match: '{{var_id}}' scope: variable.other.generic-type.haskell + ident-namespaces: + - match: ({{con_id}})(\.) + captures: + 1: variable.namespace.haskell + 2: punctuation.accessor.dot.haskell + ident-types: + - include: ident-builtin-classes - match: '{{con_id}}' scope: storage.type.haskell diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index f63c47dc47..11d5900c8f 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -370,16 +370,83 @@ import Data.List.Split ((--") -- ^ punctuation.section.sequence.end.haskell ---DECLARATIONS +--CLASS DECLARATIONS + + class +-- ^^^^^^ meta.declaration.class.haskell +-- ^^^^^ keyword.declaration.class.haskell + + class => +-- ^^^^^^^^^ meta.declaration.class.haskell +-- ^^^^^ keyword.declaration.class.haskell +-- ^^ keyword.other.big-arrow.haskell + + class QTyCls tyVar +-- ^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell +-- ^^^^^ keyword.declaration.class.haskell +-- ^^^^^^ storage.type.haskell +-- ^^^^^ variable.other.generic-type.haskell + + class ModId.QTyCls tyVar1, tyVar2 +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell +-- ^^^^^ keyword.declaration.class.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^ variable.other.generic-type.haskell + + class ModId.QTyCls tyVar1, tyVar2 => +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell +-- ^^^^^ keyword.declaration.class.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^^ keyword.other.big-arrow.haskell + + class ModId.QTyCls tyVar1, tyVar2 => Traversable t +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell +-- ^^^^^ keyword.declaration.class.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^^ keyword.other.big-arrow.haskell +-- ^^^^^^^^^^^ support.class.prelude.haskell +-- ^ variable.other.generic-type.haskell + + class () => +-- ^^^^^^^^^^^^ meta.declaration.class.haskell +-- ^^^^^ keyword.declaration.class.haskell +-- ^^ meta.sequence.tuple.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^ keyword.other.big-arrow.haskell class (Functor t, Foldable t) => Traversable t where -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell -- ^^^^^ keyword.declaration.class.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^^^ support.class.prelude.haskell +-- ^ variable.other.generic-type.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^^ storage.type.haskell +-- ^ variable.other.generic-type.haskell +-- ^ punctuation.section.sequence.end.haskell -- ^^ keyword.other.big-arrow.haskell -- ^^^^^^^^^^^ support.class.prelude.haskell -- ^ variable.other.generic-type.haskell -- ^^^^^ keyword.control.context.haskell + +--DECLARATIONS + -- | Map each element of a structure to an action, -- evaluate these actions from left to right, and -- collect the results. For a version that ignores @@ -398,9 +465,9 @@ import Data.List.Split ((--") -- ^ - meta.deriving - meta.sequence -- ^^^^^^^^ storage.modifier.haskell -- ^ punctuation.section.sequence.begin.haskell --- ^^ entity.other.inherited-class.haskell +-- ^^ support.class.prelude.haskell -- ^ punctuation.separator.sequence.haskell --- ^^^ entity.other.inherited-class.haskell +-- ^^^ support.class.prelude.haskell -- ^ punctuation.separator.sequence.haskell -- ^^^^^^^ entity.other.inherited-class.haskell -- ^ punctuation.section.sequence.end.haskell @@ -413,9 +480,9 @@ import Data.List.Split ((--") -- ^ - meta.deriving - meta.sequence -- ^^^^^^^^ storage.modifier.haskell -- ^ punctuation.section.sequence.begin.haskell --- ^^^^ entity.other.inherited-class.haskell +-- ^^^^ support.class.prelude.haskell -- ^ punctuation.separator.sequence.haskell --- ^^^^ entity.other.inherited-class.haskell +-- ^^^^ support.class.prelude.haskell -- ^ punctuation.section.sequence.end.haskell -- ^^^ storage.modifier.haskell -- ^ punctuation.section.sequence.begin.haskell @@ -427,7 +494,7 @@ import Data.List.Split ((--") traverse :: Applicative f => -- ^^^^^^^^ entity.name.function.haskell -- ^^ keyword.other.double-colon.haskell --- ^^^^^^^^^^^ storage.type.haskell +-- ^^^^^^^^^^^ support.class.prelude.haskell -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.type-declaration.haskell -- ^^ keyword.other.big-arrow.haskell (a -> f b) @@ -450,7 +517,7 @@ import Data.List.Split ((--") sequenceA ∷ Applicative f ⇒ t (f a) → f (t a) -- ^^^^^^^^^ entity.name.function.haskell -- ^ keyword.other.double-colon.haskell --- ^^^^^^^^^^^ storage.type.haskell +-- ^^^^^^^^^^^ support.class.prelude.haskell -- ^ keyword.other.big-arrow.haskell -- ^ keyword.other.arrow.haskell sequenceA = traverse id From f0d9de2e94436ef50886ff62d6db013850d7fb48 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 19:10:58 +0100 Subject: [PATCH 044/178] [Haskell] Rename symbols sequence scope to tuple Now that we learned Haskell to know the concept of tuples, lets scope those types of sequences as such. --- Haskell/Haskell.sublime-syntax | 16 ++++++++++------ Haskell/syntax_test_haskell.hs | 22 +++++++++++----------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index afb95b4077..4b0f31fce4 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -129,7 +129,7 @@ contexts: - include: literal-chars - include: literal-strings - include: literal-numbers - - include: literal-units + - include: tuples - include: splice - include: groups - include: lists @@ -242,7 +242,7 @@ contexts: push: symbol-body symbol-body: - - meta_scope: meta.sequence.symbols.haskell + - meta_scope: meta.sequence.tuple.haskell - match: \) scope: punctuation.section.sequence.end.haskell pop: 1 @@ -396,6 +396,14 @@ contexts: pop: 1 - include: expressions + tuples: + # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-380003.9 + - match: (\()(\)) + scope: meta.sequence.tuple.haskell + captures: + 1: punctuation.section.sequence.begin.haskell + 2: punctuation.section.sequence.end.haskell + lists: - match: \[\] scope: constant.language.empty-list.haskell @@ -412,10 +420,6 @@ contexts: ###[ LITERALS ]################################################################ - literal-units: - - match: \(\) - scope: constant.language.unit.haskell - literal-numbers: - match: \d+(?:(\.)\d+(?:[eE][-+]?\d+)?|[eE][-+]?\d+){{break}} scope: meta.number.float.decimal.haskell constant.numeric.value.haskell diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 11d5900c8f..1f4c38d14c 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -168,14 +168,14 @@ module () -- ^^^^^^^ meta.declaration.module.haskell - meta.sequence --- ^^ meta.declaration.module.haskell meta.sequence.symbols.haskell +-- ^^ meta.declaration.module.haskell meta.sequence.tuple.haskell -- ^^^^^^ keyword.declaration.namespace.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^ punctuation.section.sequence.end.haskell module Name () -- ^^^^^^^^^^^^ meta.declaration.module.haskell - meta.sequence --- ^^ meta.declaration.module.haskell meta.sequence.symbols.haskell +-- ^^ meta.declaration.module.haskell meta.sequence.tuple.haskell -- ^^^^^^ keyword.declaration.namespace.haskell -- ^^^^ entity.name.namespace.haskell -- ^ punctuation.section.sequence.begin.haskell @@ -183,7 +183,7 @@ module Name () where -- ^^^^^^^^^^^^ meta.declaration.module.haskell - meta.sequence --- ^^ meta.declaration.module.haskell meta.sequence.symbols.haskell +-- ^^ meta.declaration.module.haskell meta.sequence.tuple.haskell -- ^^^^^ meta.declaration.module.haskell - meta.sequence -- ^^^^^^ keyword.declaration.namespace.haskell -- ^^^^ entity.name.namespace.haskell @@ -193,7 +193,7 @@ module Ns.Name (sym1, sym2) where { import Ns.Other; import Ns.Other2 } -- ^^^^^^^^^^^^^^^ meta.declaration.module.haskell - meta.sequence --- ^^^^^^^^^^^^ meta.declaration.module.haskell meta.sequence.symbols.haskell +-- ^^^^^^^^^^^^ meta.declaration.module.haskell meta.sequence.tuple.haskell -- ^^^^^^ meta.declaration.module.haskell - meta.sequence -- ^ - meta.declaration.module - meta.block -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.haskell - meta.declaration.module @@ -276,7 +276,7 @@ import Data.List.Split (splitOn) -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^^^^^ meta.sequence.symbols.haskell +-- ^^^^^^^^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^^^^^ variable.function.haskell -- ^ punctuation.section.sequence.end.haskell @@ -289,7 +289,7 @@ import Data.List.Split (()) -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^ meta.sequence.symbols.haskell +-- ^^^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^ meta.other.unknown.haskell -- ^ punctuation.section.sequence.end.haskell @@ -302,7 +302,7 @@ import Data.List.Split (-- -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^ meta.sequence.symbols.haskell +-- ^^^^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^ comment.line.double-dash.haskell -- ^^ punctuation.definition.comment.haskell @@ -317,7 +317,7 @@ import Data.List.Split (--) -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^ meta.sequence.symbols.haskell +-- ^^^^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^^ comment.line.double-dash.haskell -- ^^ punctuation.definition.comment.haskell @@ -332,7 +332,7 @@ import Data.List.Split ((--)) -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^^^ meta.sequence.symbols.haskell +-- ^^^^^^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^^^ comment.line.double-dash.haskell -- ^^ punctuation.definition.comment.haskell @@ -347,7 +347,7 @@ import Data.List.Split ((--]) -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^^^ meta.sequence.symbols.haskell +-- ^^^^^^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^^^ comment.line.double-dash.haskell -- ^^ punctuation.definition.comment.haskell @@ -362,7 +362,7 @@ import Data.List.Split ((--") -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^^^ meta.sequence.symbols.haskell +-- ^^^^^^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^^^ comment.line.double-dash.haskell -- ^^ punctuation.definition.comment.haskell From 2dc3ce3a6d0d0f1d88fa2fac8ccf0255453ba7ca Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 19:16:38 +0100 Subject: [PATCH 045/178] [Haskell] Remove empty list special pattern As tuples are scoped `meta.sequence punctuation` only do the same for lists as well. It feels odd to scope empty lists `constant.language`. --- Haskell/Haskell.sublime-syntax | 2 -- 1 file changed, 2 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 4b0f31fce4..9bfac5bcde 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -405,8 +405,6 @@ contexts: 2: punctuation.section.sequence.end.haskell lists: - - match: \[\] - scope: constant.language.empty-list.haskell - match: \[ scope: punctuation.section.sequence.begin.haskell push: list-body From f840f3bc816b67f0eb062bcdaa00d58be248cef9 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 24 Dec 2020 19:39:17 +0100 Subject: [PATCH 046/178] [Haskell] Add type and newtype declaration statements This comment makes sure to correctly match class data types and variables after `type` and `newtype` keyword as they are after `class`. see: https://www.haskell.org/onlinereport/haskell2010/haskellch4.html --- Haskell/Haskell.sublime-syntax | 13 +++++ Haskell/syntax_test_haskell.hs | 95 ++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 9bfac5bcde..974b1c1229 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -119,6 +119,7 @@ contexts: - include: inherited - include: instances - include: classes + - include: types - include: imports - include: modules - include: statement-terminators @@ -323,6 +324,18 @@ contexts: pop: 1 - include: type-signatures +###[ TYPE DECLARATIONS ]####################################################### + + types: + - match: (?:newtype|type){{break}} + scope: keyword.declaration.type.haskell + push: type-body + + type-body: + - meta_scope: meta.declaration.type.haskell + - include: type-signatures + - include: else-pop + ###[ TYPE SIGNATURES ]######################################################### type-signatures: diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 1f4c38d14c..323129cdd7 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -444,6 +444,101 @@ import Data.List.Split ((--") -- ^ variable.other.generic-type.haskell -- ^^^^^ keyword.control.context.haskell +--TYPE DECLARATIONS + + type +-- ^^^^^ meta.declaration.type.haskell +-- ^^^^ keyword.declaration.type.haskell + + type QTyCls tyVar +-- ^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^ keyword.declaration.type.haskell +-- ^^^^^^ storage.type.haskell +-- ^^^^^ variable.other.generic-type.haskell + + type ModId.QTyCls tyVar1, tyVar2 +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^ keyword.declaration.type.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^ variable.other.generic-type.haskell + + type ModId.QTyCls tyVar1, tyVar2 = +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^ keyword.declaration.type.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^ variable.other.generic-type.haskell + + type ModId.QTyCls tyVar1, tyVar2 deriving (Class1, QTyCls2) +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^ keyword.declaration.type.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^^^^^^^^^ meta.deriving.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^ meta.deriving.haskell meta.sequence.tuple.haskell +-- ^^^^^^^^ storage.modifier.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^^ entity.other.inherited-class.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^ entity.other.inherited-class.haskell +-- ^ punctuation.section.sequence.end.haskell + +--NEWTYPE DECLARATIONS + + newtype +-- ^^^^^^^^ meta.declaration.type.haskell +-- ^^^^^^^ keyword.declaration.type.haskell + + newtype = +-- ^^^^^^^^ meta.declaration.type.haskell +-- ^^^^^^^ keyword.declaration.type.haskell +-- ^ keyword.operator.haskell + + newtype => +-- ^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^^^^ keyword.declaration.type.haskell +-- ^^ keyword.other.big-arrow.haskell + + newtype TypCls tyVar => +-- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^^^^ keyword.declaration.type.haskell +-- ^^^^^^ storage.type.haskell +-- ^^^^^ variable.other.generic-type.haskell +-- ^^ keyword.other.big-arrow.haskell + + newtype () => ModId.QTyCls tyVar1, tyVar2 deriving (Class1, QTyCls2) +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^ keyword.declaration.type.haskell +-- ^^ meta.sequence.tuple.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^ keyword.other.big-arrow.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^^^^^^^^^ meta.deriving.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^ meta.deriving.haskell meta.sequence.tuple.haskell +-- ^^^^^^^^ storage.modifier.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^^ entity.other.inherited-class.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^ entity.other.inherited-class.haskell +-- ^ punctuation.section.sequence.end.haskell + --DECLARATIONS From c42158355da38c15a65e46d54022ec01617882ad Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 25 Dec 2020 12:18:16 +0100 Subject: [PATCH 047/178] [Haskell] Fix literal chars vs. operators This commit removes invalid highlighting from character literals as this is not the way Haskell compiler works, which caused syntax highlighting to break in various situations when leading `'` is used as operator. Several test cases for char literals are added as well as those to illustrate how `'` applies as operator or part of an identifier. --- Haskell/Haskell.sublime-syntax | 19 +- Haskell/syntax_test_haskell.hs | 408 +++++++++++++++++++++++++++++---- 2 files changed, 369 insertions(+), 58 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 974b1c1229..8e9fefaba6 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -23,7 +23,7 @@ variables: # note that Haskell permits the definition of new operators # which can be nearly any string of punctuation characters, # such as $%^&*. - operator_char: '[*|!%&$@#?~+:\-.=\\]' + operator_char: '[*|!%&$@#?~+:\-.=\\''\^]' operator_infix: '{{operator_char}}+' operator_parens: '(?:{{no_comment_ahead}}{{operator_infix}}|,+)' @@ -125,15 +125,15 @@ contexts: - include: statement-terminators expressions: - - include: keywords - - include: operators - include: literal-chars - include: literal-strings - include: literal-numbers + - include: operators - include: tuples - include: splice - include: groups - include: lists + - include: keywords - include: ident-builtin-functions - include: ident-constants - include: ident-variables @@ -450,15 +450,7 @@ contexts: scope: meta.number.integer.decimal.haskell constant.numeric.value.haskell literal-chars: - - match: |- - (?x) - (') - (?: - ([\ -\[\]-~]) # Basic Char - | {{escape_sequence}} # Escapes - ) - ([^']*?) - (?:(')|{{comment_ahead}}) + - match: (')(?:([\ -\[\]-~])|{{escape_sequence}})(?:(')|{{comment_ahead}}) scope: meta.string.haskell string.quoted.single.haskell captures: 1: punctuation.definition.string.begin.haskell @@ -468,8 +460,7 @@ contexts: 5: constant.character.escape.octal.haskell 6: constant.character.escape.hexadecimal.haskell 7: constant.character.escape.control.haskell - 8: invalid.illegal.expected-closing-quotation.haskell - 9: punctuation.definition.string.end.haskell + 8: punctuation.definition.string.end.haskell literal-strings: - match: \" diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 323129cdd7..f4d1f9d6ff 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -692,7 +692,7 @@ import Data.List.Split ((--") 'class TooMany where -- ^^^^^ keyword.declaration.class.haskell --- ^ - punctuation - keyword +-- ^ keyword.operator.haskell class' -- ^^^^^^ - keyword @@ -841,61 +841,381 @@ main = do -- ^^ constant.numeric.base.haskell -- ^^^^^^^^^^ constant.numeric.value.haskell ---STRINGS +-- [ LITERAL CHARACTERS ] ----------------------------------------------------- - 'ab' --- ^^^^ meta.string.haskell string.quoted.single.haskell --- ^ punctuation.definition.string.begin.haskell --- ^ constant.character.literal.haskell --- ^ invalid.illegal.expected-closing-quotation.haskell + 'a--' +-- ^^ meta.string.haskell string.quoted.single.haskell - comment +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^^^^ comment.line.double-dash.haskell - string +-- ^^ punctuation.definition.comment.haskell + + 'a' -- literal character +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell -- ^ punctuation.definition.string.end.haskell - '\'' --- ^^^^ meta.string.haskell string.quoted.single.haskell --- ^ punctuation.definition.string.begin.haskell --- ^^ constant.character.escape.haskell + '5' -- literal digit character +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell -- ^ punctuation.definition.string.end.haskell - '\129x' --- ^^^^ meta.string.haskell string.quoted.single.haskell --- ^^^^ constant.character.escape.decimal.haskell --- ^ invalid.illegal.expected-closing-quotation.haskell --- ^ punctuation.definition.string.end.haskell + '?' -- literal symbol character +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell - 'a--' --- ^^ meta.string.haskell string.quoted.single.haskell - comment --- ^ punctuation.definition.string.begin.haskell --- ^ constant.character.literal.haskell --- ^^^^ comment.line.double-dash.haskell - string --- ^^ punctuation.definition.comment.haskell - - "\o129x\NUL" --- ^^^^^^^^^^^^ meta.string.haskell string.quoted.double.haskell --- ^^^^ constant.character.escape.octal.haskell --- ^ - constant + '\'' . '\"' . '\&' . '\\' -- escape characters +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.haskell -- ^ punctuation.definition.string.end.haskell --- ^^^^ constant.character.escape.haskell - - "ok\"()--"'ab' --- ^^^^^^^ meta.string.haskell string.quoted.double.haskell - comment --- ^^^^^^^^ comment.line.double-dash.haskell - string --- ^ punctuation.definition.string.begin.haskell --- ^^ constant.character.escape.haskell --- ^^ punctuation.definition.comment.haskell +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.haskell +-- ^ punctuation.definition.string.end.haskell + + '\a' . '\b' . '\n' . '\f' . '\t' . '\v' -- escape characters +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^^^ - meta.string - string +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^^^ - meta.string - string +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^^^ - meta.string - string +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^^^ - meta.string - string +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^^^ - meta.string - string +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.haskell +-- ^ punctuation.definition.string.end.haskell + + '\NUL' . '\SOH' . '\STX' . '\ETX' . '\EOT' . '\ENQ' . '\ACK' +-- ^^^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^^^ constant.character.escape.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^^^ - meta.string - string +-- ^^^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^^^ constant.character.escape.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^^^ - meta.string - string +-- ^^^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^^^ constant.character.escape.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^^^ - meta.string - string +-- ^^^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^^^ constant.character.escape.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^^^ - meta.string - string +-- ^^^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^^^ constant.character.escape.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^^^ - meta.string - string +-- ^^^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^^^ constant.character.escape.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^^^ - meta.string - string +-- ^^^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^^^ constant.character.escape.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ - meta.string - string + + '\0' '\1' '\2' '\3' '\4' '\5' '\6' '\7' '\8' '\9' +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.decimal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ - meta.string - string +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.decimal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ - meta.string - string +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.decimal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ - meta.string - string +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.decimal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ - meta.string - string +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.decimal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ - meta.string - string +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.decimal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ - meta.string - string +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.decimal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ - meta.string - string +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.decimal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ - meta.string - string +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.decimal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ - meta.string - string +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.decimal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ - meta.string - string + + '\o0' '\o1' '\o2' '\o3' '\o4' '\o5' '\o6' '\o7' +-- ^^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^^ constant.character.escape.octal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ - meta.string - string +-- ^^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^^ constant.character.escape.octal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ - meta.string - string +-- ^^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^^ constant.character.escape.octal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ - meta.string - string +-- ^^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^^ constant.character.escape.octal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ - meta.string - string +-- ^^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^^ constant.character.escape.octal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ - meta.string - string +-- ^^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^^ constant.character.escape.octal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ - meta.string - string +-- ^^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^^ constant.character.escape.octal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ - meta.string - string +-- ^^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^^ constant.character.escape.octal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ - meta.string - string + + '\x0' '\x1' '\x2' '\x3' '\x8' '\xA' '\xC' '\xF' +-- ^^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^^ constant.character.escape.hexadecimal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ - meta.string - string +-- ^^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^^ constant.character.escape.hexadecimal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ - meta.string - string +-- ^^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^^ constant.character.escape.hexadecimal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ - meta.string - string +-- ^^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^^ constant.character.escape.hexadecimal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ - meta.string - string +-- ^^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^^ constant.character.escape.hexadecimal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ - meta.string - string +-- ^^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^^ constant.character.escape.hexadecimal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ - meta.string - string +-- ^^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^^ constant.character.escape.hexadecimal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ - meta.string - string +-- ^^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^^ constant.character.escape.hexadecimal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ - meta.string - string + + '^A' . '^Z' . '^@' . '^[' . '^]' . '^\' . '^^' . '^_' +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.control.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^^^ - meta.string - string +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.control.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^^^ - meta.string - string +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.control.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^^^ - meta.string - string +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.control.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^^^ - meta.string - string +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.control.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^^^ - meta.string - string +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.control.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^^^ - meta.string - string +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.control.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^^^ - meta.string - string +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.control.haskell +-- ^ punctuation.definition.string.end.haskell + + +-- [ NO LITEARL CHARACTERS ]--------------------------------------------------- + + ' +-- ^ - meta.string - string +-- ^ keyword.operator.haskell - A' = A' --- ^^ constant.other.haskell - string --- ^ keyword.operator.haskell --- ^^ constant.other.haskell - string + 'a +-- ^^ - meta.string - string +-- ^ keyword.operator.haskell +-- ^ meta.name.haskell - a' = b' --- ^^ meta.name.haskell - string --- ^ keyword.operator.haskell --- ^^ meta.name.haskell - string + 'ab' +-- ^^^^ - meta.string - string +-- ^ keyword.operator.haskell +-- ^^^ meta.name.haskell + A' = A' +-- ^^^^^^^ - meta.string - string +-- ^^ constant.other.haskell - string +-- ^ keyword.operator.haskell +-- ^^ constant.other.haskell - string --- Infix operators in context + a' = b' +-- ^^^^^^^ - meta.string - string +-- ^^ meta.name.haskell - string +-- ^ keyword.operator.haskell +-- ^^ meta.name.haskell - string + + '\c' . '\z' +-- ^^^^^^^^^^^ - meta.string - string +-- ^^ keyword.operator.haskell +-- ^^ meta.name.haskell +-- ^ keyword.operator.haskell +-- ^^ keyword.operator.haskell +-- ^^ meta.name.haskell + + '\?' +-- ^^^^ keyword.operator.haskell - string + + '\129x' +-- ^^^^^^^ - meta.string - string +-- ^^ keyword.operator.haskell + + '\o8' '\o9' +-- ^^^^^^^^^^^ - meta.string - string - constant.character +-- ^^ keyword.operator.haskell +-- ^^^ meta.name.haskell +-- ^^ keyword.operator.haskell +-- ^^^ meta.name.haskell + + '\xG' '\xh' +-- ^^^^^^^^^^^ - meta.string - string - constant.character +-- ^^ keyword.operator.haskell +-- ^^^ meta.name.haskell +-- ^^ keyword.operator.haskell +-- ^^^ meta.name.haskell + + '^a' '^)' +-- ^^^^^^^^^ - meta.string - string - constant.character +-- ^^ keyword.operator.haskell +-- ^^ meta.name.haskell +-- ^^ keyword.operator.haskell +-- ^ keyword.operator.haskell + + +-- [ LITERAL STRINGS ]--------------------------------------------------------- + + "\o129x\NUL" +-- ^^^^^^^^^^^^ meta.string.haskell string.quoted.double.haskell +-- ^^^^ constant.character.escape.octal.haskell +-- ^ - constant +-- ^ punctuation.definition.string.end.haskell +-- ^^^^ constant.character.escape.haskell + + "ok\"()--"'ab' +-- ^^^^^^^ meta.string.haskell string.quoted.double.haskell - comment +-- ^^^^^^^^ comment.line.double-dash.haskell - string +-- ^ punctuation.definition.string.begin.haskell +-- ^^ constant.character.escape.haskell +-- ^^ punctuation.definition.comment.haskell + + +-- [ INFIX OPERATORS IN CONTEXT ]---------------------------------------------- data Outrageous = Flipper Record From 7477170c2be755e5b463e0bb90d1be3c1cdbae83 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 25 Dec 2020 12:33:05 +0100 Subject: [PATCH 048/178] [Haskell] Tweak test case section headers --- Haskell/syntax_test_haskell.hs | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index f4d1f9d6ff..7e26841552 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -1,5 +1,7 @@ -- SYNTAX TEST "Packages/Haskell/Haskell.sublime-syntax" +-- [ COMMENTS ] --------------------------------------------------------------- + 23*36 -- single line comment -- ^^ punctuation.definition.comment.haskell -- ^^^^^^^^^^^^^^^^^^^^^^^ comment.line.double-dash.haskell @@ -43,7 +45,7 @@ -- ^ - comment.block.haskell --- COMMENTS STARTING WITH SPECIAL SYMBOL CHARS +-- [ COMMENTS STARTING WITH SPECIAL SYMBOL CHARS ] ---------------------------- -- -- ^^^ comment @@ -75,7 +77,7 @@ -- ^^^ comment --- NO COMMENTS +-- [ NO COMMENTS ] ------------------------------------------------------------ --! -- ^^^ - comment @@ -121,7 +123,7 @@ -- ^^^ - comment ---PREPROCESSOR +-- [ PREPROCESSOR ] ----------------------------------------------------------- {-# MINIMAL traverse | sequenceA LANGUAGE #-} -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.haskell @@ -149,7 +151,7 @@ -- ^^^^^^ keyword.directive.other.c ---MODULE DECLARATIONS +-- [ MODULE DECLARATIONS ] ---------------------------------------------------- module -- ^^^^^^^ meta.declaration.module.haskell @@ -221,7 +223,7 @@ -- ^ punctuation.section.block.end.haskell ---IMPORT DECLARATIONS +-- [ IMPORT DECLARATIONS ] ---------------------------------------------------- import import -- ^^^^^^^^^^^ meta.import.haskell @@ -370,7 +372,7 @@ import Data.List.Split ((--") -- ^ punctuation.section.sequence.end.haskell ---CLASS DECLARATIONS +-- [ CLASS DECLARATIONS ] ----------------------------------------------------- class -- ^^^^^^ meta.declaration.class.haskell @@ -444,7 +446,7 @@ import Data.List.Split ((--") -- ^ variable.other.generic-type.haskell -- ^^^^^ keyword.control.context.haskell ---TYPE DECLARATIONS +-- [ TYPE DECLARATIONS ] ------------------------------------------------------ type -- ^^^^^ meta.declaration.type.haskell @@ -494,7 +496,8 @@ import Data.List.Split ((--") -- ^^^^^^^ entity.other.inherited-class.haskell -- ^ punctuation.section.sequence.end.haskell ---NEWTYPE DECLARATIONS + +-- [ NEWTYPE DECLARATIONS ] --------------------------------------------------- newtype -- ^^^^^^^^ meta.declaration.type.haskell @@ -540,7 +543,7 @@ import Data.List.Split ((--") -- ^ punctuation.section.sequence.end.haskell ---DECLARATIONS +-- [ DECLARATIONS ] ----------------------------------------------------------- -- | Map each element of a structure to an action, -- evaluate these actions from left to right, and @@ -619,7 +622,7 @@ import Data.List.Split ((--") -- ^ keyword.operator.haskell --- INFIX OPERATORS +-- [ INFIX OPERATORS ] -------------------------------------------------------- a a = (+) a 2 -- ^ keyword.operator.haskell @@ -739,7 +742,7 @@ import Data.List.Split ((--") countTheBeforeVowel = undefined ---IDENTS +-- [ IDENTS ] ----------------------------------------------------------------- genericIdent -- ^ meta.name.haskell @@ -748,7 +751,7 @@ import Data.List.Split ((--") -- ^^^^ meta.group.haskell support.function.prelude.haskell ---KEYWORDS +-- [ KEYWORDS ] --------------------------------------------------------------- deriving instance FromJSON Amount -- ^^^^^^^^ storage.modifier.haskell @@ -781,7 +784,8 @@ main = do return () -- ^^^^^^ keyword.control.flow.return.haskell ---MISC + +-- [ GROUPS / TUPLES / LISTS ] ------------------------------------------------ (group) -- ^^^^^^^ meta.group.haskell @@ -797,7 +801,7 @@ main = do -- ^ punctuation.section.sequence.end.haskell ---NUMBERS +-- [ LITERAL NUMBERS ] -------------------------------------------------------- 0 -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell From ec6bdd94fb14cf95d7bb639933c5acfbbe6ab215 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 25 Dec 2020 12:35:37 +0100 Subject: [PATCH 049/178] [Haskell] Fix variable identifier --- Haskell/Haskell.sublime-syntax | 30 +++--- Haskell/syntax_test_haskell.hs | 172 +++++++++++++++++++-------------- 2 files changed, 119 insertions(+), 83 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 8e9fefaba6..3214ca5bc5 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -12,25 +12,17 @@ file_extensions: ############################################################################### variables: - # Comments + # 2.3 Comments # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-170002.3 no_comment_ahead: '(?!{{comment_begin}})' comment_ahead: '(?={{comment_begin}})' comment_begin: '--+(?:{{comment_first_char}}|$)' comment_first_char: '[ \t\w"''(),;\[\]`{}]' - # In case this regex seems overly general, - # note that Haskell permits the definition of new operators - # which can be nearly any string of punctuation characters, - # such as $%^&*. - operator_char: '[*|!%&$@#?~+:\-.=\\''\^]' - operator_infix: '{{operator_char}}+' - operator_parens: '(?:{{no_comment_ahead}}{{operator_infix}}|,+)' - - # Identifiers + # 2.4 Identifiers and Operators # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-180002.4 con_id: (?:[[:upper:]][\w']*) - var_id: (?:(?!{{reserved_id}})[[:lower:]][\w']*) + var_id: (?:(?!{{reserved_id}})[[:lower:]_][\w']*) reserved_id: |- (?x: case | class | data | default | deriving | do | else | foreign | if @@ -39,7 +31,15 @@ variables: ){{break}} break: (?![\w']) - # Escaped Characters + # In case this regex seems overly general, + # note that Haskell permits the definition of new operators + # which can be nearly any string of punctuation characters, + # such as $%^&*. + operator_char: '[*|!%&$@#?~+:\-.=\\''\^]' + operator_infix: '{{operator_char}}+' + operator_parens: '(?:{{no_comment_ahead}}{{operator_infix}}|,+)' + + # 2.6 Character and String Literals # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-200002.6 escape_chars: |- (?x: @@ -135,6 +135,7 @@ contexts: - include: lists - include: keywords - include: ident-builtin-functions + - include: ident-anonymous - include: ident-constants - include: ident-variables @@ -351,6 +352,7 @@ contexts: - include: sequence-separators - include: ident-namespaces - include: ident-types + - include: ident-anonymous - include: ident-generic-types type-lists: @@ -618,6 +620,10 @@ contexts: - match: '{{var_id}}' scope: variable.function.haskell + ident-anonymous: + - match: _{{break}} + scope: variable.language.anonymous.haskell + ident-variables: - match: '{{var_id}}' scope: meta.name.haskell diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 7e26841552..d12184354a 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -622,77 +622,6 @@ import Data.List.Split ((--") -- ^ keyword.operator.haskell --- [ INFIX OPERATORS ] -------------------------------------------------------- - - a a = (+) a 2 --- ^ keyword.operator.haskell --- ^^^ variable.function.infix.haskell --- ^ keyword.operator.haskell --- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell - a a = (-) a 2 --- ^ keyword.operator.haskell --- ^^^ variable.function.infix.haskell --- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell - a a = (*) a 2 --- ^ keyword.operator.haskell --- ^^^ variable.function.infix.haskell --- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell - a a = (/) a 2 --- ^ keyword.operator.haskell --- ^^^ variable.function.infix.haskell --- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell - - a a = (--) a 2 --- ^ keyword.operator.haskell --- ^^^^ - variable.function.infix --- ^ punctuation.section.group.begin.haskell --- ^^^^^^^^ comment.line.double-dash.haskell - ) --- ^ punctuation.section.group.end.haskell - - a a = (---) a 2 --- ^ keyword.operator.haskell --- ^^^^^ - variable.function.infix --- ^ punctuation.section.group.begin.haskell --- ^^^^^^^^^ comment.line.double-dash.haskell - ) --- ^ punctuation.section.group.end.haskell - - a `member` x --- ^^^^^^^^ keyword.operator.function.infix.haskell --- ^ punctuation.definition.function.begin.haskell --- ^ punctuation.definition.function.end.haskell - a `P.atan2` x --- ^^^^^^^^^ keyword.operator.function.infix.haskell --- ^ punctuation.definition.function.begin.haskell --- ^ punctuation.definition.function.end.haskell - - 5 `f `7`f`"3 'ab'" --- ^ constant.numeric.value.haskell --- ^^^^ keyword.operator.function.infix.haskell --- ^ punctuation.definition.function.begin.haskell --- ^ punctuation.definition.function.end.haskell --- ^ constant.numeric.value.haskell --- ^^^ keyword.operator.function.infix.haskell --- ^ punctuation.definition.function.begin.haskell --- ^ punctuation.definition.function.end.haskell --- ^^^^^^^^ meta.string.haskell string.quoted.double.haskell --- ^ punctuation.definition.string.begin.haskell --- ^^^^^^ - constant - punctuation --- ^ punctuation.definition.string.end.haskell - - a ` f` b --- ^^^^ keyword.operator.function.infix.haskell --- ^ punctuation.definition.function.begin.haskell --- ^ punctuation.definition.function.end.haskell - - a `--` b --- ^ invalid.illegal.operator.haskell --- ^^^^^^ comment.line.double-dash.haskell - - a ` --- ^ - keyword - operator - punctuation - 'class TooMany where -- ^^^^^ keyword.declaration.class.haskell -- ^ keyword.operator.haskell @@ -744,8 +673,37 @@ import Data.List.Split ((--") -- [ IDENTS ] ----------------------------------------------------------------- + _ +-- ^ variable.language.anonymous.haskell + + a +-- ^ meta.name.haskell + + _a +-- ^^ meta.name.haskell + + _' +-- ^^ meta.name.haskell + + a' +-- ^^ meta.name.haskell + + _a'b'c_D'0123456789' +-- ^^^^^^^^^^^^^^^^^^^^ meta.name.haskell + genericIdent +-- ^^^^^^^^^^^^ meta.name.haskell + + ý ij ǚ ǣ -- ^ meta.name.haskell +-- ^ - meta.name +-- ^ meta.name.haskell +-- ^ - meta.name +-- ^ meta.name.haskell +-- ^ - meta.name +-- ^ meta.name.haskell +-- ^ - meta.name + map (flip (/)) [1..] -- ^^^ support.function.prelude.haskell -- ^^^^ meta.group.haskell support.function.prelude.haskell @@ -1219,6 +1177,78 @@ main = do -- ^^ punctuation.definition.comment.haskell +-- [ INFIX OPERATORS ] -------------------------------------------------------- + + a a = (+) a 2 +-- ^ keyword.operator.haskell +-- ^^^ variable.function.infix.haskell +-- ^ keyword.operator.haskell +-- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell + a a = (-) a 2 +-- ^ keyword.operator.haskell +-- ^^^ variable.function.infix.haskell +-- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell + a a = (*) a 2 +-- ^ keyword.operator.haskell +-- ^^^ variable.function.infix.haskell +-- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell + a a = (/) a 2 +-- ^ keyword.operator.haskell +-- ^^^ variable.function.infix.haskell +-- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell + + a a = (--) a 2 +-- ^ keyword.operator.haskell +-- ^^^^ - variable.function.infix +-- ^ punctuation.section.group.begin.haskell +-- ^^^^^^^^ comment.line.double-dash.haskell + ) +-- ^ punctuation.section.group.end.haskell + + a a = (---) a 2 +-- ^ keyword.operator.haskell +-- ^^^^^ - variable.function.infix +-- ^ punctuation.section.group.begin.haskell +-- ^^^^^^^^^ comment.line.double-dash.haskell + ) +-- ^ punctuation.section.group.end.haskell + + a `member` x +-- ^^^^^^^^ keyword.operator.function.infix.haskell +-- ^ punctuation.definition.function.begin.haskell +-- ^ punctuation.definition.function.end.haskell + a `P.atan2` x +-- ^^^^^^^^^ keyword.operator.function.infix.haskell +-- ^ punctuation.definition.function.begin.haskell +-- ^ punctuation.definition.function.end.haskell + + 5 `f `7`f`"3 'ab'" +-- ^ constant.numeric.value.haskell +-- ^^^^ keyword.operator.function.infix.haskell +-- ^ punctuation.definition.function.begin.haskell +-- ^ punctuation.definition.function.end.haskell +-- ^ constant.numeric.value.haskell +-- ^^^ keyword.operator.function.infix.haskell +-- ^ punctuation.definition.function.begin.haskell +-- ^ punctuation.definition.function.end.haskell +-- ^^^^^^^^ meta.string.haskell string.quoted.double.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^^^^^^ - constant - punctuation +-- ^ punctuation.definition.string.end.haskell + + a ` f` b +-- ^^^^ keyword.operator.function.infix.haskell +-- ^ punctuation.definition.function.begin.haskell +-- ^ punctuation.definition.function.end.haskell + + a `--` b +-- ^ invalid.illegal.operator.haskell +-- ^^^^^^ comment.line.double-dash.haskell + + a ` +-- ^ - keyword - operator - punctuation + + -- [ INFIX OPERATORS IN CONTEXT ]---------------------------------------------- data Outrageous = From fb0a7009e9721e2bb6e4566e0492cb5cfbb9b9b9 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 25 Dec 2020 14:00:43 +0100 Subject: [PATCH 050/178] [Haskell] Add some specification references --- Haskell/Haskell.sublime-syntax | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 3214ca5bc5..736c76a8c4 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -260,6 +260,8 @@ contexts: ###[ CLASS DECLARATIONS ]###################################################### classes: + # 4.3.1 Class Declarations + # https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-750004.3 - match: class{{break}} scope: keyword.declaration.class.haskell push: class-body @@ -275,6 +277,8 @@ contexts: ###[ INHERITED DECLARATIONS ]################################################## inherited: + # 4.3.3 Derived Instances + # https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-750004.3 - match: (?:deriving|via){{break}} scope: storage.modifier.haskell push: inherited-sequence @@ -297,6 +301,8 @@ contexts: ###[ INSTANCE DECLARATIONS ]################################################### instances: + # 4.3.2 Instance Declarations + # https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-750004.3 - match: instance{{break}} scope: keyword.declaration.haskell push: instance-body @@ -384,6 +390,7 @@ contexts: ###[ BLOCKS ]################################################################## blocks: + # 2.7 Layout # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-210002.7 - match: \{ scope: punctuation.section.block.begin.haskell @@ -399,6 +406,7 @@ contexts: ###[ GROUPS AND LISTS ]######################################################## groups: + # 3.9 Unit Expressions and Parenthesized Expressions # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-380003.9 - match: \( scope: punctuation.section.group.begin.haskell @@ -412,7 +420,8 @@ contexts: - include: expressions tuples: - # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-380003.9 + # 3.8 Tuples + # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-360003.8 - match: (\()(\)) scope: meta.sequence.tuple.haskell captures: @@ -420,6 +429,8 @@ contexts: 2: punctuation.section.sequence.end.haskell lists: + # 3.7 Lists + # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-340003.7 - match: \[ scope: punctuation.section.sequence.begin.haskell push: list-body @@ -434,6 +445,8 @@ contexts: ###[ LITERALS ]################################################################ literal-numbers: + # 2.5 Numeric Literals + # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-190002.5 - match: \d+(?:(\.)\d+(?:[eE][-+]?\d+)?|[eE][-+]?\d+){{break}} scope: meta.number.float.decimal.haskell constant.numeric.value.haskell captures: @@ -452,6 +465,8 @@ contexts: scope: meta.number.integer.decimal.haskell constant.numeric.value.haskell literal-chars: + # 2.6 Character and String Literals + # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-200002.6 - match: (')(?:([\ -\[\]-~])|{{escape_sequence}})(?:(')|{{comment_ahead}}) scope: meta.string.haskell string.quoted.single.haskell captures: @@ -465,6 +480,8 @@ contexts: 8: punctuation.definition.string.end.haskell literal-strings: + # 2.6 Character and String Literals + # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-200002.6 - match: \" scope: punctuation.definition.string.begin.haskell push: literal-string-body From 5fb982a9a2c0669aa962c89b1a9fdbaed2cefad8 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 25 Dec 2020 14:56:31 +0100 Subject: [PATCH 051/178] [Haskell] Fix list and tuple constructor highlighting This commit... 1. removes `,` from operators as `(,)` is a tuple constructor such as the unit expression `()` is. 2. sorts block/group/list/tuple contexts by docs headline numbers. 3. uses branching to distinguish groups and tuples. 4. adds several test cases to verify the changes. Note: Original syntax of ST and VS Code scopes such constructors `constant...`, while this commit handles those as "normal" lists and tuples. --- Haskell/Haskell.sublime-syntax | 95 ++++++++++------- Haskell/syntax_test_haskell.hs | 186 +++++++++++++++++++++++++++++++-- 2 files changed, 237 insertions(+), 44 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 736c76a8c4..571e612354 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -37,7 +37,7 @@ variables: # such as $%^&*. operator_char: '[*|!%&$@#?~+:\-.=\\''\^]' operator_infix: '{{operator_char}}+' - operator_parens: '(?:{{no_comment_ahead}}{{operator_infix}}|,+)' + operator_parens: (?:{{no_comment_ahead}}{{operator_infix}}) # 2.6 Character and String Literals # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-200002.6 @@ -129,9 +129,8 @@ contexts: - include: literal-strings - include: literal-numbers - include: operators - - include: tuples - include: splice - - include: groups + - include: groups-or-tuples - include: lists - include: keywords - include: ident-builtin-functions @@ -245,9 +244,7 @@ contexts: symbol-body: - meta_scope: meta.sequence.tuple.haskell - - match: \) - scope: punctuation.section.sequence.end.haskell - pop: 1 + - include: tuple-end - include: ident-builtin-functions - include: ident-functions - include: ident-types @@ -382,12 +379,10 @@ contexts: type-tuple-body: - meta_scope: meta.sequence.tuple.haskell - - match: \) - scope: punctuation.section.sequence.end.haskell - pop: 1 + - include: tuple-end - include: type-content -###[ BLOCKS ]################################################################## +###[ BLOCKS / GROUPS / LISTS / TUPLES ]######################################## blocks: # 2.7 Layout @@ -396,50 +391,81 @@ contexts: scope: punctuation.section.block.begin.haskell push: block-body - block-body: - - meta_scope: meta.block.haskell + block-end: - match: \} scope: punctuation.section.block.end.haskell pop: 1 - - include: main -###[ GROUPS AND LISTS ]######################################################## + block-body: + - meta_scope: meta.block.haskell + - include: block-end + - include: main - groups: - # 3.9 Unit Expressions and Parenthesized Expressions - # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-380003.9 - - match: \( - scope: punctuation.section.group.begin.haskell - push: group-body + lists: + # 3.7 Lists + # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-340003.7 + - match: \[ + scope: punctuation.section.sequence.begin.haskell + push: list-body - group-body: - - meta_scope: meta.group.haskell - - match: \) - scope: punctuation.section.group.end.haskell + list-end: + - match: \] + scope: punctuation.section.sequence.end.haskell pop: 1 + + list-body: + - meta_scope: meta.sequence.list.haskell + - include: list-end + - include: sequence-separators - include: expressions - tuples: + groups-or-tuples: # 3.8 Tuples # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-360003.8 - - match: (\()(\)) + # 3.9 Unit Expressions and Parenthesized Expressions + # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-380003.9 + - match: (\()\s*(\)) scope: meta.sequence.tuple.haskell captures: 1: punctuation.section.sequence.begin.haskell 2: punctuation.section.sequence.end.haskell + - match: (?=\() + branch_point: groups-or-tuples + branch: + - group + - tuple - lists: - # 3.7 Lists - # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-340003.7 - - match: \[ + group: + - match: \( + scope: punctuation.section.group.begin.haskell + set: group-body + + group-end: + - match: \) + scope: punctuation.section.group.end.haskell + pop: 1 + + group-body: + - meta_scope: meta.group.haskell + - include: group-end + - include: expressions + - match: ',' + fail: groups-or-tuples + + tuple: + - match: \( scope: punctuation.section.sequence.begin.haskell - push: list-body + set: tuple-body - list-body: - - meta_scope: meta.sequence.haskell - - match: \] + tuple-end: + - match: \) scope: punctuation.section.sequence.end.haskell pop: 1 + + tuple-body: + - meta_scope: meta.sequence.tuple.haskell + - include: tuple-end + - include: sequence-separators - include: expressions ###[ LITERALS ]################################################################ @@ -541,7 +567,6 @@ contexts: - match: '{{operator_infix}}' scope: keyword.operator.haskell - include: infix-parens-operators - - include: sequence-separators arrow-operators: - match: (?:->|→) diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index d12184354a..9bb7253ff1 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -743,21 +743,187 @@ main = do -- ^^^^^^ keyword.control.flow.return.haskell --- [ GROUPS / TUPLES / LISTS ] ------------------------------------------------ +-- [ BLOCKS / GROUPS / LISTS / TUPLES ] --------------------------------------- + + {} +-- ^ - meta.block +-- ^^ meta.block.haskell +-- ^ - meta.block +-- ^ punctuation.section.block.begin.haskell +-- ^ punctuation.section.block.end.haskell + + {;} +-- ^ - meta.block +-- ^^^ meta.block.haskell +-- ^ - meta.block +-- ^ punctuation.section.block.begin.haskell +-- ^ punctuation.terminator.statement.haskell +-- ^ punctuation.section.block.end.haskell + + [] +-- ^ - meta.sequence +-- ^^ meta.sequence.list.haskell +-- ^ - meta.sequence +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell - (group) --- ^^^^^^^ meta.group.haskell --- ^ punctuation.section.group.begin.haskell --- ^ punctuation.section.group.end.haskell + [,] +-- ^ - meta.sequence +-- ^^^ meta.sequence.list.haskell +-- ^ - meta.sequence +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^ punctuation.section.sequence.end.haskell - [1,2] --- ^^^^^ meta.sequence.haskell + [,,] +-- ^ - meta.sequence +-- ^^^^ meta.sequence.list.haskell +-- ^ - meta.sequence +-- ^ punctuation.section.sequence.begin.haskell +-- ^^ punctuation.separator.sequence.haskell +-- ^ punctuation.section.sequence.end.haskell + + [1,2,a,b','c',..] +-- ^ - meta.sequence +-- ^^^^^^^^^^^^^^^^^ meta.sequence.list.haskell +-- ^ - meta.sequence -- ^ punctuation.section.sequence.begin.haskell -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell -- ^ punctuation.separator.sequence.haskell -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^ meta.name.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^ meta.name.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^ keyword.operator.haskell +-- ^ punctuation.section.sequence.end.haskell + +-- List comprehension + + [ x | xs <- [ [(1,2),(3,4)], [(5,4),(3,2)] ], (3,x) <- xs ] +-- ^ - meta.sequence +-- ^^^^^^^^^^^^ meta.sequence.list.haskell - meta.sequence meta.sequence +-- ^^ meta.sequence.list.haskell meta.sequence.list.haskell - meta.sequence meta.sequence meta.sequence +-- ^ meta.sequence.list.haskell meta.sequence.list.haskell meta.sequence.list.haskell - meta.sequence meta.sequence meta.sequence meta.sequence +-- ^^^^^ meta.sequence.list.haskell meta.sequence.list.haskell meta.sequence.list.haskell meta.sequence.tuple.haskell +-- ^ meta.sequence.list.haskell meta.sequence.list.haskell meta.sequence.list.haskell - meta.sequence meta.sequence meta.sequence meta.sequence +-- ^^^^^ meta.sequence.list.haskell meta.sequence.list.haskell meta.sequence.list.haskell meta.sequence.tuple.haskell +-- ^ meta.sequence.list.haskell meta.sequence.list.haskell meta.sequence.list.haskell - meta.sequence meta.sequence meta.sequence meta.sequence +-- ^^ meta.sequence.list.haskell meta.sequence.list.haskell - meta.sequence meta.sequence meta.sequence +-- ^ meta.sequence.list.haskell meta.sequence.list.haskell meta.sequence.list.haskell - meta.sequence meta.sequence meta.sequence meta.sequence +-- ^^^^^ meta.sequence.list.haskell meta.sequence.list.haskell meta.sequence.list.haskell meta.sequence.tuple.haskell +-- ^ meta.sequence.list.haskell meta.sequence.list.haskell meta.sequence.list.haskell - meta.sequence meta.sequence meta.sequence meta.sequence +-- ^^^^^ meta.sequence.list.haskell meta.sequence.list.haskell meta.sequence.list.haskell meta.sequence.tuple.haskell +-- ^ meta.sequence.list.haskell meta.sequence.list.haskell meta.sequence.list.haskell - meta.sequence meta.sequence meta.sequence meta.sequence +-- ^^ meta.sequence.list.haskell meta.sequence.list.haskell - meta.sequence meta.sequence meta.sequence +-- ^^ meta.sequence.list.haskell - meta.sequence meta.sequence +-- ^^^^^ meta.sequence.list.haskell meta.sequence.tuple.haskell +-- ^^^^^^^^ meta.sequence.list.haskell - meta.sequence meta.sequence +-- ^ - meta.sequence +-- ^ punctuation.section.sequence.begin.haskell +-- ^ meta.name.haskell +-- ^ keyword.operator.haskell +-- ^^ meta.name.haskell +-- ^^ keyword.operator.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell +-- ^^ punctuation.section.sequence.end.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell +-- ^^ punctuation.section.sequence.end.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ constant.numeric.value.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^ meta.name.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^ keyword.operator.haskell +-- ^^ meta.name.haskell +-- ^ punctuation.section.sequence.end.haskell +-- + + () +-- ^ - meta.sequence +-- ^^ meta.sequence.tuple.haskell +-- ^ - meta.sequence +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell + + (,) +-- ^ - meta.sequence +-- ^^^ meta.sequence.tuple.haskell +-- ^ - meta.sequence +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell + + (#,#) +-- ^ - meta.sequence +-- ^^^^^ meta.sequence.tuple.haskell +-- ^ - meta.sequence +-- ^ punctuation.section.sequence.begin.haskell +-- ^ keyword.operator.haskell +-- ^ keyword.operator.haskell -- ^ punctuation.section.sequence.end.haskell + ( , , ) +-- ^ - meta.sequence +-- ^^^^^^^ meta.sequence.tuple.haskell +-- ^ - meta.sequence +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell + + (# , , #) +-- ^ - meta.sequence +-- ^^^^^^^^^ meta.sequence.tuple.haskell +-- ^ - meta.sequence +-- ^ punctuation.section.sequence.begin.haskell +-- ^ keyword.operator.haskell +-- ^ keyword.operator.haskell +-- ^ punctuation.section.sequence.end.haskell + + (group,) +-- ^^^^^^^^ meta.sequence.tuple.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^ punctuation.section.sequence.end.haskell + + (#group,#) +-- ^^^^^^^^^^ meta.sequence.tuple.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ keyword.operator.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^ keyword.operator.haskell +-- ^ punctuation.section.sequence.end.haskell + + (group) +-- ^^^^^^^ meta.group.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^ punctuation.section.group.end.haskell + -- [ LITERAL NUMBERS ] -------------------------------------------------------- @@ -1179,6 +1345,8 @@ main = do -- [ INFIX OPERATORS ] -------------------------------------------------------- + .. : :: = \ <- | -> @ ~ => + a a = (+) a 2 -- ^ keyword.operator.haskell -- ^^^ variable.function.infix.haskell @@ -1270,10 +1438,10 @@ main = do Flipper <$> genRecord , (:!) <$> genInt <*> genInt , (:@) <$> genDouble <*> genDouble --- ^^ meta.sequence.haskell variable.function.infix.haskell keyword.operator.haskell +-- ^^ variable.function.infix.haskell keyword.operator.haskell , Quux <$> genInt <*> genDouble , (:#) <$> genString <*> genRecord --- ^^ meta.sequence.haskell variable.function.infix.haskell keyword.operator.haskell +-- ^^ variable.function.infix.haskell keyword.operator.haskell , DontDoThis <$> genInt <*> genString ] [ Gen.subtermM genOutrageous (\x -> (:$) <$> genSimple <*> pure x) From 698812e9e7ba823edd7d65fd340774d59209e288 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 25 Dec 2020 15:51:50 +0100 Subject: [PATCH 052/178] [Haskell] Highlight fully qualified identifiers --- Haskell/Haskell.sublime-syntax | 1 + Haskell/syntax_test_haskell.hs | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 571e612354..33d2b5bd2c 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -135,6 +135,7 @@ contexts: - include: keywords - include: ident-builtin-functions - include: ident-anonymous + - include: ident-namespaces - include: ident-constants - include: ident-variables diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 9bb7253ff1..3cb528216a 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -704,6 +704,16 @@ import Data.List.Split ((--") -- ^ meta.name.haskell -- ^ - meta.name + T.a +-- ^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^ meta.name.haskell + + T . a +-- ^ constant.other.haskell +-- ^ keyword.operator.haskell +-- ^ meta.name.haskell + map (flip (/)) [1..] -- ^^^ support.function.prelude.haskell -- ^^^^ meta.group.haskell support.function.prelude.haskell From 7387251a14cc1ed73324ef43fe2261dfeba0f861 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 25 Dec 2020 16:13:41 +0100 Subject: [PATCH 053/178] [Haskell] Fix exported module symbol A module declaration's export symbol list may contain another module declaration, which forwards its content. --- Haskell/Haskell.sublime-syntax | 3 +++ Haskell/syntax_test_haskell.hs | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 33d2b5bd2c..d8e42ff7c2 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -246,8 +246,11 @@ contexts: symbol-body: - meta_scope: meta.sequence.tuple.haskell - include: tuple-end + - match: module{{break}} + scope: keyword.declaration.namespace.haskell - include: ident-builtin-functions - include: ident-functions + - include: ident-namespaces - include: ident-types - include: sequence-separators - include: infix-parens-operators diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 3cb528216a..169285b3e2 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -222,6 +222,30 @@ -- ^^^^^^ entity.name.namespace.haskell -- ^ punctuation.section.block.end.haskell + module Name (module Other.Module) where { import Other.Module } +-- ^^^^^^^^^^^^ meta.declaration.module.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^^^^ meta.declaration.module.haskell meta.sequence.tuple.haskell +-- ^^^^^^ meta.declaration.module.haskell - meta.sequence +-- ^ - meta.declaration - meta.block +-- ^^ meta.block.haskell - meta.import +-- ^^^^^^^^^^^^^^^^^^^^ meta.block.haskell meta.import.haskell +-- ^ meta.block.haskell - meta.import +-- ^ - meta.declaration - meta.block +-- ^^^^^^ keyword.declaration.namespace.haskell +-- ^^^^ entity.name.namespace.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^^ keyword.declaration.namespace.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^^^^ keyword.control.context.haskell +-- ^ punctuation.section.block.begin.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ entity.name.namespace.haskell +-- ^ punctuation.section.block.end.haskell -- [ IMPORT DECLARATIONS ] ---------------------------------------------------- From 767ee05c1ccbb816d4bcb6906c4d6fba23ae6319 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 25 Dec 2020 17:52:43 +0100 Subject: [PATCH 054/178] [Haskell] Add expression type signatures According to Chapter 3 'Expressions' any expression may be followed by a expression type signature which is denoted by `::`. Also scope arrows `keyword.operator` as this is how syntax calls them. --- Haskell/Haskell.sublime-syntax | 29 +++++++++++++++++++---------- Haskell/syntax_test_haskell.hs | 32 ++++++++++++++++---------------- 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index d8e42ff7c2..d01bcd570d 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -128,6 +128,7 @@ contexts: - include: literal-chars - include: literal-strings - include: literal-numbers + - include: type-signatures - include: operators - include: splice - include: groups-or-tuples @@ -272,8 +273,7 @@ contexts: - match: where{{break}} scope: keyword.control.context.haskell pop: 1 - - include: type-signatures - - include: else-pop + - include: type-signature-body ###[ INHERITED DECLARATIONS ]################################################## @@ -313,8 +313,7 @@ contexts: - match: where{{break}} scope: keyword.control.context.haskell pop: 1 - - include: type-signatures - - include: else-pop + - include: type-signature-body ###[ FUNCTION DECLARATIONS ]################################################### @@ -323,14 +322,15 @@ contexts: captures: 2: entity.name.function.haskell 3: keyword.operator.infix.haskell - 4: keyword.other.double-colon.haskell + 4: keyword.operator.double-colon.haskell push: function-body function-body: - meta_scope: meta.function.type-declaration.haskell - match: ^(?!\s*(?:--|{-|$)|\1\s) pop: 1 - - include: type-signatures + - include: big-arrow-operators + - include: type-content ###[ TYPE DECLARATIONS ]####################################################### @@ -341,16 +341,25 @@ contexts: type-body: - meta_scope: meta.declaration.type.haskell - - include: type-signatures - - include: else-pop + - include: type-signature-body ###[ TYPE SIGNATURES ]######################################################### type-signatures: + # 3 Expressions + # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html + - match: '::' + scope: keyword.operator.double-colon.haskell + push: type-signature-body + + type-signature-body: # 4.1.2 Syntax of Types # https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-750004.3 + - match: ^(?!\s*(?:--|{-|$)) + pop: 1 - include: big-arrow-operators - include: type-content + - include: else-pop type-content: - include: type-lists @@ -574,11 +583,11 @@ contexts: arrow-operators: - match: (?:->|→) - scope: keyword.other.arrow.haskell + scope: keyword.operator.arrow.haskell big-arrow-operators: - match: (?:=>|⇒) - scope: keyword.other.big-arrow.haskell + scope: keyword.operator.big-arrow.haskell infix-parens-operators: - match: \(({{operator_parens}})\) diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 169285b3e2..db60584340 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -405,7 +405,7 @@ import Data.List.Split ((--") class => -- ^^^^^^^^^ meta.declaration.class.haskell -- ^^^^^ keyword.declaration.class.haskell --- ^^ keyword.other.big-arrow.haskell +-- ^^ keyword.operator.big-arrow.haskell class QTyCls tyVar -- ^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell @@ -432,7 +432,7 @@ import Data.List.Split ((--") -- ^^^^^^ variable.other.generic-type.haskell -- ^ punctuation.separator.sequence.haskell -- ^^^^^^ variable.other.generic-type.haskell --- ^^ keyword.other.big-arrow.haskell +-- ^^ keyword.operator.big-arrow.haskell class ModId.QTyCls tyVar1, tyVar2 => Traversable t -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell @@ -443,7 +443,7 @@ import Data.List.Split ((--") -- ^^^^^^ variable.other.generic-type.haskell -- ^ punctuation.separator.sequence.haskell -- ^^^^^^ variable.other.generic-type.haskell --- ^^ keyword.other.big-arrow.haskell +-- ^^ keyword.operator.big-arrow.haskell -- ^^^^^^^^^^^ support.class.prelude.haskell -- ^ variable.other.generic-type.haskell @@ -453,7 +453,7 @@ import Data.List.Split ((--") -- ^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^ punctuation.section.sequence.end.haskell --- ^^ keyword.other.big-arrow.haskell +-- ^^ keyword.operator.big-arrow.haskell class (Functor t, Foldable t) => Traversable t where -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell @@ -465,7 +465,7 @@ import Data.List.Split ((--") -- ^^^^^^^^ storage.type.haskell -- ^ variable.other.generic-type.haskell -- ^ punctuation.section.sequence.end.haskell --- ^^ keyword.other.big-arrow.haskell +-- ^^ keyword.operator.big-arrow.haskell -- ^^^^^^^^^^^ support.class.prelude.haskell -- ^ variable.other.generic-type.haskell -- ^^^^^ keyword.control.context.haskell @@ -535,14 +535,14 @@ import Data.List.Split ((--") newtype => -- ^^^^^^^^^^^ meta.declaration.type.haskell -- ^^^^^^^ keyword.declaration.type.haskell --- ^^ keyword.other.big-arrow.haskell +-- ^^ keyword.operator.big-arrow.haskell newtype TypCls tyVar => -- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell -- ^^^^^^^ keyword.declaration.type.haskell -- ^^^^^^ storage.type.haskell -- ^^^^^ variable.other.generic-type.haskell --- ^^ keyword.other.big-arrow.haskell +-- ^^ keyword.operator.big-arrow.haskell newtype () => ModId.QTyCls tyVar1, tyVar2 deriving (Class1, QTyCls2) -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell @@ -550,7 +550,7 @@ import Data.List.Split ((--") -- ^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^ punctuation.section.sequence.end.haskell --- ^^ keyword.other.big-arrow.haskell +-- ^^ keyword.operator.big-arrow.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell @@ -615,19 +615,19 @@ import Data.List.Split ((--") traverse :: Applicative f => -- ^^^^^^^^ entity.name.function.haskell --- ^^ keyword.other.double-colon.haskell +-- ^^ keyword.operator.double-colon.haskell -- ^^^^^^^^^^^ support.class.prelude.haskell -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.type-declaration.haskell --- ^^ keyword.other.big-arrow.haskell +-- ^^ keyword.operator.big-arrow.haskell (a -> f b) -- ^^^^^^^^^^^^ meta.function.type-declaration.haskell --- ^^ keyword.other.arrow.haskell +-- ^^ keyword.operator.arrow.haskell -> t a -- ^^^^^^^^ meta.function.type-declaration.haskell --- ^^ keyword.other.arrow.haskell +-- ^^ keyword.operator.arrow.haskell -> f (t b) -- ^^^^^^^^^^^^ meta.function.type-declaration.haskell --- ^^ keyword.other.arrow.haskell +-- ^^ keyword.operator.arrow.haskell traverse f = sequenceA . fmap f -- ^ keyword.operator.haskell -- ^ keyword.operator.haskell @@ -638,10 +638,10 @@ import Data.List.Split ((--") -- 'Data.Foldable.sequenceA_'. sequenceA ∷ Applicative f ⇒ t (f a) → f (t a) -- ^^^^^^^^^ entity.name.function.haskell --- ^ keyword.other.double-colon.haskell +-- ^ keyword.operator.double-colon.haskell -- ^^^^^^^^^^^ support.class.prelude.haskell --- ^ keyword.other.big-arrow.haskell --- ^ keyword.other.arrow.haskell +-- ^ keyword.operator.big-arrow.haskell +-- ^ keyword.operator.arrow.haskell sequenceA = traverse id -- ^ keyword.operator.haskell From c2e37b2a8c1c2b0fd3bb91aa8ee7f3f52d81932b Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 25 Dec 2020 18:07:33 +0100 Subject: [PATCH 055/178] [Haskell] Fix test case indentation All tested lines are indented 4 chars. --- Haskell/syntax_test_haskell.hs | 935 +++++++++++++++++---------------- 1 file changed, 468 insertions(+), 467 deletions(-) diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index db60584340..95bbd89667 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -8,219 +8,219 @@ 23*36 -- <- - comment.line.double-dash.haskell - {- block comment -} 23*36 --- ^^ punctuation.definition.comment.begin.haskell --- ^^^^^^^^^^^^^^^^^^^ comment.block.haskell --- ^^ punctuation.definition.comment.end.haskell --- ^ - comment.block.haskell - - {- {-# #-} -} 23*36 --- ^^ punctuation.definition.comment.begin.haskell --- ^^^^^^^^^^^^^ comment.block.haskell - meta.preprocessor.haskell + {- block comment -} 23*36 +-- ^^ punctuation.definition.comment.begin.haskell +-- ^^^^^^^^^^^^^^^^^^^ comment.block.haskell +-- ^^ punctuation.definition.comment.end.haskell +-- ^ - comment.block.haskell + + {- {-# #-} -} 23*36 +-- ^^ punctuation.definition.comment.begin.haskell +-- ^^^^^^^^^^^^^ comment.block.haskell - meta.preprocessor.haskell +-- ^^ punctuation.definition.comment.end.haskell +-- ^ - comment.block.haskell + + {- {- #-} -} 23*36 +-- ^^ punctuation.definition.comment.begin.haskell +-- ^^^^^^^^^^^^ comment.block.haskell -- ^^ punctuation.definition.comment.end.haskell -- ^ - comment.block.haskell - {- {- #-} -} 23*36 --- ^^ punctuation.definition.comment.begin.haskell --- ^^^^^^^^^^^^ comment.block.haskell + {- {- -} -} 23*36 +-- ^^ punctuation.definition.comment.begin.haskell +-- ^^^^^^^^^^^ comment.block.haskell -- ^^ punctuation.definition.comment.end.haskell -- ^ - comment.block.haskell - {- {- -} -} 23*36 --- ^^ punctuation.definition.comment.begin.haskell --- ^^^^^^^^^^^ comment.block.haskell --- ^^ punctuation.definition.comment.end.haskell --- ^ - comment.block.haskell - - {- {-# -} -} 23*36 --- ^^ punctuation.definition.comment.begin.haskell --- ^^^^^^^^^^^^ comment.block.haskell - meta.preprocessor.haskell --- ^^ punctuation.definition.comment.end.haskell --- ^ - comment.block.haskell + {- {-# -} -} 23*36 +-- ^^ punctuation.definition.comment.begin.haskell +-- ^^^^^^^^^^^^ comment.block.haskell - meta.preprocessor.haskell +-- ^^ punctuation.definition.comment.end.haskell +-- ^ - comment.block.haskell - {- {-# {- test -} -} -} 23*36 --- ^^ punctuation.definition.comment.begin.haskell --- ^^^^^^^^^^^^^^^^^^^^^^^ comment.block.haskell - meta.preprocessor.haskell --- ^^ punctuation.definition.comment.end.haskell --- ^ - comment.block.haskell + {- {-# {- test -} -} -} 23*36 +-- ^^ punctuation.definition.comment.begin.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^ comment.block.haskell - meta.preprocessor.haskell +-- ^^ punctuation.definition.comment.end.haskell +-- ^ - comment.block.haskell -- [ COMMENTS STARTING WITH SPECIAL SYMBOL CHARS ] ---------------------------- - -- --- ^^^ comment - --_ --- ^^^ comment - --" --- ^^^ comment - --' --- ^^^ comment - --( --- ^^^ comment - --) --- ^^^ comment - --, --- ^^^ comment - --- --- ^^^ comment - --; --- ^^^ comment - --[ --- ^^^ comment - --] --- ^^^ comment - --` --- ^^^ comment - --{ --- ^^^ comment - --} --- ^^^ comment + -- +-- ^^^ comment + --_ +-- ^^^ comment + --" +-- ^^^ comment + --' +-- ^^^ comment + --( +-- ^^^ comment + --) +-- ^^^ comment + --, +-- ^^^ comment + --- +-- ^^^ comment + --; +-- ^^^ comment + --[ +-- ^^^ comment + --] +-- ^^^ comment + --` +-- ^^^ comment + --{ +-- ^^^ comment + --} +-- ^^^ comment -- [ NO COMMENTS ] ------------------------------------------------------------ - --! --- ^^^ - comment - --# --- ^^^ - comment - --$ --- ^^^ - comment - --% --- ^^^ - comment - --& --- ^^^ - comment - --* --- ^^^ - comment - --+ --- ^^^ - comment - --. --- ^^^ - comment - --. --- ^^^ - comment - --/ --- ^^^ - comment - --: --- ^^^ - comment - --< --- ^^^ - comment - --= --- ^^^ - comment - --> --- ^^^ - comment - --? --- ^^^ - comment - --\ --- ^^^ - comment - --\ --- ^^^ - comment - --^ --- ^^^ - comment - --| --- ^^^ - comment - --~ --- ^^^ - comment - --~ --- ^^^ - comment + --! +-- ^^^ - comment + --# +-- ^^^ - comment + --$ +-- ^^^ - comment + --% +-- ^^^ - comment + --& +-- ^^^ - comment + --* +-- ^^^ - comment + --+ +-- ^^^ - comment + --. +-- ^^^ - comment + --. +-- ^^^ - comment + --/ +-- ^^^ - comment + --: +-- ^^^ - comment + --< +-- ^^^ - comment + --= +-- ^^^ - comment + --> +-- ^^^ - comment + --? +-- ^^^ - comment + --\ +-- ^^^ - comment + --\ +-- ^^^ - comment + --^ +-- ^^^ - comment + --| +-- ^^^ - comment + --~ +-- ^^^ - comment + --~ +-- ^^^ - comment -- [ PREPROCESSOR ] ----------------------------------------------------------- - {-# MINIMAL traverse | sequenceA LANGUAGE #-} --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.haskell --- ^ - meta.preprocessor.haskell --- ^^^ punctuation.section.preprocessor.begin.haskell --- ^^^^^^^ keyword.directive.other.haskell --- ^^^^^^^ keyword.directive.other.haskell --- ^^^ punctuation.section.preprocessor.end.haskell + {-# MINIMAL traverse | sequenceA LANGUAGE #-} +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.haskell +-- ^ - meta.preprocessor.haskell +-- ^^^ punctuation.section.preprocessor.begin.haskell +-- ^^^^^^^ keyword.directive.other.haskell +-- ^^^^^^^ keyword.directive.other.haskell +-- ^^^ punctuation.section.preprocessor.end.haskell - {-# OPTIONS_HADDOCK not-home #-} --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.haskell --- ^ - meta.preprocessor.haskell --- ^^^ punctuation.section.preprocessor.begin.haskell --- ^^^^^^^^^^^^^^^ keyword.directive.other.haskell --- ^^^ punctuation.section.preprocessor.end.haskell + {-# OPTIONS_HADDOCK not-home #-} +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.haskell +-- ^ - meta.preprocessor.haskell +-- ^^^ punctuation.section.preprocessor.begin.haskell +-- ^^^^^^^^^^^^^^^ keyword.directive.other.haskell +-- ^^^ punctuation.section.preprocessor.end.haskell - #if 0 --- ^^^ meta.preprocessor.c --- ^ punctuation.definition.preprocessor.c --- ^^^ keyword.directive.other.c + #if 0 +-- ^^^ meta.preprocessor.c +-- ^ punctuation.definition.preprocessor.c +-- ^^^ keyword.directive.other.c - #endif --- ^^^^^^ meta.preprocessor.c --- ^ punctuation.definition.preprocessor.c --- ^^^^^^ keyword.directive.other.c + #endif +-- ^^^^^^ meta.preprocessor.c +-- ^ punctuation.definition.preprocessor.c +-- ^^^^^^ keyword.directive.other.c -- [ MODULE DECLARATIONS ] ---------------------------------------------------- - module --- ^^^^^^^ meta.declaration.module.haskell --- ^^^^^^ keyword.declaration.namespace.haskell - - module Name --- ^^^^^^^^^^^^ meta.declaration.module.haskell --- ^^^^^^ keyword.declaration.namespace.haskell --- ^^^^ entity.name.namespace.haskell - - module Name where --- ^^^^^^^^^^^^^^^^^ meta.declaration.module.haskell --- ^^^^^^ keyword.declaration.namespace.haskell --- ^^^^ entity.name.namespace.haskell --- ^^^^^ keyword.control.context.haskell - - module () --- ^^^^^^^ meta.declaration.module.haskell - meta.sequence --- ^^ meta.declaration.module.haskell meta.sequence.tuple.haskell --- ^^^^^^ keyword.declaration.namespace.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^ punctuation.section.sequence.end.haskell + module +-- ^^^^^^^ meta.declaration.module.haskell +-- ^^^^^^ keyword.declaration.namespace.haskell - module Name () --- ^^^^^^^^^^^^ meta.declaration.module.haskell - meta.sequence --- ^^ meta.declaration.module.haskell meta.sequence.tuple.haskell --- ^^^^^^ keyword.declaration.namespace.haskell --- ^^^^ entity.name.namespace.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^ punctuation.section.sequence.end.haskell - - module Name () where --- ^^^^^^^^^^^^ meta.declaration.module.haskell - meta.sequence --- ^^ meta.declaration.module.haskell meta.sequence.tuple.haskell --- ^^^^^ meta.declaration.module.haskell - meta.sequence --- ^^^^^^ keyword.declaration.namespace.haskell --- ^^^^ entity.name.namespace.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^ punctuation.section.sequence.end.haskell --- ^^^^^ keyword.control.context.haskell - - module Ns.Name (sym1, sym2) where { import Ns.Other; import Ns.Other2 } --- ^^^^^^^^^^^^^^^ meta.declaration.module.haskell - meta.sequence --- ^^^^^^^^^^^^ meta.declaration.module.haskell meta.sequence.tuple.haskell --- ^^^^^^ meta.declaration.module.haskell - meta.sequence --- ^ - meta.declaration.module - meta.block --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.haskell - meta.declaration.module --- ^ - meta.block --- ^^^^^^ keyword.declaration.namespace.haskell --- ^^ variable.namespace.haskell --- ^ punctuation.accessor.dot.haskell --- ^^^^ entity.name.namespace.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^^^ variable.function.haskell --- ^ punctuation.separator.sequence.haskell --- ^^^^ variable.function.haskell --- ^ punctuation.section.sequence.end.haskell --- ^^^^^ keyword.control.context.haskell --- ^ punctuation.section.block.begin.haskell --- ^^^^^^ keyword.declaration.import.haskell --- ^^ variable.namespace.haskell --- ^ punctuation.accessor.dot.haskell --- ^^^^^ entity.name.namespace.haskell --- ^ punctuation.terminator.statement.haskell --- ^^^^^^ keyword.declaration.import.haskell --- ^^ variable.namespace.haskell --- ^ punctuation.accessor.dot.haskell --- ^^^^^^ entity.name.namespace.haskell --- ^ punctuation.section.block.end.haskell + module Name +-- ^^^^^^^^^^^^ meta.declaration.module.haskell +-- ^^^^^^ keyword.declaration.namespace.haskell +-- ^^^^ entity.name.namespace.haskell + + module Name where +-- ^^^^^^^^^^^^^^^^^ meta.declaration.module.haskell +-- ^^^^^^ keyword.declaration.namespace.haskell +-- ^^^^ entity.name.namespace.haskell +-- ^^^^^ keyword.control.context.haskell + + module () +-- ^^^^^^^ meta.declaration.module.haskell - meta.sequence +-- ^^ meta.declaration.module.haskell meta.sequence.tuple.haskell +-- ^^^^^^ keyword.declaration.namespace.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell + + module Name () +-- ^^^^^^^^^^^^ meta.declaration.module.haskell - meta.sequence +-- ^^ meta.declaration.module.haskell meta.sequence.tuple.haskell +-- ^^^^^^ keyword.declaration.namespace.haskell +-- ^^^^ entity.name.namespace.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell + + module Name () where +-- ^^^^^^^^^^^^ meta.declaration.module.haskell - meta.sequence +-- ^^ meta.declaration.module.haskell meta.sequence.tuple.haskell +-- ^^^^^ meta.declaration.module.haskell - meta.sequence +-- ^^^^^^ keyword.declaration.namespace.haskell +-- ^^^^ entity.name.namespace.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^^^^ keyword.control.context.haskell + + module Ns.Name (sym1, sym2) where { import Ns.Other; import Ns.Other2 } +-- ^^^^^^^^^^^^^^^ meta.declaration.module.haskell - meta.sequence +-- ^^^^^^^^^^^^ meta.declaration.module.haskell meta.sequence.tuple.haskell +-- ^^^^^^ meta.declaration.module.haskell - meta.sequence +-- ^ - meta.declaration.module - meta.block +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.haskell - meta.declaration.module +-- ^ - meta.block +-- ^^^^^^ keyword.declaration.namespace.haskell +-- ^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^ entity.name.namespace.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^ variable.function.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^ variable.function.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^^^^ keyword.control.context.haskell +-- ^ punctuation.section.block.begin.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^ entity.name.namespace.haskell +-- ^ punctuation.terminator.statement.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ entity.name.namespace.haskell +-- ^ punctuation.section.block.end.haskell module Name (module Other.Module) where { import Other.Module } -- ^^^^^^^^^^^^ meta.declaration.module.haskell - meta.sequence @@ -249,173 +249,243 @@ -- [ IMPORT DECLARATIONS ] ---------------------------------------------------- -import import --- ^^^^^^^^^^^ meta.import.haskell --- ^^^ keyword.declaration.import.haskell --- ^^^^^^ keyword.declaration.import.haskell - -import ; import --- ^^^^ meta.import.haskell --- ^ - meta.import --- ^^^^^^^ meta.import.haskell --- ^^^ keyword.declaration.import.haskell --- ^ punctuation.terminator.statement.haskell --- ^^^^^^ meta.import.haskell keyword.declaration.import.haskell - -import qualified Data.Vector.Mutable as MutableVector --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell --- ^^^ keyword.declaration.import.haskell --- ^^^^^^^^^ keyword.declaration.import.haskell --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^^ variable.namespace.haskell - punctuation --- ^^ keyword.declaration.import.haskell --- ^^^^^^^^^^^^^ entity.name.namespace.haskell - -import --- ^^^^ meta.import.haskell --- ^^^ keyword.declaration.import.haskell - qualified --- ^^^^^^^^^^ meta.import.haskell --- ^^^^^^^^^ keyword.declaration.import.haskell - Data.Vector.Mutable --- ^^^^^^^^^^^^^^^^^^^^ meta.import.haskell --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^^ entity.name.namespace.haskell - punctuation - as --- ^^^ meta.import.haskell --- ^^ keyword.declaration.import.haskell - MutableVector --- ^^^^^^^^^^^^^^ meta.import.haskell --- ^^^^^^^^^^^^^ entity.name.namespace.haskell - -import Data.List.Split (splitOn) --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell --- ^^^ keyword.declaration.import.haskell --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^^^^^ meta.sequence.tuple.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^^^^^^ variable.function.haskell --- ^ punctuation.section.sequence.end.haskell - -import Data.List.Split (()) --- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell --- ^^^ keyword.declaration.import.haskell --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^ meta.sequence.tuple.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^ meta.other.unknown.haskell --- ^ punctuation.section.sequence.end.haskell - -import Data.List.Split (-- --- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell --- ^^^ keyword.declaration.import.haskell --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^ meta.sequence.tuple.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^^ comment.line.double-dash.haskell --- ^^ punctuation.definition.comment.haskell - ) --- ^ punctuation.section.sequence.end.haskell - -import Data.List.Split (--) --- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell --- ^^^ keyword.declaration.import.haskell --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^ meta.sequence.tuple.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^^^ comment.line.double-dash.haskell --- ^^ punctuation.definition.comment.haskell - ) --- ^ punctuation.section.sequence.end.haskell - -import Data.List.Split ((--)) --- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell --- ^^^ keyword.declaration.import.haskell --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^^^ meta.sequence.tuple.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^^^^ comment.line.double-dash.haskell --- ^^ punctuation.definition.comment.haskell - ) --- ^ punctuation.section.sequence.end.haskell - -import Data.List.Split ((--]) --- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell --- ^^^ keyword.declaration.import.haskell --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^^^ meta.sequence.tuple.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^^^^ comment.line.double-dash.haskell --- ^^ punctuation.definition.comment.haskell - ) --- ^ punctuation.section.sequence.end.haskell - -import Data.List.Split ((--") --- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell --- ^^^ keyword.declaration.import.haskell --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^^^ meta.sequence.tuple.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^^^^ comment.line.double-dash.haskell --- ^^ punctuation.definition.comment.haskell - ) --- ^ punctuation.section.sequence.end.haskell + import import +-- ^ - meta.import +-- ^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^^^^^ keyword.declaration.import.haskell + + import ; import +-- ^^^^^^^ meta.import.haskell +-- ^^ - meta.import +-- ^^^^^^^ meta.import.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^ punctuation.terminator.statement.haskell +-- ^^^^^^ meta.import.haskell keyword.declaration.import.haskell + + import qualified Data.Vector.Mutable as MutableVector +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^^^^^^^^ keyword.declaration.import.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^^^ variable.namespace.haskell - punctuation +-- ^^ keyword.declaration.import.haskell +-- ^^^^^^^^^^^^^ entity.name.namespace.haskell + + import +-- ^^^^^^^ meta.import.haskell +-- ^^^^^^ keyword.declaration.import.haskell + qualified +-- ^^^^^^^^^^ meta.import.haskell +-- ^^^^^^^^^ keyword.declaration.import.haskell + Data.Vector.Mutable +-- ^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^^^ entity.name.namespace.haskell - punctuation + as +-- ^^^ meta.import.haskell +-- ^^ keyword.declaration.import.haskell + MutableVector +-- ^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^^^^^^^^^^^ entity.name.namespace.haskell + + import Data.List.Split (splitOn) +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^^^^^ meta.sequence.tuple.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^^^ variable.function.haskell +-- ^ punctuation.section.sequence.end.haskell + + import Data.List.Split (()) +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^ variable.namespace.haskell - punctuation +-- ^^^^ meta.sequence.tuple.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^ meta.other.unknown.haskell +-- ^ punctuation.section.sequence.end.haskell + + import Data.List.Split (-- +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^ meta.sequence.tuple.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^ comment.line.double-dash.haskell +-- ^^ punctuation.definition.comment.haskell + ) +-- ^ punctuation.section.sequence.end.haskell + + import Data.List.Split (--) +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^ meta.sequence.tuple.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^ comment.line.double-dash.haskell +-- ^^ punctuation.definition.comment.haskell + ) +-- ^ punctuation.section.sequence.end.haskell + + import Data.List.Split ((--)) +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^^^ meta.sequence.tuple.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^ comment.line.double-dash.haskell +-- ^^ punctuation.definition.comment.haskell + ) +-- ^ punctuation.section.sequence.end.haskell + + import Data.List.Split ((--]) +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^^^ meta.sequence.tuple.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^ comment.line.double-dash.haskell +-- ^^ punctuation.definition.comment.haskell + ) +-- ^ punctuation.section.sequence.end.haskell + + import Data.List.Split ((--") +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^^^ meta.sequence.tuple.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^ comment.line.double-dash.haskell +-- ^^ punctuation.definition.comment.haskell + ) +-- ^ punctuation.section.sequence.end.haskell -- [ CLASS DECLARATIONS ] ----------------------------------------------------- - class --- ^^^^^^ meta.declaration.class.haskell --- ^^^^^ keyword.declaration.class.haskell + class +-- ^^^^^^ meta.declaration.class.haskell +-- ^^^^^ keyword.declaration.class.haskell + + class => +-- ^^^^^^^^^ meta.declaration.class.haskell +-- ^^^^^ keyword.declaration.class.haskell +-- ^^ keyword.operator.big-arrow.haskell + + class QTyCls tyVar +-- ^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell +-- ^^^^^ keyword.declaration.class.haskell +-- ^^^^^^ storage.type.haskell +-- ^^^^^ variable.other.generic-type.haskell + + class ModId.QTyCls tyVar1, tyVar2 +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell +-- ^^^^^ keyword.declaration.class.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^ variable.other.generic-type.haskell + + class ModId.QTyCls tyVar1, tyVar2 => +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell +-- ^^^^^ keyword.declaration.class.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^^ keyword.operator.big-arrow.haskell + + class ModId.QTyCls tyVar1, tyVar2 => Traversable t +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell +-- ^^^^^ keyword.declaration.class.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^^ keyword.operator.big-arrow.haskell +-- ^^^^^^^^^^^ support.class.prelude.haskell +-- ^ variable.other.generic-type.haskell + + class () => +-- ^^^^^^^^^^^^ meta.declaration.class.haskell +-- ^^^^^ keyword.declaration.class.haskell +-- ^^ meta.sequence.tuple.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^ keyword.operator.big-arrow.haskell + + class (Functor t, Foldable t) => Traversable t where +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell +-- ^^^^^ keyword.declaration.class.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^^^ support.class.prelude.haskell +-- ^ variable.other.generic-type.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^^ storage.type.haskell +-- ^ variable.other.generic-type.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^ keyword.operator.big-arrow.haskell +-- ^^^^^^^^^^^ support.class.prelude.haskell +-- ^ variable.other.generic-type.haskell +-- ^^^^^ keyword.control.context.haskell - class => --- ^^^^^^^^^ meta.declaration.class.haskell --- ^^^^^ keyword.declaration.class.haskell --- ^^ keyword.operator.big-arrow.haskell +-- [ TYPE DECLARATIONS ] ------------------------------------------------------ + + type +-- ^^^^^ meta.declaration.type.haskell +-- ^^^^ keyword.declaration.type.haskell - class QTyCls tyVar --- ^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell --- ^^^^^ keyword.declaration.class.haskell + type QTyCls tyVar +-- ^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^ keyword.declaration.type.haskell -- ^^^^^^ storage.type.haskell -- ^^^^^ variable.other.generic-type.haskell - class ModId.QTyCls tyVar1, tyVar2 --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell --- ^^^^^ keyword.declaration.class.haskell + type ModId.QTyCls tyVar1, tyVar2 +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^ keyword.declaration.type.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell @@ -423,148 +493,79 @@ import Data.List.Split ((--") -- ^ punctuation.separator.sequence.haskell -- ^^^^^^ variable.other.generic-type.haskell - class ModId.QTyCls tyVar1, tyVar2 => --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell --- ^^^^^ keyword.declaration.class.haskell + type ModId.QTyCls tyVar1, tyVar2 = +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^ keyword.declaration.type.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell -- ^^^^^^ variable.other.generic-type.haskell -- ^ punctuation.separator.sequence.haskell -- ^^^^^^ variable.other.generic-type.haskell --- ^^ keyword.operator.big-arrow.haskell - class ModId.QTyCls tyVar1, tyVar2 => Traversable t --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell --- ^^^^^ keyword.declaration.class.haskell + type ModId.QTyCls tyVar1, tyVar2 deriving (Class1, QTyCls2) +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^ keyword.declaration.type.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell -- ^^^^^^ variable.other.generic-type.haskell -- ^ punctuation.separator.sequence.haskell -- ^^^^^^ variable.other.generic-type.haskell --- ^^ keyword.operator.big-arrow.haskell --- ^^^^^^^^^^^ support.class.prelude.haskell --- ^ variable.other.generic-type.haskell - - class () => --- ^^^^^^^^^^^^ meta.declaration.class.haskell --- ^^^^^ keyword.declaration.class.haskell --- ^^ meta.sequence.tuple.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^ punctuation.section.sequence.end.haskell --- ^^ keyword.operator.big-arrow.haskell - - class (Functor t, Foldable t) => Traversable t where --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell --- ^^^^^ keyword.declaration.class.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^^^^^^ support.class.prelude.haskell --- ^ variable.other.generic-type.haskell --- ^ punctuation.separator.sequence.haskell --- ^^^^^^^^ storage.type.haskell --- ^ variable.other.generic-type.haskell --- ^ punctuation.section.sequence.end.haskell --- ^^ keyword.operator.big-arrow.haskell --- ^^^^^^^^^^^ support.class.prelude.haskell --- ^ variable.other.generic-type.haskell --- ^^^^^ keyword.control.context.haskell - --- [ TYPE DECLARATIONS ] ------------------------------------------------------ - - type --- ^^^^^ meta.declaration.type.haskell --- ^^^^ keyword.declaration.type.haskell - - type QTyCls tyVar --- ^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell --- ^^^^ keyword.declaration.type.haskell --- ^^^^^^ storage.type.haskell --- ^^^^^ variable.other.generic-type.haskell - - type ModId.QTyCls tyVar1, tyVar2 --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell --- ^^^^ keyword.declaration.type.haskell --- ^^^^^ variable.namespace.haskell --- ^ punctuation.accessor.dot.haskell --- ^^^^^^ storage.type.haskell --- ^^^^^^ variable.other.generic-type.haskell --- ^ punctuation.separator.sequence.haskell --- ^^^^^^ variable.other.generic-type.haskell - - type ModId.QTyCls tyVar1, tyVar2 = --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell --- ^^^^ keyword.declaration.type.haskell --- ^^^^^ variable.namespace.haskell --- ^ punctuation.accessor.dot.haskell --- ^^^^^^ storage.type.haskell --- ^^^^^^ variable.other.generic-type.haskell --- ^ punctuation.separator.sequence.haskell --- ^^^^^^ variable.other.generic-type.haskell - - type ModId.QTyCls tyVar1, tyVar2 deriving (Class1, QTyCls2) --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell --- ^^^^ keyword.declaration.type.haskell --- ^^^^^ variable.namespace.haskell --- ^ punctuation.accessor.dot.haskell --- ^^^^^^ storage.type.haskell --- ^^^^^^ variable.other.generic-type.haskell --- ^ punctuation.separator.sequence.haskell --- ^^^^^^ variable.other.generic-type.haskell --- ^^^^^^^^^ meta.deriving.haskell - meta.sequence --- ^^^^^^^^^^^^^^^^^ meta.deriving.haskell meta.sequence.tuple.haskell --- ^^^^^^^^ storage.modifier.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^^^^^ entity.other.inherited-class.haskell --- ^ punctuation.separator.sequence.haskell --- ^^^^^^^ entity.other.inherited-class.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^^^^^^^^^ meta.deriving.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^ meta.deriving.haskell meta.sequence.tuple.haskell +-- ^^^^^^^^ storage.modifier.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^^ entity.other.inherited-class.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^ entity.other.inherited-class.haskell +-- ^ punctuation.section.sequence.end.haskell -- [ NEWTYPE DECLARATIONS ] --------------------------------------------------- - newtype --- ^^^^^^^^ meta.declaration.type.haskell --- ^^^^^^^ keyword.declaration.type.haskell + newtype +-- ^^^^^^^^ meta.declaration.type.haskell +-- ^^^^^^^ keyword.declaration.type.haskell - newtype = --- ^^^^^^^^ meta.declaration.type.haskell --- ^^^^^^^ keyword.declaration.type.haskell --- ^ keyword.operator.haskell + newtype = +-- ^^^^^^^^ meta.declaration.type.haskell +-- ^^^^^^^ keyword.declaration.type.haskell +-- ^ keyword.operator.haskell - newtype => --- ^^^^^^^^^^^ meta.declaration.type.haskell --- ^^^^^^^ keyword.declaration.type.haskell --- ^^ keyword.operator.big-arrow.haskell - - newtype TypCls tyVar => --- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell --- ^^^^^^^ keyword.declaration.type.haskell --- ^^^^^^ storage.type.haskell --- ^^^^^ variable.other.generic-type.haskell --- ^^ keyword.operator.big-arrow.haskell - - newtype () => ModId.QTyCls tyVar1, tyVar2 deriving (Class1, QTyCls2) --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell --- ^^^^ keyword.declaration.type.haskell --- ^^ meta.sequence.tuple.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^ punctuation.section.sequence.end.haskell --- ^^ keyword.operator.big-arrow.haskell --- ^^^^^ variable.namespace.haskell --- ^ punctuation.accessor.dot.haskell --- ^^^^^^ storage.type.haskell --- ^^^^^^ variable.other.generic-type.haskell --- ^ punctuation.separator.sequence.haskell --- ^^^^^^ variable.other.generic-type.haskell --- ^^^^^^^^^ meta.deriving.haskell - meta.sequence --- ^^^^^^^^^^^^^^^^^ meta.deriving.haskell meta.sequence.tuple.haskell --- ^^^^^^^^ storage.modifier.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^^^^^ entity.other.inherited-class.haskell --- ^ punctuation.separator.sequence.haskell --- ^^^^^^^ entity.other.inherited-class.haskell --- ^ punctuation.section.sequence.end.haskell + newtype => +-- ^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^^^^ keyword.declaration.type.haskell +-- ^^ keyword.operator.big-arrow.haskell + + newtype TypCls tyVar => +-- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^^^^ keyword.declaration.type.haskell +-- ^^^^^^ storage.type.haskell +-- ^^^^^ variable.other.generic-type.haskell +-- ^^ keyword.operator.big-arrow.haskell + + newtype () => ModId.QTyCls tyVar1, tyVar2 deriving (Class1, QTyCls2) +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^ keyword.declaration.type.haskell +-- ^^ meta.sequence.tuple.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^ keyword.operator.big-arrow.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^^^^^^^^^ meta.deriving.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^ meta.deriving.haskell meta.sequence.tuple.haskell +-- ^^^^^^^^ storage.modifier.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^^ entity.other.inherited-class.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^ entity.other.inherited-class.haskell +-- ^ punctuation.section.sequence.end.haskell -- [ DECLARATIONS ] ----------------------------------------------------------- From f7935fd3abde76beaba2910ef522048e3542041a Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 25 Dec 2020 18:17:08 +0100 Subject: [PATCH 056/178] [Haskell] Fix default declaration statements --- Haskell/Haskell.sublime-syntax | 17 ++++++++++++++++- Haskell/syntax_test_haskell.hs | 27 +++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index d01bcd570d..55b284c2c8 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -119,6 +119,7 @@ contexts: - include: inherited - include: instances - include: classes + - include: defaults - include: types - include: imports - include: modules @@ -275,6 +276,20 @@ contexts: pop: 1 - include: type-signature-body +###[ DEFAULT DECLARATIONS ]#################################################### + + defaults: + # 4.3.4 Ambiguous Types, and Defaults for Overloaded Numeric Operations + # https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-750004.3 + - match: default{{break}} + scope: storage.modifier.haskell + push: default-body + + default-body: + - meta_scope: meta.declaration.default.haskell + - include: type-tuples + - include: else-pop + ###[ INHERITED DECLARATIONS ]################################################## inherited: @@ -556,7 +571,7 @@ contexts: scope: keyword.declaration.variable.haskell - match: (?:return){{break}} scope: keyword.control.flow.return.haskell - - match: (?:default|otherwise){{break}} + - match: (?:otherwise){{break}} scope: keyword.other.haskell - match: (?:if){{break}} scope: keyword.control.conditional.if.haskell diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 95bbd89667..313e2ca6a4 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -471,6 +471,33 @@ -- ^ variable.other.generic-type.haskell -- ^^^^^ keyword.control.context.haskell + +-- [ DEFAULT DECLARATIONS ] --------------------------------------------------- + + default +-- ^^^^^^^^ meta.declaration.default.haskell +-- ^^^^^^^ storage.modifier.haskell + + default () +-- ^^^^^^^^ meta.declaration.default.haskell - meta.sequence +-- ^^ meta.declaration.default.haskell meta.sequence.tuple.haskell +-- ^^^^^^^ storage.modifier.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell + + default (TyCls, ModId.QTyCls) +-- ^^^^^^^^ meta.declaration.default.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^^^^ meta.declaration.default.haskell meta.sequence.tuple.haskell +-- ^^^^^^^ storage.modifier.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^ storage.type.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^ punctuation.section.sequence.end.haskell + + -- [ TYPE DECLARATIONS ] ------------------------------------------------------ type From 90f5a72c29427b51edbfa1ec8cb6b89cd9a2f9fe Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 25 Dec 2020 18:52:04 +0100 Subject: [PATCH 057/178] [Haskel] Fix deriving declaration statements A `deriving` statement may contain a single constructor identifier or a tuple of constructors. --- Haskell/Haskell.sublime-syntax | 31 +++++++++----- Haskell/syntax_test_haskell.hs | 74 ++++++++++++++++++++++++++++------ 2 files changed, 82 insertions(+), 23 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 55b284c2c8..24a3240333 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -116,10 +116,10 @@ contexts: statements: - include: blocks - include: functions - - include: inherited - include: instances - include: classes - include: defaults + - include: deriving - include: types - include: imports - include: modules @@ -290,29 +290,32 @@ contexts: - include: type-tuples - include: else-pop -###[ INHERITED DECLARATIONS ]################################################## +###[ DERIVING DECLARATIONS ]################################################### - inherited: + deriving: # 4.3.3 Derived Instances # https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-750004.3 - match: (?:deriving|via){{break}} scope: storage.modifier.haskell - push: inherited-sequence + push: deriving-body - inherited-sequence: - - meta_scope: meta.deriving.haskell + deriving-body: + - meta_scope: meta.declaration.deriving.haskell - match: \( scope: punctuation.section.sequence.begin.haskell - push: inherited-sequence-body + push: deriving-tuple-body + - include: ident-namespaces + - include: ident-inherited-class - include: else-pop - inherited-sequence-body: + deriving-tuple-body: - meta_scope: meta.sequence.tuple.haskell - match: \) scope: punctuation.section.sequence.end.haskell pop: 2 - include: sequence-separators - - include: ident-inherited-classs + - include: ident-namespaces + - include: ident-inherited-classes ###[ INSTANCE DECLARATIONS ]################################################### @@ -658,11 +661,19 @@ contexts: - match: '{{class_names}}' scope: support.class.prelude.haskell - ident-inherited-classs: + ident-inherited-classes: - include: ident-builtin-classes - match: '{{con_id}}' scope: entity.other.inherited-class.haskell + ident-inherited-class: + - match: '{{class_names}}' + scope: support.class.prelude.haskell + pop: 1 + - match: '{{con_id}}' + scope: entity.other.inherited-class.haskell + pop: 1 + ident-generic-types: - match: '{{var_id}}' scope: variable.other.generic-type.haskell diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 313e2ca6a4..e5b5bbb465 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -498,6 +498,52 @@ -- ^ punctuation.section.sequence.end.haskell +-- [ DERIVING DECLARATIONS ] -------------------------------------------------- + + deriving +-- ^^^^^^^^^ meta.declaration.deriving.haskell +-- ^^^^^^^^ storage.modifier.haskell + + deriving TyCls Const +-- ^^^^^^^^^^^^^^ meta.declaration.deriving.haskell +-- ^^^^^^ - meta.declaration +-- ^^^^^^^^ storage.modifier.haskell +-- ^^^^^ entity.other.inherited-class.haskell +-- ^^^^^ constant.other.haskell + + deriving ModId.QTyCls ModId.Const +-- ^^^^^^^^^^^^^^^^^^^^^ meta.declaration.deriving.haskell +-- ^^^^^^^^^^^^ - meta.declaration +-- ^^^^^^^^ storage.modifier.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ entity.other.inherited-class.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^ constant.other.haskell + + deriving () +-- ^^^^^^^^^ meta.declaration.deriving.haskell - meta.sequence +-- ^^ meta.declaration.deriving.haskell meta.sequence.tuple.haskell +-- ^ - meta.declaration +-- ^^^^^^^^ storage.modifier.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell + + deriving (TyCls, ModId.QTyCls) +-- ^^^^^^^^^ meta.declaration.deriving.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^^^^ meta.declaration.deriving.haskell meta.sequence.tuple.haskell +-- ^ - meta.declaration +-- ^^^^^^^^ storage.modifier.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^ entity.other.inherited-class.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ entity.other.inherited-class.haskell +-- ^ punctuation.section.sequence.end.haskell + + -- [ TYPE DECLARATIONS ] ------------------------------------------------------ type @@ -532,6 +578,9 @@ type ModId.QTyCls tyVar1, tyVar2 deriving (Class1, QTyCls2) -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^^^^^^ meta.declaration.deriving.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^ meta.declaration.deriving.haskell meta.sequence.tuple.haskell +-- ^ - meta.declaration -- ^^^^ keyword.declaration.type.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell @@ -539,8 +588,6 @@ -- ^^^^^^ variable.other.generic-type.haskell -- ^ punctuation.separator.sequence.haskell -- ^^^^^^ variable.other.generic-type.haskell --- ^^^^^^^^^ meta.deriving.haskell - meta.sequence --- ^^^^^^^^^^^^^^^^^ meta.deriving.haskell meta.sequence.tuple.haskell -- ^^^^^^^^ storage.modifier.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^^^^ entity.other.inherited-class.haskell @@ -574,6 +621,9 @@ newtype () => ModId.QTyCls tyVar1, tyVar2 deriving (Class1, QTyCls2) -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^^^^^^ meta.declaration.deriving.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^ meta.declaration.deriving.haskell meta.sequence.tuple.haskell +-- ^ - meta.declaration -- ^^^^ keyword.declaration.type.haskell -- ^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell @@ -585,8 +635,6 @@ -- ^^^^^^ variable.other.generic-type.haskell -- ^ punctuation.separator.sequence.haskell -- ^^^^^^ variable.other.generic-type.haskell --- ^^^^^^^^^ meta.deriving.haskell - meta.sequence --- ^^^^^^^^^^^^^^^^^ meta.deriving.haskell meta.sequence.tuple.haskell -- ^^^^^^^^ storage.modifier.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^^^^ entity.other.inherited-class.haskell @@ -610,9 +658,9 @@ , recordDouble :: Double , recordRational :: Rational } deriving (Eq, Ord, Generic) --- ^^^^^^^^^ meta.deriving.haskell - meta.sequence --- ^^^^^^^^^^^^^^^^^^ meta.deriving.haskell meta.sequence.tuple.haskell --- ^ - meta.deriving - meta.sequence +-- ^^^^^^^^^ meta.declaration.deriving.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^ meta.declaration.deriving.haskell meta.sequence.tuple.haskell +-- ^ - meta.declaration.deriving - meta.sequence -- ^^^^^^^^ storage.modifier.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^ support.class.prelude.haskell @@ -622,12 +670,12 @@ -- ^^^^^^^ entity.other.inherited-class.haskell -- ^ punctuation.section.sequence.end.haskell deriving (Read, Show) via (Quiet Record) --- ^^^^^^^^^ meta.deriving.haskell - meta.sequence --- ^^^^^^^^^^^^ meta.deriving.haskell meta.sequence.tuple.haskell --- ^ - meta.deriving - meta.sequence --- ^^^^ meta.deriving.haskell - meta.sequence --- ^^^^^^^^^^^^^^ meta.deriving.haskell meta.sequence.tuple.haskell --- ^ - meta.deriving - meta.sequence +-- ^^^^^^^^^ meta.declaration.deriving.haskell - meta.sequence +-- ^^^^^^^^^^^^ meta.declaration.deriving.haskell meta.sequence.tuple.haskell +-- ^ - meta.declaration.deriving - meta.sequence +-- ^^^^ meta.declaration.deriving.haskell - meta.sequence +-- ^^^^^^^^^^^^^^ meta.declaration.deriving.haskell meta.sequence.tuple.haskell +-- ^ - meta.declaration.deriving - meta.sequence -- ^^^^^^^^ storage.modifier.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^^ support.class.prelude.haskell From 97fa8a0978314d6b0d0c1c72a89fd6f4ed6a207c Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 25 Dec 2020 22:00:17 +0100 Subject: [PATCH 058/178] [Haskell] Add some keyword boundary tests --- Haskell/syntax_test_haskell.hs | 57 +++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index e5b5bbb465..6281626db3 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -153,6 +153,13 @@ -- [ MODULE DECLARATIONS ] ---------------------------------------------------- + 'module +-- ^ keyword.operator.haskell +-- ^^^^^^ keyword.declaration.namespace.haskell + + module' +-- ^^^^^^^ - keyword + module -- ^^^^^^^ meta.declaration.module.haskell -- ^^^^^^ keyword.declaration.namespace.haskell @@ -249,6 +256,13 @@ -- [ IMPORT DECLARATIONS ] ---------------------------------------------------- + 'import +-- ^ keyword.operator.haskell +-- ^^^^^^ keyword.declaration.import.haskell + + import' +-- ^^^^^^^ - keyword + import import -- ^ - meta.import -- ^^^^^^^^^^^^^^ meta.import.haskell @@ -471,6 +485,13 @@ -- ^ variable.other.generic-type.haskell -- ^^^^^ keyword.control.context.haskell + 'class +-- ^ keyword.operator.haskell +-- ^^^^^ keyword.declaration.class.haskell + + class' +-- ^^^^^^ - keyword + -- [ DEFAULT DECLARATIONS ] --------------------------------------------------- @@ -478,6 +499,13 @@ -- ^^^^^^^^ meta.declaration.default.haskell -- ^^^^^^^ storage.modifier.haskell + 'default +-- ^ keyword.operator.haskell +-- ^^^^^^^ storage.modifier.haskell + + default' +-- ^^^^^^^^ - keyword + default () -- ^^^^^^^^ meta.declaration.default.haskell - meta.sequence -- ^^ meta.declaration.default.haskell meta.sequence.tuple.haskell @@ -504,6 +532,13 @@ -- ^^^^^^^^^ meta.declaration.deriving.haskell -- ^^^^^^^^ storage.modifier.haskell + 'deriving +-- ^ keyword.operator.haskell +-- ^^^^^^^^ storage.modifier.haskell + + deriving' +-- ^^^^^^^^^ - keyword + deriving TyCls Const -- ^^^^^^^^^^^^^^ meta.declaration.deriving.haskell -- ^^^^^^ - meta.declaration @@ -550,6 +585,13 @@ -- ^^^^^ meta.declaration.type.haskell -- ^^^^ keyword.declaration.type.haskell + 'type +-- ^ keyword.operator.haskell +-- ^^^^ keyword.declaration.type.haskell + + type' +-- ^^^^^ - keyword + type QTyCls tyVar -- ^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell -- ^^^^ keyword.declaration.type.haskell @@ -602,6 +644,13 @@ -- ^^^^^^^^ meta.declaration.type.haskell -- ^^^^^^^ keyword.declaration.type.haskell + 'newtype +-- ^ keyword.operator.haskell +-- ^^^^^^^ keyword.declaration.type.haskell + + newtype' +-- ^^^^^^^^ - keyword + newtype = -- ^^^^^^^^ meta.declaration.type.haskell -- ^^^^^^^ keyword.declaration.type.haskell @@ -721,14 +770,6 @@ sequenceA = traverse id -- ^ keyword.operator.haskell - - 'class TooMany where --- ^^^^^ keyword.declaration.class.haskell --- ^ keyword.operator.haskell - - class' --- ^^^^^^ - keyword - if' -- ^^^ - keyword From 00e68088d581a3f31298a500b2f4e8455656b0a4 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 25 Dec 2020 22:19:25 +0100 Subject: [PATCH 059/178] [Haskell] Add data declaration statements --- Haskell/Haskell.sublime-syntax | 42 +++++++- Haskell/syntax_test_haskell.hs | 184 +++++++++++++++++++++++---------- 2 files changed, 166 insertions(+), 60 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 24a3240333..6c8b12fa60 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -118,6 +118,7 @@ contexts: - include: functions - include: instances - include: classes + - include: datas - include: defaults - include: deriving - include: types @@ -276,6 +277,26 @@ contexts: pop: 1 - include: type-signature-body +###[ DATA DECLARATIONS ]####################################################### + + datas: + - match: data{{break}} + scope: + meta.declaration.data.haskell + keyword.declaration.data.haskell + push: data-body + + data-body: + - meta_content_scope: meta.declaration.data.haskell + - match: = + scope: keyword.operator.haskell + set: data-constructor + - include: type-signature-body + + data-constructor: + - include: records + - include: else-pop + ###[ DEFAULT DECLARATIONS ]#################################################### defaults: @@ -396,9 +417,7 @@ contexts: type-list-body: - meta_scope: meta.sequence.list.haskell - - match: \] - scope: punctuation.section.sequence.end.haskell - pop: 1 + - include: list-end - include: type-content type-tuples: @@ -413,6 +432,23 @@ contexts: - include: tuple-end - include: type-content +###[ RECORD COSTRUCTORS ]###################################################### + + records: + - match: ({{con_id}})\s*(\{) + captures: + 1: storage.type.haskell + 2: meta.block.haskell punctuation.section.block.begin.haskell + set: record-body + + record-body: + - meta_scope: meta.record.haskell + - meta_content_scope: meta.block.haskell + - match: \} + scope: meta.block.haskell punctuation.section.block.end.haskell + pop: 1 + - include: expressions + ###[ BLOCKS / GROUPS / LISTS / TUPLES ]######################################## blocks: diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 6281626db3..9bdfde3d4e 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -493,6 +493,133 @@ -- ^^^^^^ - keyword +-- [ DATA DECLARATIONS ] ------------------------------------------------------ + + data +-- ^^^^^ meta.declaration.data.haskell +-- ^^^^ keyword.declaration.data.haskell + + data' +-- ^^^^^ meta.name.haskell + + data TyCls +-- ^^^^^^^^^^^ meta.declaration.data.haskell +-- ^^^^ keyword.declaration.data.haskell +-- ^^^^^ storage.type.haskell + + data ModId.QTyCls +-- ^^^^^^^^^^^^^^^^^^ meta.declaration.data.haskell +-- ^^^^ keyword.declaration.data.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell + + data = +-- ^^^^^ meta.declaration.data.haskell +-- ^^^^ keyword.declaration.data.haskell +-- ^ keyword.operator.haskell + + data Record = +-- ^^^^^^^^^^^^ meta.declaration.data.haskell +-- ^^^^ keyword.declaration.data.haskell +-- ^^^^^^ storage.type.haskell +-- ^ keyword.operator.haskell + Record { +-- ^^^^^^^ meta.record.haskell - meta.block +-- ^^ meta.record.haskell meta.block.haskell +-- ^^^^^^ storage.type.haskell +-- ^ punctuation.section.block.begin.haskell + recordInt :: Int +-- ^^^^^^^^^ meta.name.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^^^ storage.type.haskell + , recordString :: String +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^^^^^^ meta.name.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^^^^^^ storage.type.haskell + , recordDouble :: Double +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^^^^^^ meta.name.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^^^^^^ storage.type.haskell + , recordRational :: Rational +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^^^^^^^^ meta.name.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^^^^^^^^ support.class.prelude.haskell + } deriving (Eq, Ord, Generic) +-- ^^ meta.record.haskell meta.block.haskell +-- ^ - meta +-- ^^^^^^^^^ meta.declaration.deriving.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^ meta.declaration.deriving.haskell meta.sequence.tuple.haskell +-- ^ - meta.declaration.deriving - meta.sequence +-- ^^^^^^^^ storage.modifier.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^ support.class.prelude.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^ support.class.prelude.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^ entity.other.inherited-class.haskell +-- ^ punctuation.section.sequence.end.haskell + deriving (Read, Show) via (Quiet Record) +-- ^^^^^^^^^ meta.declaration.deriving.haskell - meta.sequence +-- ^^^^^^^^^^^^ meta.declaration.deriving.haskell meta.sequence.tuple.haskell +-- ^ - meta.declaration.deriving - meta.sequence +-- ^^^^ meta.declaration.deriving.haskell - meta.sequence +-- ^^^^^^^^^^^^^^ meta.declaration.deriving.haskell meta.sequence.tuple.haskell +-- ^ - meta.declaration.deriving - meta.sequence +-- ^^^^^^^^ storage.modifier.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^ support.class.prelude.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^ support.class.prelude.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^^ storage.modifier.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^ entity.other.inherited-class.haskell +-- ^ - entity +-- ^^^^^^ entity.other.inherited-class.haskell +-- ^ punctuation.section.sequence.end.haskell + + data Outrageous = +-- ^^^^^^^^^^^^^^^^ meta.declaration.data.haskell +-- ^^^^ keyword.declaration.data.haskell +-- ^^^^^^^^^^ storage.type.haskell +-- ^ keyword.operator.haskell + Flipper Record + | Int :! Int +-- ^ keyword.operator.haskell +-- ^^ keyword.operator.haskell + | Double :@ Double +-- ^ keyword.operator.haskell +-- ^^ keyword.operator.haskell + | Int `Quux` Double +-- ^ keyword.operator.haskell +-- ^^^^^^ keyword.operator.function.infix.haskell + | String :# Record +-- ^ keyword.operator.haskell +-- ^^ keyword.operator.haskell + | Simple :$ Outrageous +-- ^ keyword.operator.haskell +-- ^^ keyword.operator.haskell + | DontDoThis { outrageousInt :: Int, outrageousString :: String } +-- ^ keyword.operator.haskell +-- ^^^^^^^^^^ constant.other.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.haskell +-- ^ punctuation.section.block.begin.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^^^ storage.type.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^^^^^^ storage.type.haskell +-- ^ punctuation.section.block.end.haskell + deriving (Eq, Ord, Generic) +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.deriving.haskell + deriving (Read, Show) via (Quiet Outrageous) +-- ^^^^^^^^^^^^^^^^^^^^^ meta.declaration.deriving.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.deriving.haskell + -- [ DEFAULT DECLARATIONS ] --------------------------------------------------- default @@ -694,50 +821,6 @@ -- [ DECLARATIONS ] ----------------------------------------------------------- --- | Map each element of a structure to an action, --- evaluate these actions from left to right, and --- collect the results. For a version that ignores --- the results see 'Data.Foldable.traverse_'. --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.double-dash.haskell - - data Record = - Record { - recordInt :: Int - , recordString :: String - , recordDouble :: Double - , recordRational :: Rational - } deriving (Eq, Ord, Generic) --- ^^^^^^^^^ meta.declaration.deriving.haskell - meta.sequence --- ^^^^^^^^^^^^^^^^^^ meta.declaration.deriving.haskell meta.sequence.tuple.haskell --- ^ - meta.declaration.deriving - meta.sequence --- ^^^^^^^^ storage.modifier.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^ support.class.prelude.haskell --- ^ punctuation.separator.sequence.haskell --- ^^^ support.class.prelude.haskell --- ^ punctuation.separator.sequence.haskell --- ^^^^^^^ entity.other.inherited-class.haskell --- ^ punctuation.section.sequence.end.haskell - deriving (Read, Show) via (Quiet Record) --- ^^^^^^^^^ meta.declaration.deriving.haskell - meta.sequence --- ^^^^^^^^^^^^ meta.declaration.deriving.haskell meta.sequence.tuple.haskell --- ^ - meta.declaration.deriving - meta.sequence --- ^^^^ meta.declaration.deriving.haskell - meta.sequence --- ^^^^^^^^^^^^^^ meta.declaration.deriving.haskell meta.sequence.tuple.haskell --- ^ - meta.declaration.deriving - meta.sequence --- ^^^^^^^^ storage.modifier.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^^^ support.class.prelude.haskell --- ^ punctuation.separator.sequence.haskell --- ^^^^ support.class.prelude.haskell --- ^ punctuation.section.sequence.end.haskell --- ^^^ storage.modifier.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^^^^ entity.other.inherited-class.haskell --- ^ - entity --- ^^^^^^ entity.other.inherited-class.haskell --- ^ punctuation.section.sequence.end.haskell - traverse :: Applicative f => -- ^^^^^^^^ entity.name.function.haskell -- ^^ keyword.operator.double-colon.haskell @@ -1570,19 +1653,6 @@ main = do -- [ INFIX OPERATORS IN CONTEXT ]---------------------------------------------- - data Outrageous = - Flipper Record - | Int :! Int - | Double :@ Double --- ^ keyword.operator.haskell - | Int `Quux` Double - | String :# Record --- ^ keyword.operator.haskell - | Simple :$ Outrageous - | DontDoThis { outrageousInt :: Int, outrageousString :: String } - deriving (Eq, Ord, Generic) - deriving (Read, Show) via (Quiet Outrageous) - genOutrageous :: Gen Outrageous genOutrageous = Gen.recursive Gen.choice [ From a6db194948b50c4d73eca898e94fcd8c984ecf26 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 25 Dec 2020 22:22:14 +0100 Subject: [PATCH 060/178] [Haskell] Fix instance keyword scope --- Haskell/Haskell.sublime-syntax | 2 +- Haskell/syntax_test_haskell.hs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 6c8b12fa60..4ef3dabba8 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -344,7 +344,7 @@ contexts: # 4.3.2 Instance Declarations # https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-750004.3 - match: instance{{break}} - scope: keyword.declaration.haskell + scope: keyword.declaration.instance.haskell push: instance-body instance-body: diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 9bdfde3d4e..d69c4cc5d8 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -868,7 +868,7 @@ instance TooMany Int where -- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell --- ^^^^^^^^ keyword.declaration..haskell +-- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^^^ keyword.control.context.haskell tooMany n = n > 42 @@ -948,7 +948,7 @@ deriving instance FromJSON Amount -- ^^^^^^^^ storage.modifier.haskell deriving instance FromJSON Ask --- ^^^^^^^^ meta.declaration.instance.haskell keyword.declaration.haskell +-- ^^^^^^^^ meta.declaration.instance.haskell keyword.declaration.instance.haskell test = -- ^ keyword.operator.haskell From 32c43a0116a73fc59e84be88f01ee66fecd9c515 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 25 Dec 2020 22:25:13 +0100 Subject: [PATCH 061/178] [Haskell] Reorganize identifier section --- Haskell/Haskell.sublime-syntax | 108 ++++++++++++++++----------------- Haskell/syntax_test_haskell.hs | 96 ++++++++++++++--------------- 2 files changed, 102 insertions(+), 102 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 4ef3dabba8..4958a99c34 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -535,6 +535,60 @@ contexts: - include: sequence-separators - include: expressions +###[ IDENTIFIERS ]############################################################# + + ident-builtin-classes: + - match: '{{class_names}}' + scope: support.class.prelude.haskell + + ident-inherited-classes: + - include: ident-builtin-classes + - match: '{{con_id}}' + scope: entity.other.inherited-class.haskell + + ident-inherited-class: + - match: '{{class_names}}' + scope: support.class.prelude.haskell + pop: 1 + - match: '{{con_id}}' + scope: entity.other.inherited-class.haskell + pop: 1 + + ident-generic-types: + - match: '{{var_id}}' + scope: variable.other.generic-type.haskell + + ident-namespaces: + - match: ({{con_id}})(\.) + captures: + 1: variable.namespace.haskell + 2: punctuation.accessor.dot.haskell + + ident-types: + - include: ident-builtin-classes + - match: '{{con_id}}' + scope: storage.type.haskell + + ident-constants: + - match: '{{con_id}}' + scope: constant.other.haskell + + ident-builtin-functions: + - match: '{{function_names}}' + scope: support.function.prelude.haskell + + ident-functions: + - match: '{{var_id}}' + scope: variable.function.haskell + + ident-anonymous: + - match: _{{break}} + scope: variable.language.anonymous.haskell + + ident-variables: + - match: '{{var_id}}' + scope: meta.name.haskell + ###[ LITERALS ]################################################################ literal-numbers: @@ -691,60 +745,6 @@ contexts: - match: .* scope: string.quasiquoted.haskell -###[ IDENTIFIERS ]############################################################# - - ident-builtin-classes: - - match: '{{class_names}}' - scope: support.class.prelude.haskell - - ident-inherited-classes: - - include: ident-builtin-classes - - match: '{{con_id}}' - scope: entity.other.inherited-class.haskell - - ident-inherited-class: - - match: '{{class_names}}' - scope: support.class.prelude.haskell - pop: 1 - - match: '{{con_id}}' - scope: entity.other.inherited-class.haskell - pop: 1 - - ident-generic-types: - - match: '{{var_id}}' - scope: variable.other.generic-type.haskell - - ident-namespaces: - - match: ({{con_id}})(\.) - captures: - 1: variable.namespace.haskell - 2: punctuation.accessor.dot.haskell - - ident-types: - - include: ident-builtin-classes - - match: '{{con_id}}' - scope: storage.type.haskell - - ident-constants: - - match: '{{con_id}}' - scope: constant.other.haskell - - ident-builtin-functions: - - match: '{{function_names}}' - scope: support.function.prelude.haskell - - ident-functions: - - match: '{{var_id}}' - scope: variable.function.haskell - - ident-anonymous: - - match: _{{break}} - scope: variable.language.anonymous.haskell - - ident-variables: - - match: '{{var_id}}' - scope: meta.name.haskell - ###[ PROTOTYPES ]############################################################## else-pop: diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index d69c4cc5d8..27f6870ae5 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -895,54 +895,6 @@ countTheBeforeVowel = undefined --- [ IDENTS ] ----------------------------------------------------------------- - - _ --- ^ variable.language.anonymous.haskell - - a --- ^ meta.name.haskell - - _a --- ^^ meta.name.haskell - - _' --- ^^ meta.name.haskell - - a' --- ^^ meta.name.haskell - - _a'b'c_D'0123456789' --- ^^^^^^^^^^^^^^^^^^^^ meta.name.haskell - - genericIdent --- ^^^^^^^^^^^^ meta.name.haskell - - ý ij ǚ ǣ --- ^ meta.name.haskell --- ^ - meta.name --- ^ meta.name.haskell --- ^ - meta.name --- ^ meta.name.haskell --- ^ - meta.name --- ^ meta.name.haskell --- ^ - meta.name - - T.a --- ^ variable.namespace.haskell --- ^ punctuation.accessor.dot.haskell --- ^ meta.name.haskell - - T . a --- ^ constant.other.haskell --- ^ keyword.operator.haskell --- ^ meta.name.haskell - - map (flip (/)) [1..] --- ^^^ support.function.prelude.haskell --- ^^^^ meta.group.haskell support.function.prelude.haskell - - -- [ KEYWORDS ] --------------------------------------------------------------- deriving instance FromJSON Amount @@ -1159,6 +1111,54 @@ main = do -- ^ punctuation.section.group.end.haskell +-- [ IDENTS ] ----------------------------------------------------------------- + + _ +-- ^ variable.language.anonymous.haskell + + a +-- ^ meta.name.haskell + + _a +-- ^^ meta.name.haskell + + _' +-- ^^ meta.name.haskell + + a' +-- ^^ meta.name.haskell + + _a'b'c_D'0123456789' +-- ^^^^^^^^^^^^^^^^^^^^ meta.name.haskell + + genericIdent +-- ^^^^^^^^^^^^ meta.name.haskell + + ý ij ǚ ǣ +-- ^ meta.name.haskell +-- ^ - meta.name +-- ^ meta.name.haskell +-- ^ - meta.name +-- ^ meta.name.haskell +-- ^ - meta.name +-- ^ meta.name.haskell +-- ^ - meta.name + + T.a +-- ^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^ meta.name.haskell + + T . a +-- ^ constant.other.haskell +-- ^ keyword.operator.haskell +-- ^ meta.name.haskell + + map (flip (/)) [1..] +-- ^^^ support.function.prelude.haskell +-- ^^^^ meta.group.haskell support.function.prelude.haskell + + -- [ LITERAL NUMBERS ] -------------------------------------------------------- 0 From 8cc9cca2c849d115f9af356c71198ae7ed4074ac Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 25 Dec 2020 22:37:45 +0100 Subject: [PATCH 062/178] [Haskell] Fix scope of where keyword The `where` keyword has the same meaning no matter where it is used. --- Haskell/Haskell.sublime-syntax | 4 ++-- Haskell/syntax_test_haskell.hs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 4958a99c34..58d0152fae 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -650,7 +650,7 @@ contexts: ###[ KEYWORDS AND OPERATORS ]################################################## keywords: - - match: (?:do|in){{break}} + - match: (?:do|in|where){{break}} scope: keyword.control.context.haskell - match: (?:newtype|type){{break}} scope: keyword.declaration.type.haskell @@ -660,7 +660,7 @@ contexts: scope: storage.modifier.haskell - match: (?:case|of){{break}} scope: keyword.control.conditional.select.haskell # the construct is commonly called "select" - - match: (?:let|where){{break}} + - match: (?:let){{break}} scope: keyword.declaration.variable.haskell - match: (?:return){{break}} scope: keyword.control.flow.return.haskell diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 27f6870ae5..88ed2ce575 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -908,7 +908,7 @@ test = -- ^^^ keyword.declaration.variable.haskell -- ^^ keyword.control.context.haskell where --- ^^^^^ keyword.declaration.variable.haskell +-- ^^^^^ keyword.control.context.haskell y = 1 -- ^ keyword.operator.haskell From 24c9cdd3fe1c7f5282e5db7e242aa2b68780d9a4 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 25 Dec 2020 22:44:16 +0100 Subject: [PATCH 063/178] [Haskell] Reorganize keywords This commit... 1. removes duplicated keywords which are already matched in `statements` 2. sorts them logically (by scope) --- Haskell/Haskell.sublime-syntax | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 58d0152fae..5ddcda2d8d 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -650,28 +650,22 @@ contexts: ###[ KEYWORDS AND OPERATORS ]################################################## keywords: + - match: let{{break}} + scope: keyword.declaration.variable.haskell - match: (?:do|in|where){{break}} scope: keyword.control.context.haskell - - match: (?:newtype|type){{break}} - scope: keyword.declaration.type.haskell - - match: (?:data){{break}} - scope: keyword.declaration.data.haskell - - match: (?:deriving){{break}} - scope: storage.modifier.haskell - match: (?:case|of){{break}} scope: keyword.control.conditional.select.haskell # the construct is commonly called "select" - - match: (?:let){{break}} - scope: keyword.declaration.variable.haskell - - match: (?:return){{break}} - scope: keyword.control.flow.return.haskell - - match: (?:otherwise){{break}} - scope: keyword.other.haskell - - match: (?:if){{break}} + - match: if{{break}} scope: keyword.control.conditional.if.haskell - - match: (?:then){{break}} + - match: then{{break}} scope: keyword.control.conditional.then.haskell - - match: (?:else){{break}} + - match: else{{break}} scope: keyword.control.conditional.else.haskell + - match: otherwise{{break}} + scope: keyword.control.conditional.otherwise.haskell + - match: return{{break}} + scope: keyword.control.flow.return.haskell operators: - match: (`)[ \w'.]+(`) From 12c9510b166a72a2d728f7de44d9d01062a74f73 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sat, 26 Dec 2020 19:16:05 +0100 Subject: [PATCH 064/178] [Haskell] Fix symbol and operator patterns This commit implements operators by strictly following syntax specification in order to fix various mismatches. The chapters in question are: 2.2 Lexical Program Structure 2.4 Identifiers and Operators https://www.haskell.org/onlinereport/haskell2010/haskellch2.html --- Haskell/Haskell.sublime-syntax | 45 +++++---- Haskell/syntax_test_haskell.hs | 170 +++++++++++++++++++++++++++++++-- 2 files changed, 188 insertions(+), 27 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 5ddcda2d8d..28a6ca58af 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -12,12 +12,19 @@ file_extensions: ############################################################################### variables: + # 2.2 Lexical Program Structure + # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-160002.2 + special: '[(),;\[\]`{}]' + symbol: '[\p{S}\p{P}&&[^_"''{{special}}]]' + ascii_symbol: '[!#$%&⋆+./<=>?@\\\^|\-~:]' + unicode_symbol: '[[:punct:]&&[^:ascii:]]' + # 2.3 Comments # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-170002.3 no_comment_ahead: '(?!{{comment_begin}})' comment_ahead: '(?={{comment_begin}})' comment_begin: '--+(?:{{comment_first_char}}|$)' - comment_first_char: '[ \t\w"''(),;\[\]`{}]' + comment_first_char: '[\s\w"''{{special}}]' # 2.4 Identifiers and Operators # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-180002.4 @@ -31,13 +38,16 @@ variables: ){{break}} break: (?![\w']) - # In case this regex seems overly general, - # note that Haskell permits the definition of new operators - # which can be nearly any string of punctuation characters, - # such as $%^&*. - operator_char: '[*|!%&$@#?~+:\-.=\\''\^]' - operator_infix: '{{operator_char}}+' - operator_parens: (?:{{no_comment_ahead}}{{operator_infix}}) + # In case this regex seems overly general, note that Haskell permits + # the definition of new operators which can be nearly any string + # of punctuation characters, such as $%^&*. + operator_symbol: (?:{{symbol}}+) + operator_parens: (?:{{no_comment_ahead}}{{operator_symbol}}) + + varsym: (?:[{{symbol}}&&[^:]]{{symbol}}*) + consym: (?:(?!{{reserved_op}})[:]{{symbol}}*) + reserved_op: |- + (?x: .. | :: | : | \\ | \| | <- | -> | @ | ~ | => | = )(?!{{symbol}}) # 2.6 Character and String Literals # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-200002.6 @@ -483,7 +493,6 @@ contexts: list-body: - meta_scope: meta.sequence.list.haskell - include: list-end - - include: sequence-separators - include: expressions groups-or-tuples: @@ -514,10 +523,10 @@ contexts: group-body: - meta_scope: meta.group.haskell + - match: ',|:(?!{{symbol}})' + fail: groups-or-tuples - include: group-end - include: expressions - - match: ',' - fail: groups-or-tuples tuple: - match: \( @@ -532,7 +541,6 @@ contexts: tuple-body: - meta_scope: meta.sequence.tuple.haskell - include: tuple-end - - include: sequence-separators - include: expressions ###[ IDENTIFIERS ]############################################################# @@ -668,6 +676,8 @@ contexts: scope: keyword.control.flow.return.haskell operators: + - include: infix-parens-operators + - include: sequence-separators - match: (`)[ \w'.]+(`) # Haskell allows any ordinary function application (elem 4 [1..10]) # to be rewritten as an infix expression (4 `elem` [1..10])." @@ -675,13 +685,14 @@ contexts: captures: 1: punctuation.definition.function.begin.haskell 2: punctuation.definition.function.end.haskell - - match: (`)[^`]*?(?:(`)|{{comment_ahead}}) - scope: invalid.illegal.operator.haskell - match: infix[lr]?{{break}} scope: keyword.operator.haskell - - match: '{{operator_infix}}' + # Match all not otherwise matched single quotes as promoition operator + # Note: Found in real world code but not in specs so far. + - match: \' + scope: keyword.operator.haskell + - match: '{{operator_symbol}}' scope: keyword.operator.haskell - - include: infix-parens-operators arrow-operators: - match: (?:->|→) @@ -692,7 +703,7 @@ contexts: scope: keyword.operator.big-arrow.haskell infix-parens-operators: - - match: \(({{operator_parens}})\) + - match: \(\s*({{operator_parens}})\s*\) scope: variable.function.infix.haskell captures: 1: keyword.operator.haskell diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 88ed2ce575..17b94c8510 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -94,12 +94,8 @@ --+ -- ^^^ - comment --. --- ^^^ - comment - --. -- ^^^ - comment --/ --- ^^^ - comment - --: -- ^^^ - comment --< -- ^^^ - comment @@ -110,8 +106,6 @@ --? -- ^^^ - comment --\ --- ^^^ - comment - --\ -- ^^^ - comment --^ -- ^^^ - comment @@ -119,7 +113,7 @@ -- ^^^ - comment --~ -- ^^^ - comment - --~ + --: -- ^^^ - comment @@ -764,6 +758,43 @@ -- ^^^^^^^ entity.other.inherited-class.haskell -- ^ punctuation.section.sequence.end.haskell + type CmdRoute = +-- ^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^ keyword.declaration.type.haskell +-- ^^^^^^^^ storage.type.haskell +-- ^ keyword.operator.haskell + ( ReqBody '[JSON] CmdDto :> PostCreated '[JSON] NoContent +-- ^^^^^^^^^^^ meta.group.haskell - meta.sequence +-- ^^^^^^ meta.group.haskell meta.sequence.list.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.haskell - meta.sequence +-- ^^^^^^ meta.group.haskell meta.sequence.list.haskell +-- ^^^^^^^^^^^ meta.group.haskell - meta.sequence +-- ^ punctuation.section.group.begin.haskell +-- ^ keyword.operator.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^ keyword.operator.haskell +-- ^ keyword.operator.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell + :<|> Capture "id" Text :> ReqBody '[JSON] CmdDto :> Put '[JSON] NoContent +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.haskell - meta.sequence +-- ^^^^^^ meta.group.haskell meta.sequence.list.haskell +-- ^^^^^^^^^^^^^^^^ meta.group.haskell - meta.sequence +-- ^^^^^^ meta.group.haskell meta.sequence.list.haskell +-- ^^^^^^^^^^^ meta.group.haskell - meta.sequence +-- ^^^^ keyword.operator.haskell +-- ^^ keyword.operator.haskell +-- ^ keyword.operator.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^ keyword.operator.haskell +-- ^ keyword.operator.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell + ) +-- ^ meta.group.haskell punctuation.section.group.end.haskell + -- [ NEWTYPE DECLARATIONS ] --------------------------------------------------- @@ -1105,6 +1136,34 @@ main = do -- ^ keyword.operator.haskell -- ^ punctuation.section.sequence.end.haskell + ('<':'b':'r':_) +-- ^^^^^^^^^^^^^^^ meta.sequence.tuple.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^ string.quoted.single.haskell +-- ^ keyword.operator.haskell +-- ^^^ string.quoted.single.haskell +-- ^ keyword.operator.haskell +-- ^^^ string.quoted.single.haskell +-- ^ keyword.operator.haskell +-- ^ variable.language.anonymous.haskell +-- ^ punctuation.section.sequence.end.haskell + + (():(,):[]:[,]:{}:``) +-- ^^^^^^^^^^^^^^^^^^^^^ meta.sequence.tuple.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^ - keyword +-- ^ keyword.operator.haskell +-- ^^^ - keyword +-- ^ keyword.operator.haskell +-- ^^ - keyword +-- ^ keyword.operator.haskell +-- ^^^ - keyword +-- ^ keyword.operator.haskell +-- ^^ - keyword +-- ^ keyword.operator.haskell +-- ^^ - keyword +-- ^ punctuation.section.sequence.end.haskell + (group) -- ^^^^^^^ meta.group.haskell -- ^ punctuation.section.group.begin.haskell @@ -1579,26 +1638,115 @@ main = do -- [ INFIX OPERATORS ] -------------------------------------------------------- - .. : :: = \ <- | -> @ ~ => + ! # $ % & ⋆ + . / < = > ? @ \ ^ | - ~ : -- ascii symbols +-- ^ - keyword +-- ^ keyword.operator.haskell +-- ^ - keyword +-- ^ keyword.operator.haskell +-- ^ - keyword +-- ^ keyword.operator.haskell +-- ^ - keyword +-- ^ keyword.operator.haskell +-- ^ - keyword +-- ^ keyword.operator.haskell +-- ^ - keyword +-- ^ keyword.operator.haskell +-- ^ - keyword +-- ^ keyword.operator.haskell +-- ^ - keyword +-- ^ keyword.operator.haskell +-- ^ - keyword +-- ^ keyword.operator.haskell +-- ^ - keyword +-- ^ keyword.operator.haskell +-- ^ - keyword +-- ^ keyword.operator.haskell +-- ^ - keyword +-- ^ keyword.operator.haskell +-- ^ - keyword +-- ^ keyword.operator.haskell +-- ^ - keyword +-- ^ keyword.operator.haskell +-- ^ - keyword +-- ^ keyword.operator.haskell +-- ^ - keyword +-- ^ keyword.operator.haskell +-- ^ - keyword +-- ^ keyword.operator.haskell +-- ^ - keyword +-- ^ keyword.operator.haskell +-- ^ - keyword +-- ^ keyword.operator.haskell +-- ^ - keyword +-- ^ keyword.operator.haskell +-- ^ - keyword + + .. : :: = \ <- | -> @ ~ => -- reserved operators +-- ^^ keyword.operator.haskell +-- ^ keyword.operator.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^ keyword.operator.haskell +-- ^ keyword.operator.haskell +-- ^^ keyword.operator.haskell +-- ^ keyword.operator.haskell +-- ^^ keyword.operator.haskell +-- ^ keyword.operator.haskell +-- ^ keyword.operator.haskell +-- ^^ keyword.operator.haskell + + ( ) , ; [ ] ` { } -- special symbols +-- ^^^^^^^^^^^^^^^^^ - keyword +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^ punctuation.terminator.statement.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^ punctuation.section.block.begin.haskell +-- ^ punctuation.section.block.end.haskell a a = (+) a 2 -- ^ keyword.operator.haskell -- ^^^ variable.function.infix.haskell -- ^ keyword.operator.haskell -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell + + a a = ( + ) a 2 +-- ^ keyword.operator.haskell +-- ^^^^^ variable.function.infix.haskell +-- ^ keyword.operator.haskell +-- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell + a a = (-) a 2 -- ^ keyword.operator.haskell -- ^^^ variable.function.infix.haskell -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell + + a a = ( - ) a 2 +-- ^ keyword.operator.haskell +-- ^^^^^ variable.function.infix.haskell +-- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell + a a = (*) a 2 -- ^ keyword.operator.haskell -- ^^^ variable.function.infix.haskell -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell + + a a = ( * ) a 2 +-- ^ keyword.operator.haskell +-- ^^^^^ variable.function.infix.haskell +-- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell + a a = (/) a 2 -- ^ keyword.operator.haskell -- ^^^ variable.function.infix.haskell -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell + a a = ( / ) a 2 +-- ^ keyword.operator.haskell +-- ^^^^^ variable.function.infix.haskell +-- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell + a a = (--) a 2 -- ^ keyword.operator.haskell -- ^^^^ - variable.function.infix @@ -1619,6 +1767,7 @@ main = do -- ^^^^^^^^ keyword.operator.function.infix.haskell -- ^ punctuation.definition.function.begin.haskell -- ^ punctuation.definition.function.end.haskell + a `P.atan2` x -- ^^^^^^^^^ keyword.operator.function.infix.haskell -- ^ punctuation.definition.function.begin.haskell @@ -1644,11 +1793,11 @@ main = do -- ^ punctuation.definition.function.end.haskell a `--` b --- ^ invalid.illegal.operator.haskell +-- ^ - illegal - keyword - operator - punctuation -- ^^^^^^ comment.line.double-dash.haskell a ` --- ^ - keyword - operator - punctuation +-- ^ - illegal - keyword - operator - punctuation -- [ INFIX OPERATORS IN CONTEXT ]---------------------------------------------- @@ -1674,3 +1823,4 @@ myManageHook = composeAll , return True --> doShift "1" -- ^^^ keyword.operator ] + From dde2fc4ef668feeacbe5660832deb06c3e4d8a9e Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sat, 26 Dec 2020 23:48:39 +0100 Subject: [PATCH 065/178] [Haskell] Fix empty and unicode character literals It turned out the old pattern to only support some ascii characters. This commit strictly implements specifications to fix that. --- Haskell/Haskell.sublime-syntax | 2 +- Haskell/syntax_test_haskell.hs | 322 ++++++++++++++++++++++++++++++++- 2 files changed, 322 insertions(+), 2 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 28a6ca58af..c408655508 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -622,7 +622,7 @@ contexts: literal-chars: # 2.6 Character and String Literals # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-200002.6 - - match: (')(?:([\ -\[\]-~])|{{escape_sequence}})(?:(')|{{comment_ahead}}) + - match: (')(?:([ [\S&&[^\\'']]])|{{escape_sequence}})?(?:(')|{{comment_ahead}}) scope: meta.string.haskell string.quoted.single.haskell captures: 1: punctuation.definition.string.begin.haskell diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 17b94c8510..460099eed9 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -1265,6 +1265,16 @@ main = do -- [ LITERAL CHARACTERS ] ----------------------------------------------------- + ''.' ' +-- ^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell + 'a--' -- ^^ meta.string.haskell string.quoted.single.haskell - comment -- ^ punctuation.definition.string.begin.haskell @@ -1284,11 +1294,321 @@ main = do -- ^ constant.character.literal.haskell -- ^ punctuation.definition.string.end.haskell - '?' -- literal symbol character + '!'.'#'.'$'.'%'.'&'.'⋆'.'+'.'.'.'/'.'<' -- ascii symbols +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell + + '='.'>'.'?'.'@'.'^'.'|'.'-'.'~'.':' -- ascii symbols +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell + + '('.')'.','.';'.'['.']'.'`'.'{'.'}' -- special symbols +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell + + '‘'.'’'.'"'.'“'.'”'.'—'.'¯'.'˙'.'´'.'˝' -- ^^^ meta.string.haskell string.quoted.single.haskell -- ^ punctuation.definition.string.begin.haskell -- ^ constant.character.literal.haskell -- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell + + '←'.'→'.'↔'.'↓'.'↑'.'↕'.'⇐'.'⇒'.'⇔'.'⇓'.'⇑'.'⇕' +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell + + 'α'.'β'.'γ'.'δ'.'ε'.'ζ'.'η'.'θ'.'ι'.'κ'.'λ'.'μ' +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell +-- ^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell '\'' . '\"' . '\&' . '\\' -- escape characters -- ^^^^ meta.string.haskell string.quoted.single.haskell From 5b59763ba24366ac09d86a8346caea3e61164bb8 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sun, 27 Dec 2020 09:56:54 +0100 Subject: [PATCH 066/178] [Haskell] Reorganize newtype test cases --- Haskell/syntax_test_haskell.hs | 108 ++++++++++++++++----------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 460099eed9..7bbe42682a 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -700,6 +700,60 @@ -- ^ punctuation.section.sequence.end.haskell +-- [ NEWTYPE DECLARATIONS ] --------------------------------------------------- + + newtype +-- ^^^^^^^^ meta.declaration.type.haskell +-- ^^^^^^^ keyword.declaration.type.haskell + + 'newtype +-- ^ keyword.operator.haskell +-- ^^^^^^^ keyword.declaration.type.haskell + + newtype' +-- ^^^^^^^^ - keyword + + newtype = +-- ^^^^^^^^ meta.declaration.type.haskell +-- ^^^^^^^ keyword.declaration.type.haskell +-- ^ keyword.operator.haskell + + newtype => +-- ^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^^^^ keyword.declaration.type.haskell +-- ^^ keyword.operator.big-arrow.haskell + + newtype TypCls tyVar => +-- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^^^^ keyword.declaration.type.haskell +-- ^^^^^^ storage.type.haskell +-- ^^^^^ variable.other.generic-type.haskell +-- ^^ keyword.operator.big-arrow.haskell + + newtype () => ModId.QTyCls tyVar1, tyVar2 deriving (Class1, QTyCls2) +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^^^^^^ meta.declaration.deriving.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^ meta.declaration.deriving.haskell meta.sequence.tuple.haskell +-- ^ - meta.declaration +-- ^^^^ keyword.declaration.type.haskell +-- ^^ meta.sequence.tuple.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^ keyword.operator.big-arrow.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^^^^^^^^ storage.modifier.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^^ entity.other.inherited-class.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^ entity.other.inherited-class.haskell +-- ^ punctuation.section.sequence.end.haskell + + -- [ TYPE DECLARATIONS ] ------------------------------------------------------ type @@ -796,60 +850,6 @@ -- ^ meta.group.haskell punctuation.section.group.end.haskell --- [ NEWTYPE DECLARATIONS ] --------------------------------------------------- - - newtype --- ^^^^^^^^ meta.declaration.type.haskell --- ^^^^^^^ keyword.declaration.type.haskell - - 'newtype --- ^ keyword.operator.haskell --- ^^^^^^^ keyword.declaration.type.haskell - - newtype' --- ^^^^^^^^ - keyword - - newtype = --- ^^^^^^^^ meta.declaration.type.haskell --- ^^^^^^^ keyword.declaration.type.haskell --- ^ keyword.operator.haskell - - newtype => --- ^^^^^^^^^^^ meta.declaration.type.haskell --- ^^^^^^^ keyword.declaration.type.haskell --- ^^ keyword.operator.big-arrow.haskell - - newtype TypCls tyVar => --- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell --- ^^^^^^^ keyword.declaration.type.haskell --- ^^^^^^ storage.type.haskell --- ^^^^^ variable.other.generic-type.haskell --- ^^ keyword.operator.big-arrow.haskell - - newtype () => ModId.QTyCls tyVar1, tyVar2 deriving (Class1, QTyCls2) --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell --- ^^^^^^^^^ meta.declaration.deriving.haskell - meta.sequence --- ^^^^^^^^^^^^^^^^^ meta.declaration.deriving.haskell meta.sequence.tuple.haskell --- ^ - meta.declaration --- ^^^^ keyword.declaration.type.haskell --- ^^ meta.sequence.tuple.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^ punctuation.section.sequence.end.haskell --- ^^ keyword.operator.big-arrow.haskell --- ^^^^^ variable.namespace.haskell --- ^ punctuation.accessor.dot.haskell --- ^^^^^^ storage.type.haskell --- ^^^^^^ variable.other.generic-type.haskell --- ^ punctuation.separator.sequence.haskell --- ^^^^^^ variable.other.generic-type.haskell --- ^^^^^^^^ storage.modifier.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^^^^^ entity.other.inherited-class.haskell --- ^ punctuation.separator.sequence.haskell --- ^^^^^^^ entity.other.inherited-class.haskell --- ^ punctuation.section.sequence.end.haskell - - -- [ DECLARATIONS ] ----------------------------------------------------------- traverse :: Applicative f => From d0d9e94fe19dd86df54ef2d9511b62614c438304 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sun, 27 Dec 2020 10:45:07 +0100 Subject: [PATCH 067/178] [Haskell] Improve class declaration --- Haskell/Haskell.sublime-syntax | 50 +++++++++-- Haskell/syntax_test_haskell.hs | 148 ++++++++++++++++++++++++++++++--- 2 files changed, 180 insertions(+), 18 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index c408655508..0835b3eea4 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -277,15 +277,55 @@ contexts: # 4.3.1 Class Declarations # https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-750004.3 - match: class{{break}} - scope: keyword.declaration.class.haskell - push: class-body + scope: + meta.declaration.class.haskell + keyword.declaration.class.haskell + branch_point: classes + branch: + - class-context + - class-signature + + class-else-fail: + - match: (?=\S) + fail: classes + + class-context: + # The context specifies the superclasses + - meta_content_scope: meta.declaration.class.context.haskell + - match: => + scope: + meta.declaration.class.haskell + keyword.operator.big-arrow.haskell + set: class-signature + - include: class-context-decls + - include: class-else-fail + + class-context-decls: + - include: class-context-tuples + - include: sequence-separators + - include: ident-anonymous + - include: ident-namespaces + - include: ident-types + - include: ident-generic-types - class-body: - - meta_scope: meta.declaration.class.haskell + class-context-tuples: + - match: \( + scope: punctuation.section.sequence.begin.haskell + push: class-context-tuple-body + + class-context-tuple-body: + - meta_scope: meta.sequence.tuple.haskell + - include: tuple-end + - include: class-context-decls + - include: else-pop + + class-signature: + - meta_content_scope: meta.declaration.class.signature.haskell - match: where{{break}} scope: keyword.control.context.haskell pop: 1 - - include: type-signature-body + - include: type-content + - include: else-pop ###[ DATA DECLARATIONS ]####################################################### diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 7bbe42682a..57cd375393 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -407,23 +407,35 @@ -- [ CLASS DECLARATIONS ] ----------------------------------------------------- + 'class +-- ^ keyword.operator.haskell +-- ^^^^^ keyword.declaration.class.haskell + + class' +-- ^^^^^^ - keyword + class --- ^^^^^^ meta.declaration.class.haskell +-- ^^^^^ meta.declaration.class.haskell +-- ^ meta.declaration.class.signature.haskell -- ^^^^^ keyword.declaration.class.haskell class => --- ^^^^^^^^^ meta.declaration.class.haskell +-- ^^^^^ meta.declaration.class.haskell +-- ^ meta.declaration.class.context.haskell +-- ^^ meta.declaration.class.haskell -- ^^^^^ keyword.declaration.class.haskell -- ^^ keyword.operator.big-arrow.haskell class QTyCls tyVar --- ^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell +-- ^^^^^ meta.declaration.class.haskell +-- ^^^^^^^^^^^^^^ meta.declaration.class.signature.haskell -- ^^^^^ keyword.declaration.class.haskell -- ^^^^^^ storage.type.haskell -- ^^^^^ variable.other.generic-type.haskell class ModId.QTyCls tyVar1, tyVar2 --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell +-- ^^^^^ meta.declaration.class.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.signature.haskell -- ^^^^^ keyword.declaration.class.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell @@ -433,7 +445,10 @@ -- ^^^^^^ variable.other.generic-type.haskell class ModId.QTyCls tyVar1, tyVar2 => --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell +-- ^^^^^ meta.declaration.class.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.context.haskell +-- ^^ meta.declaration.class.haskell +-- ^ meta.declaration.class.signature.haskell -- ^^^^^ keyword.declaration.class.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell @@ -443,8 +458,43 @@ -- ^^^^^^ variable.other.generic-type.haskell -- ^^ keyword.operator.big-arrow.haskell + class ModId.QTyCls (tyVar1 tyVar2) => +-- ^^^^^ meta.declaration.class.haskell +-- ^^^^^^^^^^^^^^ meta.declaration.class.context.haskell +-- ^^^^^^^^^^^^^^^ meta.declaration.class.context.haskell meta.sequence.tuple.haskell +-- ^ meta.declaration.class.context.haskell - meta.sequence +-- ^^ meta.declaration.class.haskell +-- ^ meta.declaration.class.signature.haskell +-- ^^^^^ keyword.declaration.class.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^ keyword.operator.big-arrow.haskell + + class ModId.QTyCls (tyVar1 tyVar2 => +-- ^^^^^ meta.declaration.class.haskell +-- ^^^^^^^^^^^^^^ meta.declaration.class.context.haskell +-- ^^^^^^^^^^^^^^^^ meta.declaration.class.context.haskell meta.sequence.tuple.haskell +-- ^^ meta.declaration.class.haskell +-- ^ meta.declaration.class.signature.haskell +-- ^^^^^ keyword.declaration.class.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^^ keyword.operator.big-arrow.haskell + class ModId.QTyCls tyVar1, tyVar2 => Traversable t --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell +-- ^^^^^ meta.declaration.class.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.context.haskell +-- ^^ meta.declaration.class.haskell +-- ^^^^^^^^^^^^^^^ meta.declaration.class.signature.haskell -- ^^^^^ keyword.declaration.class.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell @@ -457,7 +507,11 @@ -- ^ variable.other.generic-type.haskell class () => --- ^^^^^^^^^^^^ meta.declaration.class.haskell +-- ^^^^^ meta.declaration.class.haskell +-- ^ meta.declaration.class.context.haskell - meta.sequence +-- ^^ meta.declaration.class.context.haskell meta.sequence.tuple.haskell +-- ^ meta.declaration.class.context.haskell - meta.sequence +-- ^^ meta.declaration.class.haskell -- ^^^^^ keyword.declaration.class.haskell -- ^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell @@ -465,7 +519,12 @@ -- ^^ keyword.operator.big-arrow.haskell class (Functor t, Foldable t) => Traversable t where --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell +-- ^^^^^ meta.declaration.class.haskell +-- ^ meta.declaration.class.context.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.context.haskell meta.sequence.tuple.haskell +-- ^ meta.declaration.class.context.haskell - meta.sequence +-- ^^ meta.declaration.class.haskell +-- ^^^^^^^^^^^^^^^ meta.declaration.class.signature.haskell -- ^^^^^ keyword.declaration.class.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^^^^^ support.class.prelude.haskell @@ -479,12 +538,75 @@ -- ^ variable.other.generic-type.haskell -- ^^^^^ keyword.control.context.haskell - 'class --- ^ keyword.operator.haskell --- ^^^^^ keyword.declaration.class.haskell +-- A class declaration with no where part may be useful for combining +-- a collection of classes into a larger one that inherits all of the class +-- methods in the original ones. - class' --- ^^^^^^ - keyword + class Eq a => a -> a +-- ^^^^^ meta.declaration.class.haskell +-- ^^^^^^ meta.declaration.class.context.haskell +-- ^^ meta.declaration.class.haskell +-- ^^^^^^^^ meta.declaration.class.signature.haskell +-- ^^^^^ keyword.declaration.class.haskell +-- ^^ support.class.prelude.haskell +-- ^ variable.other.generic-type.haskell +-- ^^ keyword.operator.big-arrow.haskell +-- ^ variable.other.generic-type.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^ variable.other.generic-type.haskell + + class (Eq a, Show a, Eq b) => [a] -> [b] -> String +-- ^^^^^ meta.declaration.class.haskell +-- ^ meta.declaration.class.context.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.context.haskell meta.sequence.tuple.haskell +-- ^ meta.declaration.class.context.haskell - meta.sequence +-- ^^ meta.declaration.class.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.signature.haskell +-- ^^^^^ keyword.declaration.class.haskell +-- ^^ support.class.prelude.haskell +-- ^ variable.other.generic-type.haskell +-- ^^ keyword.operator.big-arrow.haskell +-- ^ variable.other.generic-type.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^ variable.other.generic-type.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^^^^^^ storage.type.haskell + + class (Eq (f a), Functor f) => (a -> b) -> f a -> f b -> Bool +-- ^^^^^ meta.declaration.class.haskell +-- ^ meta.declaration.class.context.haskell - meta.sequence +-- ^^^^ meta.declaration.class.context.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence +-- ^^^^^ meta.declaration.class.context.haskell meta.sequence.tuple.haskell meta.sequence.tuple.haskell +-- ^^^^^^^^^^^^ meta.declaration.class.context.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence +-- ^ meta.declaration.class.context.haskell - meta.sequence +-- ^^ meta.declaration.class.haskell +-- ^ meta.declaration.class.signature.haskell - meta.group +-- ^^^^^^^^ meta.declaration.class.signature.haskell meta.sequence.tuple.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.signature.haskell - meta.group +-- ^^^^^ keyword.declaration.class.haskell +-- ^^ support.class.prelude.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ variable.other.generic-type.haskell +-- ^ variable.other.generic-type.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^ support.class.prelude.haskell +-- ^ variable.other.generic-type.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^ keyword.operator.big-arrow.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ variable.other.generic-type.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^ variable.other.generic-type.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^ variable.other.generic-type.haskell +-- ^ variable.other.generic-type.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^ variable.other.generic-type.haskell +-- ^ variable.other.generic-type.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^^^^ storage.type.haskell -- [ DATA DECLARATIONS ] ------------------------------------------------------ From da13ed3cbfb338dc5dddf329c2526d1cbfa324df Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sun, 27 Dec 2020 15:31:20 +0100 Subject: [PATCH 068/178] [Haskell] Split import/export symbol lists As `module` and qualified identifiers are not permitted in import lists this commit splits `symbols` context to be able to correctly handle that. --- Haskell/Haskell.sublime-syntax | 91 +++++++++---- Haskell/syntax_test_haskell.hs | 227 ++++++++++++++++++++++++--------- 2 files changed, 233 insertions(+), 85 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 0835b3eea4..1c490625b5 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -211,65 +211,94 @@ contexts: ###[ MODULE DECLARATIONS ]##################################################### modules: + # 5.1 Module Structure + # https://www.haskell.org/onlinereport/haskell2010/haskellch5.html#x11-990005.1 - match: module{{break}} scope: keyword.declaration.namespace.haskell - push: module-body + push: + - module-meta + - module-body - module-body: + module-meta: + - meta_include_prototype: false - meta_scope: meta.declaration.module.haskell - - match: where{{break}} - scope: keyword.control.context.haskell - pop: 1 + - include: immediatelly-pop + + module-body: - match: ({{con_id}})(\.) captures: 1: variable.namespace.haskell 2: punctuation.accessor.dot.haskell - match: '{{con_id}}' scope: entity.name.namespace.haskell - - include: symbols + - match: \( + scope: punctuation.section.sequence.begin.haskell + set: module-tuple-body + - include: else-pop + + module-tuple-body: + - meta_scope: meta.sequence.tuple.haskell + - include: tuple-end + - include: range-tuples + - include: infix-parens-operators + - include: sequence-separators + - match: \( + scope: punctuation.section.sequence.begin.haskell + push: module-tuple-body + - match: module{{break}} + scope: keyword.declaration.namespace.haskell + - include: ident-builtin-functions + - include: ident-functions + - include: ident-namespaces + - include: ident-types - include: else-pop ###[ IMPORT DECLARATIONS ]##################################################### imports: + # 5.3 Import Declarations + # https://www.haskell.org/onlinereport/haskell2010/haskellch5.html#x11-1010005.3 - match: import{{break}} scope: keyword.declaration.import.haskell - push: import-body + push: + - import-meta + - import-body - import-body: + import-meta: + - meta_include_prototype: false - meta_scope: meta.import.haskell + - include: immediatelly-pop + + import-body: - match: (?:qualified|as|hiding){{break}} - scope: keyword.declaration.import.haskell + scope: storage.modifier.import.haskell - match: ({{con_id}})\s*(?:(\.)|(?=\(|as{{break}})) captures: 1: variable.namespace.haskell 2: punctuation.accessor.dot.haskell - match: '{{con_id}}' scope: entity.name.namespace.haskell - - include: symbols - - include: else-pop - -###[ SYMBOL DECLARATIONS ]##################################################### - - symbols: - match: \( scope: punctuation.section.sequence.begin.haskell - push: symbol-body + set: import-tuple-body + - include: else-pop - symbol-body: + import-tuple-body: - meta_scope: meta.sequence.tuple.haskell - include: tuple-end + - include: range-tuples + - include: infix-parens-operators + - include: sequence-separators + - match: \( + scope: punctuation.section.sequence.begin.haskell + push: import-tuple-body + - match: \. + scope: invalid.illegal.accessor.haskell - match: module{{break}} - scope: keyword.declaration.namespace.haskell - - include: ident-builtin-functions + scope: invalid.illegal.unexpected-keyword.haskell - include: ident-functions - - include: ident-namespaces - include: ident-types - - include: sequence-separators - - include: infix-parens-operators - - match: \({{no_comment_ahead}}.*?\) - comment: So named because I don't know what to call this. - scope: meta.other.unknown.haskell + - include: else-pop ###[ CLASS DECLARATIONS ]###################################################### @@ -583,6 +612,14 @@ contexts: - include: tuple-end - include: expressions + range-tuples: + - match: (\()(\.\.)(\)) + scope: meta.sequence.tuple.haskell + captures: + 1: punctuation.section.sequence.begin.haskell + 2: keyword.operator.range.haskell + 3: punctuation.section.sequence.end.haskell + ###[ IDENTIFIERS ]############################################################# ident-builtin-classes: @@ -795,3 +832,7 @@ contexts: else-pop: - match: (?=\S) pop: 1 + + immediatelly-pop: + - match: '' + pop: 1 diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 57cd375393..47a86c47b5 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -164,7 +164,8 @@ -- ^^^^ entity.name.namespace.haskell module Name where --- ^^^^^^^^^^^^^^^^^ meta.declaration.module.haskell +-- ^^^^^^^^^^^^ meta.declaration.module.haskell +-- ^^^^^ - meta.declaration.module -- ^^^^^^ keyword.declaration.namespace.haskell -- ^^^^ entity.name.namespace.haskell -- ^^^^^ keyword.control.context.haskell @@ -187,7 +188,7 @@ module Name () where -- ^^^^^^^^^^^^ meta.declaration.module.haskell - meta.sequence -- ^^ meta.declaration.module.haskell meta.sequence.tuple.haskell --- ^^^^^ meta.declaration.module.haskell - meta.sequence +-- ^^^^^^^ - meta.declaration.module -- ^^^^^^ keyword.declaration.namespace.haskell -- ^^^^ entity.name.namespace.haskell -- ^ punctuation.section.sequence.begin.haskell @@ -197,8 +198,7 @@ module Ns.Name (sym1, sym2) where { import Ns.Other; import Ns.Other2 } -- ^^^^^^^^^^^^^^^ meta.declaration.module.haskell - meta.sequence -- ^^^^^^^^^^^^ meta.declaration.module.haskell meta.sequence.tuple.haskell --- ^^^^^^ meta.declaration.module.haskell - meta.sequence --- ^ - meta.declaration.module - meta.block +-- ^^^^^^ - meta.declaration.module - meta.block - meta.sequence -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.haskell - meta.declaration.module -- ^ - meta.block -- ^^^^^^ keyword.declaration.namespace.haskell @@ -226,8 +226,7 @@ module Name (module Other.Module) where { import Other.Module } -- ^^^^^^^^^^^^ meta.declaration.module.haskell - meta.sequence -- ^^^^^^^^^^^^^^^^^^^^^ meta.declaration.module.haskell meta.sequence.tuple.haskell --- ^^^^^^ meta.declaration.module.haskell - meta.sequence --- ^ - meta.declaration - meta.block +-- ^^^^^^^ - meta.declaration - meta.block - meta.sequence -- ^^ meta.block.haskell - meta.import -- ^^^^^^^^^^^^^^^^^^^^ meta.block.haskell meta.import.haskell -- ^ meta.block.haskell - meta.import @@ -274,13 +273,13 @@ import qualified Data.Vector.Mutable as MutableVector -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^^^^ keyword.declaration.import.haskell --- ^^^^^^^^^ keyword.declaration.import.haskell +-- ^^^^^^^^^ storage.modifier.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^^^^ variable.namespace.haskell - punctuation --- ^^ keyword.declaration.import.haskell +-- ^^ storage.modifier.import.haskell -- ^^^^^^^^^^^^^ entity.name.namespace.haskell import @@ -288,7 +287,7 @@ -- ^^^^^^ keyword.declaration.import.haskell qualified -- ^^^^^^^^^^ meta.import.haskell --- ^^^^^^^^^ keyword.declaration.import.haskell +-- ^^^^^^^^^ storage.modifier.import.haskell Data.Vector.Mutable -- ^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^^ variable.namespace.haskell - punctuation @@ -298,109 +297,217 @@ -- ^^^^^^^ entity.name.namespace.haskell - punctuation as -- ^^^ meta.import.haskell --- ^^ keyword.declaration.import.haskell +-- ^^ storage.modifier.import.haskell MutableVector -- ^^^^^^^^^^^^^^ meta.import.haskell -- ^^^^^^^^^^^^^ entity.name.namespace.haskell - import Data.List.Split (splitOn) --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell + import Mod1.Mod2.Module (funcName) +-- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell - meta.sequence +-- ^^^^^^^^^^ meta.import.haskell meta.sequence.tuple.haskell +-- ^ - meta.import -- ^^^^^^ keyword.declaration.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^^^^^ meta.sequence.tuple.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^^^^^^ variable.function.haskell --- ^ punctuation.section.sequence.end.haskell - - import Data.List.Split (()) --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^^^^^^ meta.sequence.tuple.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^^^^ variable.function.haskell +-- ^ punctuation.section.sequence.end.haskell + + import Mod1.Mod2.Module (ClassName(..)) +-- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell - meta.sequence +-- ^^^^^^^^^^ meta.import.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence +-- ^^^^ meta.import.haskell meta.sequence.tuple.haskell meta.sequence.tuple.haskell +-- ^ meta.import.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence +-- ^ - meta.import -- ^^^^^^ keyword.declaration.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^ meta.sequence.tuple.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^ meta.other.unknown.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^^^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^^^^^ storage.type.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^ keyword.operator.range.haskell +-- ^^ punctuation.section.sequence.end.haskell + + import Mod1.Mod2.Module (ClassName (SubClass), funcName) +-- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell - meta.sequence +-- ^^^^^^^^^^^ meta.import.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence +-- ^^^^^^^^^^ meta.import.haskell meta.sequence.tuple.haskell meta.sequence.tuple.haskell +-- ^^^^^^^^^^^ meta.import.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence +-- ^ - meta.import +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^^^^^ storage.type.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^^^^ storage.type.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^^ variable.function.haskell +-- ^ punctuation.section.sequence.end.haskell + + import Mod1.Mod2.Module (ClassName (memberName), funcName) +-- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell - meta.sequence +-- ^^^^^^^^^^^ meta.import.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence +-- ^^^^^^^^^^^^ meta.import.haskell meta.sequence.tuple.haskell meta.sequence.tuple.haskell +-- ^^^^^^^^^^^ meta.import.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence +-- ^ - meta.import +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^^^^^ storage.type.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^^^^^^ variable.function.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^^ variable.function.haskell +-- ^ punctuation.section.sequence.end.haskell + + import Mod1.Mod2.Module (ClassName (SubClass, memberName), funcName) +-- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell - meta.sequence +-- ^^^^^^^^^^^ meta.import.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell meta.sequence.tuple.haskell meta.sequence.tuple.haskell +-- ^^^^^^^^^^^ meta.import.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence +-- ^ - meta.import +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^^^^^ storage.type.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^^^^ storage.type.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^^^^ variable.function.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^^ variable.function.haskell +-- ^ punctuation.section.sequence.end.haskell - import Data.List.Split (-- --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell + import Mod1.Mod2.Module ((), (<.>), fun1, fun2, +-- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^ variable.function.infix.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^ variable.function.infix.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^ variable.function.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^ variable.function.haskell +-- ^ punctuation.separator.sequence.haskell + fun3, fun4) +-- ^^^^^^^^^^^ meta.import.haskell meta.sequence.tuple.haskell +-- ^ - meta.import +-- ^^^^ variable.function.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^ variable.function.haskell +-- ^ punctuation.section.sequence.end.haskell + + import Mod1.Mod2.Module (()) +-- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell - meta.sequence +-- ^ meta.import.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence +-- ^^ meta.import.haskell meta.sequence.tuple.haskell meta.sequence.tuple.haskell +-- ^ meta.import.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence +-- ^ - meta.import -- ^^^^^^ keyword.declaration.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^ meta.sequence.tuple.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^^ comment.line.double-dash.haskell --- ^^ punctuation.definition.comment.haskell - ) --- ^ punctuation.section.sequence.end.haskell +-- ^^^^^^ variable.namespace.haskell - punctuation +-- ^^^^ meta.sequence.tuple.haskell +-- ^^ punctuation.section.sequence.begin.haskell +-- ^^ punctuation.section.sequence.end.haskell - import Data.List.Split (--) --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell + import Mod1.Mod2.Module (-- +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^^^^ keyword.declaration.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^ meta.sequence.tuple.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^^^ comment.line.double-dash.haskell --- ^^ punctuation.definition.comment.haskell +-- ^^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^ meta.sequence.tuple.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^ comment.line.double-dash.haskell +-- ^^ punctuation.definition.comment.haskell ) -- ^ punctuation.section.sequence.end.haskell - import Data.List.Split ((--)) + import Mod1.Mod2.Module (--) -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^^^^ keyword.declaration.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^^^ meta.sequence.tuple.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^^^^ comment.line.double-dash.haskell +-- ^^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^ meta.sequence.tuple.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^ comment.line.double-dash.haskell -- ^^ punctuation.definition.comment.haskell ) -- ^ punctuation.section.sequence.end.haskell - import Data.List.Split ((--]) --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell + import Mod1.Mod2.Module ((--)) +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^^^^ keyword.declaration.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^^^ meta.sequence.tuple.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^^^^ comment.line.double-dash.haskell --- ^^ punctuation.definition.comment.haskell +-- ^^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^^^ meta.sequence.tuple.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^ comment.line.double-dash.haskell +-- ^^ punctuation.definition.comment.haskell ) -- ^ punctuation.section.sequence.end.haskell - import Data.List.Split ((--") --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell + import Mod1.Mod2.Module ((--]) +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell -- ^^^^^^ keyword.declaration.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^ variable.namespace.haskell - punctuation --- ^^^^^^^ meta.sequence.tuple.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^^^^ comment.line.double-dash.haskell --- ^^ punctuation.definition.comment.haskell +-- ^^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^^^ meta.sequence.tuple.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^ comment.line.double-dash.haskell +-- ^^ punctuation.definition.comment.haskell + ) +-- ^ punctuation.section.sequence.end.haskell + + import Mod1.Mod2.Module ((--") +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^^^ meta.sequence.tuple.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^ comment.line.double-dash.haskell +-- ^^ punctuation.definition.comment.haskell ) -- ^ punctuation.section.sequence.end.haskell From 0923357bffa2bba313ab55f1ca971926932bd45b Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sun, 27 Dec 2020 15:59:19 +0100 Subject: [PATCH 069/178] [Haskell] Remove where keyword from declaration scope --- Haskell/Haskell.sublime-syntax | 6 ------ Haskell/syntax_test_haskell.hs | 3 ++- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 1c490625b5..56eb3960cc 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -350,9 +350,6 @@ contexts: class-signature: - meta_content_scope: meta.declaration.class.signature.haskell - - match: where{{break}} - scope: keyword.control.context.haskell - pop: 1 - include: type-content - include: else-pop @@ -428,9 +425,6 @@ contexts: instance-body: - meta_scope: meta.declaration.instance.haskell - - match: where{{break}} - scope: keyword.control.context.haskell - pop: 1 - include: type-signature-body ###[ FUNCTION DECLARATIONS ]################################################### diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 47a86c47b5..dfdb7a7e54 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -1127,7 +1127,8 @@ -- ^^^^^^^^^^^^^ meta.function.type-declaration.haskell instance TooMany Int where --- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell +-- ^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell +-- ^^^^^ - meta.declaration.instance -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^^^ keyword.control.context.haskell tooMany n = n > 42 From 81744945a56f34fbd73b2fe2381561ccdc7fe045 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sun, 27 Dec 2020 16:13:29 +0100 Subject: [PATCH 070/178] [Haskell] Tweak deriving contexts --- Haskell/Haskell.sublime-syntax | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 56eb3960cc..923d34b17e 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -394,25 +394,30 @@ contexts: # https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-750004.3 - match: (?:deriving|via){{break}} scope: storage.modifier.haskell - push: deriving-body + push: + - deriving-meta + - deriving-body - deriving-body: + deriving-meta: + - meta_include_prototype: false - meta_scope: meta.declaration.deriving.haskell + - include: immediatelly-pop + + deriving-body: - match: \( scope: punctuation.section.sequence.begin.haskell - push: deriving-tuple-body + set: deriving-tuple-body - include: ident-namespaces - include: ident-inherited-class - include: else-pop deriving-tuple-body: - meta_scope: meta.sequence.tuple.haskell - - match: \) - scope: punctuation.section.sequence.end.haskell - pop: 2 + - include: tuple-end - include: sequence-separators - include: ident-namespaces - include: ident-inherited-classes + - include: else-pop ###[ INSTANCE DECLARATIONS ]################################################### From d59b3c31e6ed8b50808b008031724a45e9f97e23 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sun, 27 Dec 2020 16:14:25 +0100 Subject: [PATCH 071/178] [Haskell] Tweak block comment contexts --- Haskell/Haskell.sublime-syntax | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 923d34b17e..18472ce36a 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -155,6 +155,7 @@ contexts: ###[ COMMENTS ]################################################################ comments: + # 2.3 Comments # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-170002.3 - include: line-comments - include: block-comments @@ -165,6 +166,7 @@ contexts: push: block-comment-body block-comment-body: + - meta_include_prototype: false - meta_scope: comment.block.haskell - match: -\} scope: punctuation.definition.comment.end.haskell @@ -174,6 +176,7 @@ contexts: - include: block-comments block-comment-nested-body: + - meta_include_prototype: false - match: -\} pop: 1 - include: block-comments From 961e380c8ae008b464d3b5bdb9cd4ed01732148f Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sun, 27 Dec 2020 16:49:27 +0100 Subject: [PATCH 072/178] [Haskell] Scope builtin constants --- Haskell/Haskell.sublime-syntax | 11 ++++++++++- Haskell/syntax_test_haskell.hs | 12 ++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 18472ce36a..160e145671 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -74,6 +74,9 @@ variables: | RealFrac | RealFloat | Integral | Floating ){{break}} + constant_names: |- + (?x: Just | Nothing | Left | Right | True | False | LT | EQ | GT ){{break}} + function_names: |- (?x: abs | acos | acosh | all | and | any | appendFile | asTypeOf | asin @@ -146,9 +149,11 @@ contexts: - include: groups-or-tuples - include: lists - include: keywords - - include: ident-builtin-functions - include: ident-anonymous - include: ident-namespaces + - include: ident-builtin-classes + - include: ident-builtin-constants + - include: ident-builtin-functions - include: ident-constants - include: ident-variables @@ -656,6 +661,10 @@ contexts: - match: '{{con_id}}' scope: storage.type.haskell + ident-builtin-constants: + - match: '{{constant_names}}' + scope: constant.language.haskell + ident-constants: - match: '{{con_id}}' scope: constant.other.haskell diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index dfdb7a7e54..7254c7ad49 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -1443,6 +1443,18 @@ main = do -- ^ keyword.operator.haskell -- ^ meta.name.haskell + Just +-- ^^^^ constant.language.haskell + + Nothing +-- ^^^^^^^ constant.language.haskell + + False +-- ^^^^^ constant.language.haskell + + True +-- ^^^^ constant.language.haskell + map (flip (/)) [1..] -- ^^^ support.function.prelude.haskell -- ^^^^ meta.group.haskell support.function.prelude.haskell From 98ef8e981713d9582a2f025a01cf37cad49dd50c Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sun, 27 Dec 2020 18:07:02 +0100 Subject: [PATCH 073/178] [Haskell] Improve preprocessor statements --- Haskell/Default.sublime-keymap | 88 +++++++++++++++++++++++++++++++ Haskell/Haskell.sublime-syntax | 94 ++++++++++++++++++++++++++++++++-- Haskell/syntax_test_haskell.hs | 74 ++++++++++++++++++++++++-- 3 files changed, 247 insertions(+), 9 deletions(-) create mode 100644 Haskell/Default.sublime-keymap diff --git a/Haskell/Default.sublime-keymap b/Haskell/Default.sublime-keymap new file mode 100644 index 0000000000..809a7894a3 --- /dev/null +++ b/Haskell/Default.sublime-keymap @@ -0,0 +1,88 @@ +[ + // + // BLOCK COMMENTS + // + + // Expand {-|-} to {- | -} when space is pressed + { "keys": [" "], "command": "insert_snippet", "args": {"contents": " $0 "}, "context": + [ + { "key": "setting.auto_match_enabled", "operand": true }, + { "key": "selector", "operand": "source.haskell" }, + { "key": "selection_empty", "operand": true, "match_all": true }, + { "key": "preceding_text", "operator": "regex_contains", "operand": "{-$", "match_all": true }, + { "key": "following_text", "operator": "regex_contains", "operand": "^-}", "match_all": true } + ] + }, + // Collapse {- | -} to {-|-} when backspace is pressed + { "keys": ["backspace"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Left Right.sublime-macro"}, "context": + [ + { "key": "setting.auto_match_enabled", "operand": true }, + { "key": "selector", "operand": "source.haskell" }, + { "key": "selection_empty", "operand": true, "match_all": true }, + { "key": "preceding_text", "operator": "regex_contains", "operand": "{-\\s$", "match_all": true }, + { "key": "following_text", "operator": "regex_contains", "operand": "^\\s-}", "match_all": true } + ] + }, + // Collapse {-|-} to {|} when backspace is pressed + { "keys": ["backspace"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Left Right.sublime-macro"}, "context": + [ + { "key": "setting.auto_match_enabled", "operand": true }, + { "key": "selector", "operand": "source.haskell" }, + { "key": "selection_empty", "operand": true, "match_all": true }, + { "key": "preceding_text", "operator": "regex_contains", "operand": "{-$", "match_all": true }, + { "key": "following_text", "operator": "regex_contains", "operand": "^-}", "match_all": true } + ] + }, + + // + // PREPROCESSOR PRAGMA + // + + // Auto-pair hash tags: {-# | #-} + { "keys": ["#"], "command": "insert_snippet", "args": {"contents": "# $0 #"}, "context": + [ + { "key": "setting.auto_match_enabled", "operand": true }, + { "key": "selector", "operand": "source.haskell" }, + { "key": "selection_empty", "operand": true, "match_all": true }, + { "key": "preceding_text", "operator": "regex_contains", "operand": "{-$", "match_all": true }, + { "key": "following_text", "operator": "regex_contains", "operand": "^-}", "match_all": true } + ] + }, + { "keys": ["#"], "command": "insert_snippet", "args": {"contents": "# ${0:$SELECTION} #"}, "context": + [ + { "key": "setting.auto_match_enabled", "operand": true }, + { "key": "selector", "operand": "source.haskell comment.block" }, + { "key": "selection_empty", "operand": false, "match_all": true } + ] + }, + // Expand {-#|#-} to {-# | #-} when space is pressed + { "keys": [" "], "command": "insert_snippet", "args": {"contents": " $0 "}, "context": + [ + { "key": "setting.auto_match_enabled", "operand": true }, + { "key": "selector", "operand": "source.haskell" }, + { "key": "selection_empty", "operand": true, "match_all": true }, + { "key": "preceding_text", "operator": "regex_contains", "operand": "{-#$", "match_all": true }, + { "key": "following_text", "operator": "regex_contains", "operand": "^#-}", "match_all": true } + ] + }, + // Collapse {-# | #-} to {-#|#-} when backspace is pressed + { "keys": ["backspace"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Left Right.sublime-macro"}, "context": + [ + { "key": "setting.auto_match_enabled", "operand": true }, + { "key": "selector", "operand": "source.haskell" }, + { "key": "selection_empty", "operand": true, "match_all": true }, + { "key": "preceding_text", "operator": "regex_contains", "operand": "{-#\\s$", "match_all": true }, + { "key": "following_text", "operator": "regex_contains", "operand": "^\\s#-}", "match_all": true } + ] + }, + // Collapse {-#|#-} to {-|-} when backspace is pressed + { "keys": ["backspace"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Left Right.sublime-macro"}, "context": + [ + { "key": "setting.auto_match_enabled", "operand": true }, + { "key": "selector", "operand": "source.haskell" }, + { "key": "selection_empty", "operand": true, "match_all": true }, + { "key": "preceding_text", "operator": "regex_contains", "operand": "{-#$", "match_all": true }, + { "key": "following_text", "operator": "regex_contains", "operand": "^#-}", "match_all": true } + ] + } +] \ No newline at end of file diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 160e145671..97003c4b3c 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -114,6 +114,52 @@ variables: | RULES | SPECIALIZE | SPECIALISE ){{break}} + # https://wiki.haskell.org/Language_extensions + # https://github.com/JustusAdam/language-haskell + pragma_deprecated_constants: |- + (?:No)?(?x: + AutoDeriveTypeable | DatatypeContexts | DoRec | IncoherentInstances + | MonadFailDesugaring | MonoPatBinds | NullaryTypeClasses + | OverlappingInstances | PatternSignatures | RecordPuns | RelaxedPolyRec + ){{break}} + + # https://wiki.haskell.org/Language_extensions + # https://github.com/JustusAdam/language-haskell + pragma_extension_constants: |- + (?:No)?(?x: + AllowAmbiguousTypes | AlternativeLayoutRule + | AlternativeLayoutRuleTransitional | Arrows | BangPatterns | BinaryLiterals + | CApiFFI | CPP | CUSKs | ConstrainedClassMethods | ConstraintKinds + | DataKinds | DefaultSignatures | DeriveAnyClass | DeriveDataTypeable + | DeriveFoldable | DeriveFunctor | DeriveGeneric | DeriveLift + | DeriveTraversable | DerivingStrategies | DerivingVia + | DisambiguateRecordFields | DoAndIfThenElse | BlockArguments + | DuplicateRecordFields | EmptyCase | EmptyDataDecls | EmptyDataDeriving + | ExistentialQuantification | ExplicitForAll | ExplicitNamespaces + | ExtendedDefaultRules | FlexibleContexts | FlexibleInstances + | ForeignFunctionInterface | FunctionalDependencies | GADTSyntax | GADTs + | GHCForeignImportPrim | Generali(?:s | z)edNewtypeDeriving | ImplicitParams + | ImplicitPrelude | ImportQualifiedPost | ImpredicativeTypes + | TypeFamilyDependencies | InstanceSigs | ApplicativeDo | InterruptibleFFI + | JavaScriptFFI | KindSignatures | LambdaCase | LiberalTypeSynonyms | MagicHash + | MonadComprehensions | MonoLocalBinds | MonomorphismRestriction + | MultiParamTypeClasses | MultiWayIf | NumericUnderscores | NPlusKPatterns + | NamedFieldPuns | NamedWildCards | NegativeLiterals | HexFloatLiterals + | NondecreasingIndentation | NumDecimals | OverloadedLabels | OverloadedLists + | OverloadedStrings | PackageImports | ParallelArrays | ParallelListComp + | PartialTypeSignatures | PatternGuards | PatternSynonyms | PolyKinds + | PolymorphicComponents | QuantifiedConstraints | PostfixOperators + | QuasiQuotes | Rank2Types | RankNTypes | RebindableSyntax | RecordWildCards + | RecursiveDo | RelaxedLayout | RoleAnnotations | ScopedTypeVariables + | StandaloneDeriving | StarIsType | StaticPointers | Strict | StrictData + | TemplateHaskell | TemplateHaskellQuotes | StandaloneKindSignatures + | TraditionalRecordSyntax | TransformListComp | TupleSections + | TypeApplications | TypeInType | TypeFamilies | TypeOperators + | TypeSynonymInstances | UnboxedTuples | UnboxedSums + | UndecidableInstances | UndecidableSuperClasses | UnicodeSyntax + | UnliftedFFITypes | UnliftedNewtypes | ViewPatterns + ){{break}} + ############################################################################### contexts: @@ -204,17 +250,57 @@ contexts: 2: punctuation.definition.preprocessor.c preprocessor-pragmas: + # 12 Compiler Pragmas + # https://www.haskell.org/onlinereport/haskell2010/haskellch12.html#x19-18800012 - match: \{-# scope: punctuation.section.preprocessor.begin.haskell push: preprocessor-pragma-body preprocessor-pragma-body: - - meta_scope: meta.preprocessor.haskell + - meta_include_prototype: false + - meta_scope: meta.preprocessor.pragma.directive.haskell + - include: comments + # known directives + - match: LANGUAGE{{break}} + scope: keyword.directive.language.haskell + set: preprocessor-pragma-language-value + - match: '{{pragma_keys}}' + scope: keyword.directive.builtin.haskell + set: preprocessor-pragma-other-value + # maybe incomplete directive + # maintain meta scope to support completions + - match: \p{Lu}+|(?=\S) + set: preprocessor-pragma-other-value + + preprocessor-pragma-language-value: + - meta_include_prototype: false + - meta_content_scope: meta.preprocessor.pragma.value.language.haskell + - include: preprocessor-pragma-common + - match: '{{pragma_extension_constants}}' + scope: constant.language.extension.haskell + - match: '{{pragma_deprecated_constants}}' + scope: constant.language.extension.haskell invalid.deprecated.haskell + + preprocessor-pragma-other-value: + - meta_include_prototype: false + - meta_content_scope: meta.preprocessor.pragma.value.other.haskell + - include: preprocessor-pragma-common + - include: constructor-separators + - include: literal-numbers + - include: literal-strings + - match: (-*)[-\w]+ + scope: constant.other.pragma.haskell + captures: + 1: punctuation.definition.constant.haskell + + preprocessor-pragma-common: - match: '#-\}' - scope: punctuation.section.preprocessor.end.haskell + scope: + meta.preprocessor.pragma.value.haskell + punctuation.section.preprocessor.end.haskell pop: 1 - - match: '{{pragma_keys}}' - scope: keyword.directive.other.haskell + - include: comments + - include: sequence-separators ###[ MODULE DECLARATIONS ]##################################################### diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 7254c7ad49..a092d45cc9 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -17,6 +17,7 @@ {- {-# #-} -} 23*36 -- ^^ punctuation.definition.comment.begin.haskell -- ^^^^^^^^^^^^^ comment.block.haskell - meta.preprocessor.haskell +-- ^^^^^^^ - meta.preprocessor -- ^^ punctuation.definition.comment.end.haskell -- ^ - comment.block.haskell @@ -120,20 +121,83 @@ -- [ PREPROCESSOR ] ----------------------------------------------------------- {-# MINIMAL traverse | sequenceA LANGUAGE #-} --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.haskell +-- ^^^^^^^^^^^ meta.preprocessor.pragma.directive.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.pragma.value.other.haskell +-- ^^^ meta.preprocessor.pragma.value.haskell -- ^ - meta.preprocessor.haskell -- ^^^ punctuation.section.preprocessor.begin.haskell --- ^^^^^^^ keyword.directive.other.haskell --- ^^^^^^^ keyword.directive.other.haskell +-- ^^^^^^^ keyword.directive.builtin.haskell +-- ^^^^^^^^ constant.other.pragma.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^^^ constant.other.pragma.haskell +-- ^^^^^^^^ constant.other.pragma.haskell +-- ^^^^^^^^ - keyword.directive -- ^^^ punctuation.section.preprocessor.end.haskell + {-# OPTIONS_GHC -Drelease #-} +-- ^^^^^^^^^^^^^^^ meta.preprocessor.pragma.directive.haskell +-- ^^^^^^^^^^^ meta.preprocessor.pragma.value.other.haskell +-- ^^^ meta.preprocessor.pragma.value.haskell +-- ^ - meta.preprocessor.haskell +-- ^^^ punctuation.section.preprocessor.begin.haskell +-- ^^^^^^^^^^^ keyword.directive.builtin.haskell +-- ^^^^^^^^^ constant.other.pragma.haskell +-- ^ punctuation.definition.constant.haskell +-- ^^^ punctuation.section.preprocessor.end.haskell + {-# OPTIONS_HADDOCK not-home #-} --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.haskell +-- ^^^^^^^^^^^^^^^^^^^ meta.preprocessor.pragma.directive.haskell +-- ^^^^^^^^^^ meta.preprocessor.pragma.value.other.haskell +-- ^^^ meta.preprocessor.pragma.value.haskell -- ^ - meta.preprocessor.haskell -- ^^^ punctuation.section.preprocessor.begin.haskell --- ^^^^^^^^^^^^^^^ keyword.directive.other.haskell +-- ^^^^^^^^^^^^^^^ keyword.directive.builtin.haskell +-- ^^^^^^^^ constant.other.pragma.haskell -- ^^^ punctuation.section.preprocessor.end.haskell + {-# LANGUAGE +-- ^^^^^^^^^^^^ meta.preprocessor.pragma.directive.haskell +-- ^ meta.preprocessor.pragma.value.language.haskell +-- ^^^ punctuation.section.preprocessor.begin.haskell +-- ^^^^^^^^ keyword.directive.language.haskell + -- Type level programming +-- ^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.double-dash.haskell + DataKinds, PolyKinds, +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.pragma.value.language.haskell +-- ^^^^^^^^^ constant.language.extension.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^^^ constant.language.extension.haskell +-- ^ punctuation.separator.sequence.haskell + -- Generics +-- ^^^^^^^^^^^ comment.line.double-dash.haskell + DeriveGeneric, DeriveAnyClass, DerivingVia +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.pragma.value.language.haskell +-- ^^^^^^^^^^^^^ constant.language.extension.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^^^^^^^^ constant.language.extension.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^^^^^ constant.language.extension.haskell + {- Type applications -} +-- ^^^^^^^^^^^^^^^^^^^^^^^ comment.block.haskell + , TypeApplications, AllowAmbiguousTypes +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.pragma.value.language.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^^^^^^^^^^ constant.language.extension.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^^^^^^^^^^^^^ constant.language.extension.haskell + #-} +-- ^^^ meta.preprocessor.pragma.value.haskell punctuation.section.preprocessor.end.haskell + + {-# WARNING "Not supported" #-} +-- ^^^^^^^^^^^ meta.preprocessor.pragma.directive.haskell +-- ^^^^^^^^^^^^^^^^^ meta.preprocessor.pragma.value.other.haskell +-- ^^^ meta.preprocessor.pragma.value.haskell +-- ^ - meta.preprocessor.haskell +-- ^^^ punctuation.section.preprocessor.begin.haskell +-- ^^^^^^^ keyword.directive.builtin.haskell +-- ^^^^^^^^^^^^^^^ meta.string.haskell string.quoted.double.haskell +-- ^^^ punctuation.section.preprocessor.end.haskell + #if 0 -- ^^^ meta.preprocessor.c -- ^ punctuation.definition.preprocessor.c From 0ea89c9d617d7a34d4f60669e2a8e3b28b810c43 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sun, 27 Dec 2020 18:23:26 +0100 Subject: [PATCH 074/178] [Haskell] Add file extensions --- Haskell/Haskell.sublime-syntax | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 97003c4b3c..5098f47362 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -8,6 +8,8 @@ version: 2 file_extensions: - hs + - hs-boot + - hsig ############################################################################### From 58f51d60bab9cd9b5b631e789538671d61058296 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sun, 27 Dec 2020 19:25:11 +0100 Subject: [PATCH 075/178] [Haskell] Tweak function declaration Bailout from type signature as soon as the function name is found on the next line. --- Haskell/Haskell.sublime-syntax | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 5098f47362..b3a18c7eda 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -531,7 +531,7 @@ contexts: ###[ FUNCTION DECLARATIONS ]################################################### functions: - - match: '^(\s*)({{var_id}}|\(({{operator_parens}})\))\s*(::|∷)' + - match: ^(\s*)({{var_id}}|\(({{operator_parens}})\))\s*(::|∷) captures: 2: entity.name.function.haskell 3: keyword.operator.infix.haskell @@ -540,7 +540,7 @@ contexts: function-body: - meta_scope: meta.function.type-declaration.haskell - - match: ^(?!\s*(?:--|{-|$)|\1\s) + - match: ^(?:(?!\s*(?:--|{-|$)|\1\s)|(?=\s*\2)) pop: 1 - include: big-arrow-operators - include: type-content From f3e5aa992a09133b00f5cce10f303582f0adbd11 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sun, 27 Dec 2020 21:56:47 +0100 Subject: [PATCH 076/178] [Haskell] Add instance declaration tests --- Haskell/syntax_test_haskell.hs | 225 ++++++++++++++++++++++++++++++++- 1 file changed, 220 insertions(+), 5 deletions(-) diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index a092d45cc9..4aac00e14c 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -993,6 +993,226 @@ -- ^ punctuation.section.sequence.end.haskell +-- [ INSTANCE DECLARATIONS ] -------------------------------------------------- + + instance +-- ^^^^^^^^^ meta.declaration.instance.haskell +-- ^^^^^^^^ keyword.declaration.instance.haskell + + instance ModId.QTyCls +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence +-- ^^^^^^^^ keyword.declaration.instance.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell + + instance ModId.QTyCls [] +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence +-- ^^ meta.declaration.instance.haskell meta.sequence.list.haskell +-- ^ meta.declaration.instance.haskell - meta.sequence +-- ^^^^^^^^ keyword.declaration.instance.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell + + instance ModId.QTyCls () +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence +-- ^^ meta.declaration.instance.haskell meta.sequence.tuple.haskell +-- ^ meta.declaration.instance.haskell - meta.sequence +-- ^^^^^^^^ keyword.declaration.instance.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell + + instance ModId.QTyCls (,) +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence +-- ^^^ meta.declaration.instance.haskell meta.sequence.tuple.haskell +-- ^ meta.declaration.instance.haskell - meta.sequence +-- ^^^^^^^^ keyword.declaration.instance.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^ punctuation.section.sequence.end.haskell + + instance ModId.QTyCls (->) +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence +-- ^^^^ meta.declaration.instance.haskell meta.sequence.tuple.haskell +-- ^ meta.declaration.instance.haskell - meta.sequence +-- ^^^^^^^^ keyword.declaration.instance.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^ punctuation.section.sequence.end.haskell + + instance ModId.QTyCls a +-- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell +-- ^^^^^^^^ keyword.declaration.instance.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^ variable.other.generic-type.haskell + + instance ModId.QTyCls [a] +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence +-- ^^^ meta.declaration.instance.haskell meta.sequence.list.haskell +-- ^ meta.declaration.instance.haskell - meta.sequence +-- ^^^^^^^^ keyword.declaration.instance.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ variable.other.generic-type.haskell +-- ^ punctuation.section.sequence.end.haskell + + instance ModId.QTyCls (a, b) +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence +-- ^^^^^^ meta.declaration.instance.haskell meta.sequence.tuple.haskell +-- ^ meta.declaration.instance.haskell - meta.sequence +-- ^^^^^^^^ keyword.declaration.instance.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ variable.other.generic-type.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^ variable.other.generic-type.haskell +-- ^ punctuation.section.sequence.end.haskell + + instance ModId.QTyCls (a -> b) +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence +-- ^^^^^^^^ meta.declaration.instance.haskell meta.sequence.tuple.haskell +-- ^ meta.declaration.instance.haskell - meta.sequence +-- ^^^^^^^^ keyword.declaration.instance.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ variable.other.generic-type.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^ variable.other.generic-type.haskell +-- ^ punctuation.section.sequence.end.haskell + + instance ModId.QTyCls ([] a b) +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence +-- ^ meta.declaration.instance.haskell meta.sequence.tuple.haskell +-- ^^ meta.declaration.instance.haskell meta.sequence.tuple.haskell meta.sequence.list.haskell +-- ^^^^^ meta.declaration.instance.haskell meta.sequence.tuple.haskell +-- ^ meta.declaration.instance.haskell - meta.sequence +-- ^^^^^^^^ keyword.declaration.instance.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^ variable.other.generic-type.haskell +-- ^ variable.other.generic-type.haskell +-- ^ punctuation.section.sequence.end.haskell + + instance ModId.QTyCls (() a b) +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence +-- ^ meta.declaration.instance.haskell meta.sequence.tuple.haskell +-- ^^ meta.declaration.instance.haskell meta.sequence.tuple.haskell meta.sequence.tuple.haskell +-- ^^^^^ meta.declaration.instance.haskell meta.sequence.tuple.haskell +-- ^ meta.declaration.instance.haskell - meta.sequence +-- ^^^^^^^^ keyword.declaration.instance.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^ variable.other.generic-type.haskell +-- ^ variable.other.generic-type.haskell +-- ^ punctuation.section.sequence.end.haskell + + instance ModId.QTyCls ((,) a b) +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence +-- ^ meta.declaration.instance.haskell meta.sequence.tuple.haskell +-- ^^^ meta.declaration.instance.haskell meta.sequence.tuple.haskell meta.sequence.tuple.haskell +-- ^^^^^ meta.declaration.instance.haskell meta.sequence.tuple.haskell +-- ^ meta.declaration.instance.haskell - meta.sequence +-- ^^^^^^^^ keyword.declaration.instance.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^ variable.other.generic-type.haskell +-- ^ variable.other.generic-type.haskell +-- ^ punctuation.section.sequence.end.haskell + + instance ModId.QTyCls ((->) a b) +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence +-- ^ meta.declaration.instance.haskell meta.sequence.tuple.haskell +-- ^^^^ meta.declaration.instance.haskell meta.sequence.tuple.haskell meta.sequence.tuple.haskell +-- ^^^^^ meta.declaration.instance.haskell meta.sequence.tuple.haskell +-- ^ meta.declaration.instance.haskell - meta.sequence +-- ^^^^^^^^ keyword.declaration.instance.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^^ punctuation.section.sequence.begin.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^ variable.other.generic-type.haskell +-- ^ variable.other.generic-type.haskell +-- ^ punctuation.section.sequence.end.haskell + + instance Num a => Bar [a] where ... +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence +-- ^^^ meta.declaration.instance.haskell meta.sequence.list.haskell +-- ^ meta.declaration.instance.haskell - meta.sequence +-- ^^^^^^^^ keyword.declaration.instance.haskell +-- ^^^ support.class.prelude.haskell +-- ^ variable.other.generic-type.haskell +-- ^^ keyword.operator.big-arrow.haskell +-- ^^^ storage.type.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ variable.other.generic-type.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^^^^ keyword.control.context.haskell + + instance (Eq a, Show a) => Foo [a] where ... +-- ^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence +-- ^^^^^^^^^^^^^^ meta.declaration.instance.haskell meta.sequence.tuple.haskell +-- ^^^^^^^^ meta.declaration.instance.haskell - meta.sequence +-- ^^^ meta.declaration.instance.haskell meta.sequence.list.haskell +-- ^ meta.declaration.instance.haskell - meta.sequence +-- ^^^^^^^^ keyword.declaration.instance.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^ support.class.prelude.haskell +-- ^ variable.other.generic-type.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^ support.class.prelude.haskell +-- ^ variable.other.generic-type.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^ keyword.operator.big-arrow.haskell +-- ^^^ storage.type.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ variable.other.generic-type.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^^^^ keyword.control.context.haskell + + {- illegal instance declarations -} + + instance C (a,a) where ... -- a, a is not distict +--- ^ invalid.illegal + + instance C (Int,a) where ... -- no type allowed +--- ^^^ invalid.illegal + + instance C [[a]] where ... -- no nested lists allowed +--- ^^^ invalid.illegal + + -- [ NEWTYPE DECLARATIONS ] --------------------------------------------------- newtype @@ -1222,11 +1442,6 @@ -- [ KEYWORDS ] --------------------------------------------------------------- - deriving instance FromJSON Amount --- ^^^^^^^^ storage.modifier.haskell - deriving instance FromJSON Ask --- ^^^^^^^^ meta.declaration.instance.haskell keyword.declaration.instance.haskell - test = -- ^ keyword.operator.haskell let x = 2 in x * y From 16fabde7c867829a23545d1d682d153f7d73a106 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sun, 27 Dec 2020 22:29:56 +0100 Subject: [PATCH 077/178] [Haskell] Fix type signatures Sequence separators are supported in type tuples/lists only, but not in top-level type signature content. --- Haskell/Haskell.sublime-syntax | 9 ++- Haskell/syntax_test_haskell.hs | 107 ++++++++++++++++----------------- 2 files changed, 59 insertions(+), 57 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index b3a18c7eda..496d8fb5ff 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -427,7 +427,6 @@ contexts: class-context-decls: - include: class-context-tuples - - include: sequence-separators - include: ident-anonymous - include: ident-namespaces - include: ident-types @@ -441,6 +440,7 @@ contexts: class-context-tuple-body: - meta_scope: meta.sequence.tuple.haskell - include: tuple-end + - include: sequence-separators - include: class-context-decls - include: else-pop @@ -578,10 +578,9 @@ contexts: - include: type-lists - include: type-tuples - include: arrow-operators - - include: sequence-separators + - include: ident-anonymous - include: ident-namespaces - include: ident-types - - include: ident-anonymous - include: ident-generic-types type-lists: @@ -592,7 +591,9 @@ contexts: type-list-body: - meta_scope: meta.sequence.list.haskell - include: list-end + - include: sequence-separators - include: type-content + - include: else-pop type-tuples: # 4.1.3 Syntax of Class Assertions and Contexts @@ -604,7 +605,9 @@ contexts: type-tuple-body: - meta_scope: meta.sequence.tuple.haskell - include: tuple-end + - include: sequence-separators - include: type-content + - include: else-pop ###[ RECORD COSTRUCTORS ]###################################################### diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 4aac00e14c..a03664045c 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -604,30 +604,31 @@ -- ^^^^^^ storage.type.haskell -- ^^^^^ variable.other.generic-type.haskell - class ModId.QTyCls tyVar1, tyVar2 + class ModId.QTyCls tyVar1 tyVar2, ident -- ^^^^^ meta.declaration.class.haskell --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.signature.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.signature.haskell +-- ^^^^^^^ - meta.declaration -- ^^^^^ keyword.declaration.class.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell -- ^^^^^^ variable.other.generic-type.haskell --- ^ punctuation.separator.sequence.haskell --- ^^^^^^ variable.other.generic-type.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^ meta.name.haskell - class ModId.QTyCls tyVar1, tyVar2 => + class ModId.QTyCls tyVar1 tyVar2 => -- ^^^^^ meta.declaration.class.haskell --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.context.haskell --- ^^ meta.declaration.class.haskell --- ^ meta.declaration.class.signature.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.context.haskell +-- ^^ meta.declaration.class.haskell +-- ^ meta.declaration.class.signature.haskell -- ^^^^^ keyword.declaration.class.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell -- ^^^^^^ variable.other.generic-type.haskell --- ^ punctuation.separator.sequence.haskell --- ^^^^^^ variable.other.generic-type.haskell --- ^^ keyword.operator.big-arrow.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^^ keyword.operator.big-arrow.haskell class ModId.QTyCls (tyVar1 tyVar2) => -- ^^^^^ meta.declaration.class.haskell @@ -661,21 +662,20 @@ -- ^^^^^^ variable.other.generic-type.haskell -- ^^ keyword.operator.big-arrow.haskell - class ModId.QTyCls tyVar1, tyVar2 => Traversable t + class ModId.QTyCls tyVar1 tyVar2 => Traversable t -- ^^^^^ meta.declaration.class.haskell --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.context.haskell --- ^^ meta.declaration.class.haskell --- ^^^^^^^^^^^^^^^ meta.declaration.class.signature.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.context.haskell +-- ^^ meta.declaration.class.haskell +-- ^^^^^^^^^^^^^^^ meta.declaration.class.signature.haskell -- ^^^^^ keyword.declaration.class.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell -- ^^^^^^ variable.other.generic-type.haskell --- ^ punctuation.separator.sequence.haskell --- ^^^^^^ variable.other.generic-type.haskell --- ^^ keyword.operator.big-arrow.haskell --- ^^^^^^^^^^^ support.class.prelude.haskell --- ^ variable.other.generic-type.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^^ keyword.operator.big-arrow.haskell +-- ^^^^^^^^^^^ support.class.prelude.haskell +-- ^ variable.other.generic-type.haskell class () => -- ^^^^^ meta.declaration.class.haskell @@ -895,9 +895,11 @@ -- ^^^^^^^^^^ constant.other.haskell -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.haskell -- ^ punctuation.section.block.begin.haskell +-- ^^^^^^^^^^^^^ meta.block.haskell meta.name.haskell -- ^^ keyword.operator.double-colon.haskell -- ^^^ storage.type.haskell -- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^^^^^^^^^^ meta.block.haskell meta.name.haskell -- ^^ keyword.operator.double-colon.haskell -- ^^^^^^ storage.type.haskell -- ^ punctuation.section.block.end.haskell @@ -1243,11 +1245,11 @@ -- ^^^^^ variable.other.generic-type.haskell -- ^^ keyword.operator.big-arrow.haskell - newtype () => ModId.QTyCls tyVar1, tyVar2 deriving (Class1, QTyCls2) --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell --- ^^^^^^^^^ meta.declaration.deriving.haskell - meta.sequence --- ^^^^^^^^^^^^^^^^^ meta.declaration.deriving.haskell meta.sequence.tuple.haskell --- ^ - meta.declaration + newtype () => ModId.QTyCls tyVar1 tyVar2 deriving (Class1, QTyCls2) +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^^^^^^ meta.declaration.deriving.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^ meta.declaration.deriving.haskell meta.sequence.tuple.haskell +-- ^ - meta.declaration -- ^^^^ keyword.declaration.type.haskell -- ^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell @@ -1257,14 +1259,13 @@ -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell -- ^^^^^^ variable.other.generic-type.haskell --- ^ punctuation.separator.sequence.haskell --- ^^^^^^ variable.other.generic-type.haskell --- ^^^^^^^^ storage.modifier.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^^^^^ entity.other.inherited-class.haskell --- ^ punctuation.separator.sequence.haskell --- ^^^^^^^ entity.other.inherited-class.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^^^^^^^^ storage.modifier.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^^ entity.other.inherited-class.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^ entity.other.inherited-class.haskell +-- ^ punctuation.section.sequence.end.haskell -- [ TYPE DECLARATIONS ] ------------------------------------------------------ @@ -1286,44 +1287,42 @@ -- ^^^^^^ storage.type.haskell -- ^^^^^ variable.other.generic-type.haskell - type ModId.QTyCls tyVar1, tyVar2 --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell + type ModId.QTyCls tyVar1 tyVar2 +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell -- ^^^^ keyword.declaration.type.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell -- ^^^^^^ variable.other.generic-type.haskell --- ^ punctuation.separator.sequence.haskell --- ^^^^^^ variable.other.generic-type.haskell +-- ^^^^^^ variable.other.generic-type.haskell - type ModId.QTyCls tyVar1, tyVar2 = --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell + type ModId.QTyCls tyVar1 tyVar2 = +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^ - meta.declaration -- ^^^^ keyword.declaration.type.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell -- ^^^^^^ variable.other.generic-type.haskell --- ^ punctuation.separator.sequence.haskell --- ^^^^^^ variable.other.generic-type.haskell +-- ^^^^^^ variable.other.generic-type.haskell - type ModId.QTyCls tyVar1, tyVar2 deriving (Class1, QTyCls2) --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell --- ^^^^^^^^^ meta.declaration.deriving.haskell - meta.sequence --- ^^^^^^^^^^^^^^^^^ meta.declaration.deriving.haskell meta.sequence.tuple.haskell --- ^ - meta.declaration + type ModId.QTyCls tyVar1 tyVar2 deriving (Class1, QTyCls2) +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^^^^^^ meta.declaration.deriving.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^ meta.declaration.deriving.haskell meta.sequence.tuple.haskell +-- ^ - meta.declaration -- ^^^^ keyword.declaration.type.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell -- ^^^^^^ variable.other.generic-type.haskell --- ^ punctuation.separator.sequence.haskell --- ^^^^^^ variable.other.generic-type.haskell --- ^^^^^^^^ storage.modifier.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^^^^^ entity.other.inherited-class.haskell --- ^ punctuation.separator.sequence.haskell --- ^^^^^^^ entity.other.inherited-class.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^^^^^^ variable.other.generic-type.haskell +-- ^^^^^^^^ storage.modifier.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^^ entity.other.inherited-class.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^ entity.other.inherited-class.haskell +-- ^ punctuation.section.sequence.end.haskell type CmdRoute = -- ^^^^^^^^^^^^^^ meta.declaration.type.haskell From 9cde06c8158c095ed8dd828f24affacd9b55780f Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sun, 27 Dec 2020 23:33:53 +0100 Subject: [PATCH 078/178] [Haskell] Improve default statement Ensures to pop right after the tuple. --- Haskell/Haskell.sublime-syntax | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 496d8fb5ff..aaee7b3415 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -476,11 +476,19 @@ contexts: # https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-750004.3 - match: default{{break}} scope: storage.modifier.haskell - push: default-body + push: + - default-meta + - default-body - default-body: + default-meta: + - meta_include_prototype: false - meta_scope: meta.declaration.default.haskell - - include: type-tuples + - include: immediatelly-pop + + default-body: + - match: \( + scope: punctuation.section.sequence.begin.haskell + set: type-tuple-body - include: else-pop ###[ DERIVING DECLARATIONS ]################################################### From f528ad56e28cdeafdf31c997eec613d65900fd70 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Mon, 28 Dec 2020 00:22:35 +0100 Subject: [PATCH 079/178] [Haskell] Add forall keyword highlighting --- Haskell/Haskell.sublime-syntax | 19 +++++++++++++++++ Haskell/syntax_test_haskell.hs | 38 ++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index aaee7b3415..2af861f880 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -191,6 +191,7 @@ contexts: - include: literal-chars - include: literal-strings - include: literal-numbers + - include: type-forall - include: type-signatures - include: operators - include: splice @@ -583,6 +584,7 @@ contexts: - include: else-pop type-content: + - include: type-forall - include: type-lists - include: type-tuples - include: arrow-operators @@ -591,6 +593,22 @@ contexts: - include: ident-types - include: ident-generic-types + type-forall: + - match: ∀(?!{{symbol}}) + scope: keyword.operator.forall.haskell + push: type-forall-body + - match: forall{{break}} + scope: keyword.control.forall.haskell + push: type-forall-body + + type-forall-body: + - match: \. + scope: keyword.operator.haskell + pop: 1 + - include: ident-anonymous + - include: ident-generic-types + - include: else-pop + type-lists: - match: \[ scope: punctuation.section.sequence.begin.haskell @@ -617,6 +635,7 @@ contexts: - include: type-content - include: else-pop + ###[ RECORD COSTRUCTORS ]###################################################### records: diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index a03664045c..5ec9d80556 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -909,6 +909,44 @@ -- ^^^^^^^^^^^^^^^^^^^^^ meta.declaration.deriving.haskell -- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.deriving.haskell + data BuilderType = Builder + { (>>=) :: forall m a b. Unrestricted.Monad m => m a -> (a -> m b) -> m b +-- ^^^^^ variable.function.infix.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^^^^^^ keyword.control.forall.haskell +-- ^ keyword.operator.haskell +-- ^^^^^^^^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^ support.class.prelude.haskell + , (>>) :: forall m b . Unrestricted.Monad m => m() -> m b -> m b +-- ^ punctuation.separator.sequence.haskell +-- ^^^^ variable.function.infix.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^^^^^^ keyword.control.forall.haskell +-- ^ keyword.operator.haskell +-- ^^^^^^^^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^ support.class.prelude.haskell + , fail :: ∀ m a . Unrestricted.MonadFail m => String -> m a +-- ^ punctuation.separator.sequence.haskell +-- ^^^^ support.function.prelude.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^ keyword.operator.forall.haskell +-- ^ keyword.operator.haskell +-- ^^^^^^^^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^^^^ storage.type.haskell + , return :: forall m a . Unrestricted.Monad m => a -> m a +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^ keyword.control.flow.return.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^^^^^^ keyword.control.forall.haskell +-- ^ keyword.operator.haskell +-- ^^^^^^^^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^ support.class.prelude.haskell + } + -- [ DEFAULT DECLARATIONS ] --------------------------------------------------- default From 3324690204336b17896c0e1fb5e101315be7cc91 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Mon, 28 Dec 2020 14:12:27 +0100 Subject: [PATCH 080/178] [Haskell] Rework Haskell Literate This commit ... 1. Derives Haskell Literate.sublime-syntax from LaTeX.sublime-syntax -> Embedded Haskell code blocks are now supported everywhere. 2. Embeds Haskell.sublime-syntax rather than importing it to let ST re-use existing definitions and support lazy loading. 3. Adjusts scope names to align with LaTeX.sublime-syntax 4. Add a test file. --- Haskell/Literate Haskell.sublime-syntax | 55 +++++++++---------------- Haskell/syntax_test_literate.lhs | 28 +++++++++++++ 2 files changed, 47 insertions(+), 36 deletions(-) create mode 100644 Haskell/syntax_test_literate.lhs diff --git a/Haskell/Literate Haskell.sublime-syntax b/Haskell/Literate Haskell.sublime-syntax index 482ba775a2..1c993ebdc8 100644 --- a/Haskell/Literate Haskell.sublime-syntax +++ b/Haskell/Literate Haskell.sublime-syntax @@ -1,50 +1,33 @@ %YAML 1.2 --- -# http://www.sublimetext.com/docs/3/syntax.html +# https://www.sublimetext.com/docs/syntax.html name: Literate Haskell +scope: text.tex.latex.haskell + +extends: Packages/LaTeX/LaTeX.sublime-syntax + file_extensions: - lhs -scope: text.tex.latex.haskell -contexts: - prototype: - - include: scope:text.tex.latex#comments - main: - - include: scope:text.tex.latex#unique-latex - - include: scope:text.tex.latex#packages +contexts: + plain-tex: + - meta_prepend: true - include: haskell-code - - include: scope:text.tex.latex#plain-tex - - include: scope:text.tex.latex#begin-end-commands - - include: scope:text.tex.latex#general-commands - - include: global-braces - - global-braces: - - match: '\{' - scope: punctuation.definition.group.brace.begin.latex - push: - - meta_scope: meta.group.brace.latex - - match: '\}' - scope: punctuation.definition.group.brace.end.latex - pop: true - - include: main haskell-code: - - match: '(?:\s*)((\\)begin)(\{)(code)(\})' + - match: ((\\)begin)(\{)(code)(\}) captures: - 1: support.function.be.latex + 1: support.function.begin.latex keyword.control.block.begin.latex + 2: punctuation.definition.backslash.latex + 3: punctuation.definition.group.brace.begin.latex + 4: variable.parameter.function.latex + 5: punctuation.definition.group.brace.end.latex + embed: scope:source.haskell + embed_scope: source.haskell.embedded.latex + escape: ((\\)end)(\{)(code)(\}) + escape_captures: + 1: support.function.end.latex keyword.control.block.end.latex 2: punctuation.definition.backslash.latex 3: punctuation.definition.group.brace.begin.latex 4: variable.parameter.function.latex 5: punctuation.definition.group.brace.end.latex - push: - - meta_scope: meta.function.embedded.haskell.latex - - meta_content_scope: source.haskell.embedded.latex - - match: '((\\)end)(\{)(code)(\})' - captures: - 1: support.function.be.latex - 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex - 4: variable.parameter.function.latex - 5: punctuation.definition.group.brace.end.latex - pop: true - - include: scope:source.haskell diff --git a/Haskell/syntax_test_literate.lhs b/Haskell/syntax_test_literate.lhs new file mode 100644 index 0000000000..84580da048 --- /dev/null +++ b/Haskell/syntax_test_literate.lhs @@ -0,0 +1,28 @@ +% SYNTAX TEST "Packages/Haskell/Literate Haskell.sublime-syntax" + + \begin{code} +% ^^^^^^^^^^^^^ - source.haskell +% ^ source.haskell.embedded.latex +% ^ punctuation.definition.backslash.latex +% ^^^^^^ support.function.begin.latex keyword.control.block.begin.latex +% ^ punctuation.definition.group.brace.begin.latex +% ^^^^ variable.parameter.function.latex +% ^ punctuation.definition.group.brace.end.latex + + {- comment -} +% ^^^^^^^^^^^^^ source.haskell.embedded.latex comment.block.haskell + + {-# LANGUAGE EmptyCase #-} +% ^^^^^^^^^^^^^^^^^^^^^^^^^^ source.haskell.embedded.latex +% ^^^^^^^^^^^^ meta.preprocessor.pragma.directive.haskell +% ^^^^^^^^^^^ meta.preprocessor.pragma.value.language.haskell +% ^^^ meta.preprocessor.pragma.value.haskell + + \end{code} +% ^ source.haskell.embedded.latex +% ^^^^^^^^^^^ - source.haskell +% ^ punctuation.definition.backslash.latex +% ^^^^ support.function.end.latex keyword.control.block.end.latex +% ^ punctuation.definition.group.brace.begin.latex +% ^^^^ variable.parameter.function.latex +% ^ punctuation.definition.group.brace.end.latex From 3316d08bb3103b0c90f4899605b6a066fd582820 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Mon, 28 Dec 2020 15:40:04 +0100 Subject: [PATCH 081/178] [Haskell] Improve type/newtype declarations The right hand side after `=` is a type signature. Split type and newtype declarations as they contain slightly different syntax. --- Haskell/Haskell.sublime-syntax | 31 +++++++++++-- Haskell/syntax_test_haskell.hs | 84 ++++++++++++++++++++++++++++------ 2 files changed, 98 insertions(+), 17 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 2af861f880..c86a9db8de 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -182,6 +182,7 @@ contexts: - include: datas - include: defaults - include: deriving + - include: newtypes - include: types - include: imports - include: modules @@ -191,7 +192,6 @@ contexts: - include: literal-chars - include: literal-strings - include: literal-numbers - - include: type-forall - include: type-signatures - include: operators - include: splice @@ -554,16 +554,39 @@ contexts: - include: big-arrow-operators - include: type-content +###[ NEWTYPE DECLARATIONS ]#################################################### + + newtypes: + - match: newtype{{break}} + scope: keyword.declaration.newtype.haskell + push: newtype-body + + newtype-body: + - meta_scope: meta.declaration.newtype.haskell + - match: ^(?!\s*(?:--|{-|$)) + pop: 1 + - match: =(?!>) + scope: keyword.operator.haskell + - include: big-arrow-operators + - include: type-content + - include: else-pop + ###[ TYPE DECLARATIONS ]####################################################### types: - - match: (?:newtype|type){{break}} + - match: type{{break}} scope: keyword.declaration.type.haskell push: type-body - + type-body: - meta_scope: meta.declaration.type.haskell - - include: type-signature-body + - match: ^(?!\s*(?:--|{-|$)) + pop: 1 + - match: =(?!>) + scope: keyword.operator.haskell + - include: big-arrow-operators + - include: type-content + - include: else-pop ###[ TYPE SIGNATURES ]######################################################### diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 5ec9d80556..ebd81d23ac 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -1256,39 +1256,39 @@ -- [ NEWTYPE DECLARATIONS ] --------------------------------------------------- newtype --- ^^^^^^^^ meta.declaration.type.haskell --- ^^^^^^^ keyword.declaration.type.haskell +-- ^^^^^^^^ meta.declaration.newtype.haskell +-- ^^^^^^^ keyword.declaration.newtype.haskell 'newtype -- ^ keyword.operator.haskell --- ^^^^^^^ keyword.declaration.type.haskell +-- ^^^^^^^ keyword.declaration.newtype.haskell newtype' -- ^^^^^^^^ - keyword newtype = --- ^^^^^^^^ meta.declaration.type.haskell --- ^^^^^^^ keyword.declaration.type.haskell +-- ^^^^^^^^ meta.declaration.newtype.haskell +-- ^^^^^^^ keyword.declaration.newtype.haskell -- ^ keyword.operator.haskell newtype => --- ^^^^^^^^^^^ meta.declaration.type.haskell --- ^^^^^^^ keyword.declaration.type.haskell +-- ^^^^^^^^^^^ meta.declaration.newtype.haskell +-- ^^^^^^^ keyword.declaration.newtype.haskell -- ^^ keyword.operator.big-arrow.haskell newtype TypCls tyVar => --- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell --- ^^^^^^^ keyword.declaration.type.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.newtype.haskell +-- ^^^^^^^ keyword.declaration.newtype.haskell -- ^^^^^^ storage.type.haskell -- ^^^^^ variable.other.generic-type.haskell -- ^^ keyword.operator.big-arrow.haskell newtype () => ModId.QTyCls tyVar1 tyVar2 deriving (Class1, QTyCls2) --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.newtype.haskell -- ^^^^^^^^^ meta.declaration.deriving.haskell - meta.sequence -- ^^^^^^^^^^^^^^^^^ meta.declaration.deriving.haskell meta.sequence.tuple.haskell -- ^ - meta.declaration --- ^^^^ keyword.declaration.type.haskell +-- ^^^^ keyword.declaration.newtype.haskell -- ^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^ punctuation.section.sequence.end.haskell @@ -1335,8 +1335,7 @@ -- ^^^^^^ variable.other.generic-type.haskell type ModId.QTyCls tyVar1 tyVar2 = --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell --- ^ - meta.declaration +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell -- ^^^^ keyword.declaration.type.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell @@ -1362,6 +1361,65 @@ -- ^^^^^^^ entity.other.inherited-class.haskell -- ^ punctuation.section.sequence.end.haskell + type Id a = a +-- ^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^ keyword.operator.haskell +-- ^ variable.other.generic-type.haskell + + type Const a b = a +-- ^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^ keyword.operator.haskell +-- ^ variable.other.generic-type.haskell + + type FunctionTo a b = b -> a +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^ keyword.operator.haskell +-- ^ variable.other.generic-type.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^ variable.other.generic-type.haskell + + type Indexed f g = forall i. f i -> g i +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^ keyword.operator.haskell +-- ^^^^^^ keyword.control.forall.haskell +-- ^ variable.other.generic-type.haskell +-- ^ keyword.operator.haskell +-- ^ variable.other.generic-type.haskell +-- ^ variable.other.generic-type.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^ variable.other.generic-type.haskell +-- ^ variable.other.generic-type.haskell + + type ShowIndexed f g = forall i. (Show i) => f i -> g i +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^ keyword.operator.haskell +-- ^^^^^^ keyword.control.forall.haskell +-- ^ variable.other.generic-type.haskell +-- ^ keyword.operator.haskell +-- ^^^^^^^^ meta.sequence.tuple.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^ support.class.prelude.haskell +-- ^ variable.other.generic-type.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^ keyword.operator.big-arrow.haskell +-- ^ variable.other.generic-type.haskell +-- ^ variable.other.generic-type.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^ variable.other.generic-type.haskell +-- ^ variable.other.generic-type.haskell + + type ShowConstrained f a = (Show a) => f a +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^ keyword.operator.haskell +-- ^^^^^^^^ meta.sequence.tuple.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^ support.class.prelude.haskell +-- ^ variable.other.generic-type.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^ keyword.operator.big-arrow.haskell +-- ^ variable.other.generic-type.haskell +-- ^ variable.other.generic-type.haskell + type CmdRoute = -- ^^^^^^^^^^^^^^ meta.declaration.type.haskell -- ^^^^ keyword.declaration.type.haskell From 45b0b029b07543ac39d4ba8d3d2ec5679e039537 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Mon, 28 Dec 2020 16:58:49 +0100 Subject: [PATCH 082/178] [Haskell] Add comment test case Added from another PR. --- Haskell/syntax_test_haskell.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index ebd81d23ac..06334d8357 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -5,6 +5,10 @@ 23*36 -- single line comment -- ^^ punctuation.definition.comment.haskell -- ^^^^^^^^^^^^^^^^^^^^^^^ comment.line.double-dash.haskell +23*36 --------------------------------------------------- single line comment +-- ^ - comment - punctuation +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.double-dash.haskell punctuation.definition.comment.haskell +-- ^^^^^^^^^^^^^^^^^^^^ comment.line.double-dash.haskell - punctuation 23*36 -- <- - comment.line.double-dash.haskell From f1ecd86ad09ca75e910ef70d963a7515445cafef Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Mon, 28 Dec 2020 18:10:48 +0100 Subject: [PATCH 083/178] [Haskell] Distinguish top-level declarations and statements Most declarations, such as classes, data, imports, functions, ... may only appear as top-level statements, which are not supported in nested code blocks. This commit therefore avoids matching those top-level declarations in nested code blocks to reduce false positives and improve performance. --- Haskell/Haskell.sublime-syntax | 51 ++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index c86a9db8de..f4e51a8395 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -171,21 +171,24 @@ contexts: - include: preprocessor-directives main: + - include: modules + - include: declarations - include: statements - include: expressions - statements: - - include: blocks - - include: functions - - include: instances + declarations: - include: classes - include: datas - - include: defaults - - include: deriving + - include: functions + - include: imports + - include: instances - include: newtypes - include: types - - include: imports - - include: modules + + statements: + - include: blocks + - include: defaults + - include: deriving - include: statement-terminators expressions: @@ -313,15 +316,16 @@ contexts: - match: module{{break}} scope: keyword.declaration.namespace.haskell push: + - module-block - module-meta - - module-body + - module-name module-meta: - meta_include_prototype: false - meta_scope: meta.declaration.module.haskell - include: immediatelly-pop - module-body: + module-name: - match: ({{con_id}})(\.) captures: 1: variable.namespace.haskell @@ -330,10 +334,10 @@ contexts: scope: entity.name.namespace.haskell - match: \( scope: punctuation.section.sequence.begin.haskell - set: module-tuple-body + set: module-exports-body - include: else-pop - module-tuple-body: + module-exports-body: - meta_scope: meta.sequence.tuple.haskell - include: tuple-end - include: range-tuples @@ -341,7 +345,7 @@ contexts: - include: sequence-separators - match: \( scope: punctuation.section.sequence.begin.haskell - push: module-tuple-body + push: module-exports-body - match: module{{break}} scope: keyword.declaration.namespace.haskell - include: ident-builtin-functions @@ -350,6 +354,23 @@ contexts: - include: ident-types - include: else-pop + module-block: + # The module body may be wrapped into braces, which still needs to be + # handled as top-level block containing top-level declarations. + - match: \{ + scope: punctuation.section.block.begin.haskell + set: module-block-body + - match: where{{break}} + scope: keyword.control.context.haskell + - include: else-pop + + module-block-body: + - meta_scope: meta.block.haskell + - include: block-end + - include: declarations + - include: statements + - include: expressions + ###[ IMPORT DECLARATIONS ]##################################################### imports: @@ -693,7 +714,9 @@ contexts: block-body: - meta_scope: meta.block.haskell - include: block-end - - include: main + - include: statements + - include: expressions + - include: else-pop lists: # 3.7 Lists From 07b4fee9154a41bd0998dd18dfe819cd4631203c Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Mon, 28 Dec 2020 18:17:50 +0100 Subject: [PATCH 084/178] [Haskell] Add signature statements support see: https://wiki.haskell.org/Module_signature --- Haskell/Haskell.sublime-syntax | 12 ++++ Haskell/syntax_test_haskell.hs | 103 +++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index f4e51a8395..96f5c57c54 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -319,12 +319,24 @@ contexts: - module-block - module-meta - module-name + # https://wiki.haskell.org/Module_signature + - match: signature{{break}} + scope: keyword.declaration.namespace.haskell + push: + - module-block + - signature-meta + - module-name module-meta: - meta_include_prototype: false - meta_scope: meta.declaration.module.haskell - include: immediatelly-pop + signature-meta: + - meta_include_prototype: false + - meta_scope: meta.declaration.signature.haskell + - include: immediatelly-pop + module-name: - match: ({{con_id}})(\.) captures: diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 06334d8357..618ddcbf9c 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -315,6 +315,109 @@ -- ^^^^^^ entity.name.namespace.haskell -- ^ punctuation.section.block.end.haskell + +-- [ MODULE SIGNATURE DECLARATIONS ] ------------------------------------------ + + 'signature +-- ^ keyword.operator.haskell +-- ^^^^^^^^^ keyword.declaration.namespace.haskell + + signature' +-- ^^^^^^^^^^ - keyword + + signature +-- ^^^^^^^^^^ meta.declaration.signature.haskell +-- ^^^^^^^^^ keyword.declaration.namespace.haskell + + signature Name +-- ^^^^^^^^^^^^^^^ meta.declaration.signature.haskell +-- ^^^^^^^^^ keyword.declaration.namespace.haskell +-- ^^^^ entity.name.namespace.haskell + + signature Name where +-- ^^^^^^^^^^^^^^^ meta.declaration.signature.haskell +-- ^^^^^ - meta.declaration.signature +-- ^^^^^^^^^ keyword.declaration.namespace.haskell +-- ^^^^ entity.name.namespace.haskell +-- ^^^^^ keyword.control.context.haskell + + signature () +-- ^^^^^^^^^^ meta.declaration.signature.haskell - meta.sequence +-- ^^ meta.declaration.signature.haskell meta.sequence.tuple.haskell +-- ^^^^^^^^^ keyword.declaration.namespace.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell + + signature Name () +-- ^^^^^^^^^^^^^^^ meta.declaration.signature.haskell - meta.sequence +-- ^^ meta.declaration.signature.haskell meta.sequence.tuple.haskell +-- ^^^^^^^^^ keyword.declaration.namespace.haskell +-- ^^^^ entity.name.namespace.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell + + signature Name () where +-- ^^^^^^^^^^^^^^^ meta.declaration.signature.haskell - meta.sequence +-- ^^ meta.declaration.signature.haskell meta.sequence.tuple.haskell +-- ^^^^^^^ - meta.declaration.signature +-- ^^^^^^^^^ keyword.declaration.namespace.haskell +-- ^^^^ entity.name.namespace.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^^^^ keyword.control.context.haskell + + signature Ns.Name (sym1, sym2) where { import Ns.Other; import Ns.Other2 } +-- ^^^^^^^^^^^^^^^^^^ meta.declaration.signature.haskell - meta.sequence +-- ^^^^^^^^^^^^ meta.declaration.signature.haskell meta.sequence.tuple.haskell +-- ^^^^^^ - meta.declaration.signature - meta.block - meta.sequence +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.haskell - meta.declaration.signature +-- ^ - meta.block +-- ^^^^^^^^^ keyword.declaration.namespace.haskell +-- ^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^ entity.name.namespace.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^ variable.function.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^ variable.function.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^^^^ keyword.control.context.haskell +-- ^ punctuation.section.block.begin.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^ entity.name.namespace.haskell +-- ^ punctuation.terminator.statement.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ entity.name.namespace.haskell +-- ^ punctuation.section.block.end.haskell + + signature Name (module Other.Module) where { import Other.Module } +-- ^^^^^^^^^^^^^^^ meta.declaration.signature.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^^^^ meta.declaration.signature.haskell meta.sequence.tuple.haskell +-- ^^^^^^^ - meta.declaration - meta.block - meta.sequence +-- ^^ meta.block.haskell - meta.import +-- ^^^^^^^^^^^^^^^^^^^^ meta.block.haskell meta.import.haskell +-- ^ meta.block.haskell - meta.import +-- ^ - meta.declaration - meta.block +-- ^^^^^^^^^ keyword.declaration.namespace.haskell +-- ^^^^ entity.name.namespace.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^^ keyword.declaration.namespace.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^^^^ keyword.control.context.haskell +-- ^ punctuation.section.block.begin.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ entity.name.namespace.haskell +-- ^ punctuation.section.block.end.haskell + -- [ IMPORT DECLARATIONS ] ---------------------------------------------------- 'import From 5aefbbf185ae727504bdcd65d9f714258d65d576 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Mon, 28 Dec 2020 20:30:18 +0100 Subject: [PATCH 085/178] [Haskell] Fix nested record field declarations Braces within groups and lists are record fields. --- Haskell/Haskell.sublime-syntax | 49 +++++++++++++++++++++------------- Haskell/syntax_test_haskell.hs | 43 ++++++++++++++++++++--------- 2 files changed, 61 insertions(+), 31 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 96f5c57c54..4aa5f00560 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -46,10 +46,8 @@ variables: operator_symbol: (?:{{symbol}}+) operator_parens: (?:{{no_comment_ahead}}{{operator_symbol}}) + consym: (?:[:]{{varsym}}) varsym: (?:[{{symbol}}&&[^:]]{{symbol}}*) - consym: (?:(?!{{reserved_op}})[:]{{symbol}}*) - reserved_op: |- - (?x: .. | :: | : | \\ | \| | <- | -> | @ | ~ | => | = )(?!{{symbol}}) # 2.6 Character and String Literals # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-200002.6 @@ -486,6 +484,8 @@ contexts: ###[ DATA DECLARATIONS ]####################################################### datas: + # 4.2.1 Algebraic Datatype Declarations + # https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-680004.2 - match: data{{break}} scope: meta.declaration.data.haskell @@ -500,7 +500,10 @@ contexts: - include: type-signature-body data-constructor: + - include: constructor-operators + - include: constructor-separators - include: records + - include: ident-types - include: else-pop ###[ DEFAULT DECLARATIONS ]#################################################### @@ -691,23 +694,18 @@ contexts: - include: type-content - include: else-pop - -###[ RECORD COSTRUCTORS ]###################################################### +###[ RECORD CONSTRUCTORS ]##################################################### records: - - match: ({{con_id}})\s*(\{) - captures: - 1: storage.type.haskell - 2: meta.block.haskell punctuation.section.block.begin.haskell - set: record-body + - match: \{ + scope: punctuation.section.block.begin.haskell + push: record-body record-body: - - meta_scope: meta.record.haskell - - meta_content_scope: meta.block.haskell - - match: \} - scope: meta.block.haskell punctuation.section.block.end.haskell - pop: 1 + - meta_scope: meta.record.haskell meta.block.haskell + - include: block-end - include: expressions + - include: else-pop ###[ BLOCKS / GROUPS / LISTS / TUPLES ]######################################## @@ -745,6 +743,7 @@ contexts: list-body: - meta_scope: meta.sequence.list.haskell - include: list-end + - include: records - include: expressions groups-or-tuples: @@ -778,6 +777,7 @@ contexts: - match: ',|:(?!{{symbol}})' fail: groups-or-tuples - include: group-end + - include: records - include: expressions tuple: @@ -793,6 +793,7 @@ contexts: tuple-body: - meta_scope: meta.sequence.tuple.haskell - include: tuple-end + - include: records - include: expressions range-tuples: @@ -940,11 +941,10 @@ contexts: scope: keyword.control.flow.return.haskell operators: - - include: infix-parens-operators + - include: constructor-separators - include: sequence-separators + - include: infix-parens-operators - match: (`)[ \w'.]+(`) - # Haskell allows any ordinary function application (elem 4 [1..10]) - # to be rewritten as an infix expression (4 `elem` [1..10])." scope: keyword.operator.function.infix.haskell captures: 1: punctuation.definition.function.begin.haskell @@ -966,6 +966,19 @@ contexts: - match: (?:=>|⇒) scope: keyword.operator.big-arrow.haskell + constructor-operators: + - match: (`)\s*{{con_id}}\s*(`) + scope: keyword.operator.function.infix.haskell + captures: + 1: punctuation.definition.function.begin.haskell + 2: punctuation.definition.function.end.haskell + - match: '{{consym}}|!' + scope: keyword.operator.haskell + + constructor-separators: + - match: \|(?!\|) + scope: punctuation.separator.sequence.haskell + infix-parens-operators: - match: \(\s*({{operator_parens}})\s*\) scope: variable.function.infix.haskell diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 618ddcbf9c..e471a810ce 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -919,7 +919,7 @@ -- ^^^^^^ storage.type.haskell -- ^ keyword.operator.haskell Record { --- ^^^^^^^ meta.record.haskell - meta.block +-- ^^^^^^^ - meta.record -- ^^ meta.record.haskell meta.block.haskell -- ^^^^^^ storage.type.haskell -- ^ punctuation.section.block.begin.haskell @@ -981,25 +981,38 @@ -- ^^^^ keyword.declaration.data.haskell -- ^^^^^^^^^^ storage.type.haskell -- ^ keyword.operator.haskell - Flipper Record + Flipper !Record +-- ^^^^^^^ storage.type.haskell +-- ^ keyword.operator.haskell +-- ^^^^^^ storage.type.haskell | Int :! Int --- ^ keyword.operator.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^ storage.type.haskell -- ^^ keyword.operator.haskell +-- ^^^ storage.type.haskell | Double :@ Double --- ^ keyword.operator.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^ storage.type.haskell -- ^^ keyword.operator.haskell +-- ^^^^^^ storage.type.haskell | Int `Quux` Double --- ^ keyword.operator.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^ storage.type.haskell -- ^^^^^^ keyword.operator.function.infix.haskell +-- ^^^^^^ storage.type.haskell | String :# Record --- ^ keyword.operator.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^ storage.type.haskell -- ^^ keyword.operator.haskell +-- ^^^^^^ storage.type.haskell | Simple :$ Outrageous --- ^ keyword.operator.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^ storage.type.haskell -- ^^ keyword.operator.haskell +-- ^^^^^^^^^^ storage.type.haskell | DontDoThis { outrageousInt :: Int, outrageousString :: String } --- ^ keyword.operator.haskell --- ^^^^^^^^^^ constant.other.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^^^^ storage.type.haskell -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.haskell -- ^ punctuation.section.block.begin.haskell -- ^^^^^^^^^^^^^ meta.block.haskell meta.name.haskell @@ -1624,7 +1637,7 @@ foldBoolGuard x y z -- ^^^^^^^^^^^^^^^^^^^ source.haskell | z = y --- ^ keyword.operator.haskell +-- ^ punctuation.separator.sequence.haskell | otherwise = x countTheBeforeVowel :: String @@ -1753,7 +1766,7 @@ main = do -- ^ - meta.sequence -- ^ punctuation.section.sequence.begin.haskell -- ^ meta.name.haskell --- ^ keyword.operator.haskell +-- ^ punctuation.separator.sequence.haskell -- ^^ meta.name.haskell -- ^^ keyword.operator.haskell -- ^ punctuation.section.sequence.begin.haskell @@ -2715,7 +2728,7 @@ main = do -- ^ - keyword -- ^ keyword.operator.haskell -- ^ - keyword --- ^ keyword.operator.haskell +-- ^ punctuation.separator.sequence.haskell -- ^ - keyword -- ^ keyword.operator.haskell -- ^ - keyword @@ -2731,7 +2744,7 @@ main = do -- ^ keyword.operator.haskell -- ^ keyword.operator.haskell -- ^^ keyword.operator.haskell --- ^ keyword.operator.haskell +-- ^ punctuation.separator.sequence.haskell -- ^^ keyword.operator.haskell -- ^ keyword.operator.haskell -- ^ keyword.operator.haskell @@ -2748,6 +2761,10 @@ main = do -- ^ punctuation.section.block.begin.haskell -- ^ punctuation.section.block.end.haskell + a a = a || b +-- ^ keyword.operator.haskell +-- ^^ keyword.operator.haskell + a a = (+) a 2 -- ^ keyword.operator.haskell -- ^^^ variable.function.infix.haskell From 248fa1f892198d4f654d38684c90a75880374649 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Mon, 28 Dec 2020 20:56:20 +0100 Subject: [PATCH 086/178] [Haskell] Remove ident-constants It appears Haskell only knows about variables vs. constructors. Constructors are data types, either classes or user defined types. Scoping those constant.other therefore feels odd. There are some constructors such as `True`, `False` or `Nothing` which are used as constants though. This commit therefore scopes all constructors as storage.type except the ones known to have constant character. It helps keeping syntax highlighting consistent in ambiguous situations. --- Haskell/Haskell.sublime-syntax | 7 +------ Haskell/syntax_test_haskell.hs | 10 +++++----- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 4aa5f00560..abdce16d72 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -201,10 +201,9 @@ contexts: - include: keywords - include: ident-anonymous - include: ident-namespaces - - include: ident-builtin-classes - include: ident-builtin-constants - include: ident-builtin-functions - - include: ident-constants + - include: ident-types - include: ident-variables ###[ COMMENTS ]################################################################ @@ -842,10 +841,6 @@ contexts: - match: '{{constant_names}}' scope: constant.language.haskell - ident-constants: - - match: '{{con_id}}' - scope: constant.other.haskell - ident-builtin-functions: - match: '{{function_names}}' scope: support.function.prelude.haskell diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index e471a810ce..4f245089ff 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -1118,7 +1118,7 @@ -- ^^^^^^ - meta.declaration -- ^^^^^^^^ storage.modifier.haskell -- ^^^^^ entity.other.inherited-class.haskell --- ^^^^^ constant.other.haskell +-- ^^^^^ storage.type.haskell deriving ModId.QTyCls ModId.Const -- ^^^^^^^^^^^^^^^^^^^^^ meta.declaration.deriving.haskell @@ -1129,7 +1129,7 @@ -- ^^^^^^ entity.other.inherited-class.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^ constant.other.haskell +-- ^^^^^ storage.type.haskell deriving () -- ^^^^^^^^^ meta.declaration.deriving.haskell - meta.sequence @@ -1933,7 +1933,7 @@ main = do -- ^ meta.name.haskell T . a --- ^ constant.other.haskell +-- ^ storage.type.haskell -- ^ keyword.operator.haskell -- ^ meta.name.haskell @@ -2628,9 +2628,9 @@ main = do A' = A' -- ^^^^^^^ - meta.string - string --- ^^ constant.other.haskell - string +-- ^^ storage.type.haskell -- ^ keyword.operator.haskell --- ^^ constant.other.haskell - string +-- ^^ storage.type.haskell a' = b' -- ^^^^^^^ - meta.string - string From 6265cdcbb8b6fd57ba4455e1d922df4419004c20 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Mon, 28 Dec 2020 21:00:14 +0100 Subject: [PATCH 087/178] [Haskell] Rename meta.name to variable.other This commit scopes arbitrary variable identifiers `variable.other` instead of `meta.name` as meta scopes should not be used to scope single tokens/identifiers. Identifiers can be variables or functions, we can't distinguish. --- Haskell/Haskell.sublime-syntax | 2 +- Haskell/syntax_test_haskell.hs | 74 +++++++++++++++++----------------- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index abdce16d72..64dd962509 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -855,7 +855,7 @@ contexts: ident-variables: - match: '{{var_id}}' - scope: meta.name.haskell + scope: variable.other.haskell ###[ LITERALS ]################################################################ diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 4f245089ff..cf10bf6235 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -722,7 +722,7 @@ -- ^^^^^^ variable.other.generic-type.haskell -- ^^^^^^ variable.other.generic-type.haskell -- ^ punctuation.separator.sequence.haskell --- ^^^^^ meta.name.haskell +-- ^^^^^ variable.other.haskell class ModId.QTyCls tyVar1 tyVar2 => -- ^^^^^ meta.declaration.class.haskell @@ -894,7 +894,7 @@ -- ^^^^ keyword.declaration.data.haskell data' --- ^^^^^ meta.name.haskell +-- ^^^^^ variable.other.haskell data TyCls -- ^^^^^^^^^^^ meta.declaration.data.haskell @@ -924,22 +924,22 @@ -- ^^^^^^ storage.type.haskell -- ^ punctuation.section.block.begin.haskell recordInt :: Int --- ^^^^^^^^^ meta.name.haskell +-- ^^^^^^^^^ variable.other.haskell -- ^^ keyword.operator.double-colon.haskell -- ^^^ storage.type.haskell , recordString :: String -- ^ punctuation.separator.sequence.haskell --- ^^^^^^^^^^^^ meta.name.haskell +-- ^^^^^^^^^^^^ variable.other.haskell -- ^^ keyword.operator.double-colon.haskell -- ^^^^^^ storage.type.haskell , recordDouble :: Double -- ^ punctuation.separator.sequence.haskell --- ^^^^^^^^^^^^ meta.name.haskell +-- ^^^^^^^^^^^^ variable.other.haskell -- ^^ keyword.operator.double-colon.haskell -- ^^^^^^ storage.type.haskell , recordRational :: Rational -- ^ punctuation.separator.sequence.haskell --- ^^^^^^^^^^^^^^ meta.name.haskell +-- ^^^^^^^^^^^^^^ variable.other.haskell -- ^^ keyword.operator.double-colon.haskell -- ^^^^^^^^ support.class.prelude.haskell } deriving (Eq, Ord, Generic) @@ -1015,11 +1015,11 @@ -- ^^^^^^^^^^ storage.type.haskell -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.haskell -- ^ punctuation.section.block.begin.haskell --- ^^^^^^^^^^^^^ meta.block.haskell meta.name.haskell +-- ^^^^^^^^^^^^^ meta.block.haskell variable.other.haskell -- ^^ keyword.operator.double-colon.haskell -- ^^^ storage.type.haskell -- ^ punctuation.separator.sequence.haskell --- ^^^^^^^^^^^^^^^^ meta.block.haskell meta.name.haskell +-- ^^^^^^^^^^^^^^^^ meta.block.haskell variable.other.haskell -- ^^ keyword.operator.double-colon.haskell -- ^^^^^^ storage.type.haskell -- ^ punctuation.section.block.end.haskell @@ -1733,9 +1733,9 @@ main = do -- ^ punctuation.separator.sequence.haskell -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell -- ^ punctuation.separator.sequence.haskell --- ^ meta.name.haskell +-- ^ variable.other.haskell -- ^ punctuation.separator.sequence.haskell --- ^^ meta.name.haskell +-- ^^ variable.other.haskell -- ^ punctuation.separator.sequence.haskell -- ^^^ meta.string.haskell string.quoted.single.haskell -- ^ punctuation.separator.sequence.haskell @@ -1765,9 +1765,9 @@ main = do -- ^^^^^^^^ meta.sequence.list.haskell - meta.sequence meta.sequence -- ^ - meta.sequence -- ^ punctuation.section.sequence.begin.haskell --- ^ meta.name.haskell +-- ^ variable.other.haskell -- ^ punctuation.separator.sequence.haskell --- ^^ meta.name.haskell +-- ^^ variable.other.haskell -- ^^ keyword.operator.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^ punctuation.section.sequence.begin.haskell @@ -1800,10 +1800,10 @@ main = do -- ^ punctuation.section.sequence.begin.haskell -- ^ constant.numeric.value.haskell -- ^ punctuation.separator.sequence.haskell --- ^ meta.name.haskell +-- ^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell -- ^^ keyword.operator.haskell --- ^^ meta.name.haskell +-- ^^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell -- @@ -1900,42 +1900,42 @@ main = do -- ^ variable.language.anonymous.haskell a --- ^ meta.name.haskell +-- ^ variable.other.haskell _a --- ^^ meta.name.haskell +-- ^^ variable.other.haskell _' --- ^^ meta.name.haskell +-- ^^ variable.other.haskell a' --- ^^ meta.name.haskell +-- ^^ variable.other.haskell _a'b'c_D'0123456789' --- ^^^^^^^^^^^^^^^^^^^^ meta.name.haskell +-- ^^^^^^^^^^^^^^^^^^^^ variable.other.haskell genericIdent --- ^^^^^^^^^^^^ meta.name.haskell +-- ^^^^^^^^^^^^ variable.other.haskell ý ij ǚ ǣ --- ^ meta.name.haskell +-- ^ variable.other.haskell -- ^ - meta.name --- ^ meta.name.haskell +-- ^ variable.other.haskell -- ^ - meta.name --- ^ meta.name.haskell +-- ^ variable.other.haskell -- ^ - meta.name --- ^ meta.name.haskell +-- ^ variable.other.haskell -- ^ - meta.name T.a -- ^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^ meta.name.haskell +-- ^ variable.other.haskell T . a -- ^ storage.type.haskell -- ^ keyword.operator.haskell --- ^ meta.name.haskell +-- ^ variable.other.haskell Just -- ^^^^ constant.language.haskell @@ -2619,12 +2619,12 @@ main = do 'a -- ^^ - meta.string - string -- ^ keyword.operator.haskell --- ^ meta.name.haskell +-- ^ variable.other.haskell 'ab' -- ^^^^ - meta.string - string -- ^ keyword.operator.haskell --- ^^^ meta.name.haskell +-- ^^^ variable.other.haskell A' = A' -- ^^^^^^^ - meta.string - string @@ -2634,17 +2634,17 @@ main = do a' = b' -- ^^^^^^^ - meta.string - string --- ^^ meta.name.haskell - string +-- ^^ variable.other.haskell - string -- ^ keyword.operator.haskell --- ^^ meta.name.haskell - string +-- ^^ variable.other.haskell - string '\c' . '\z' -- ^^^^^^^^^^^ - meta.string - string -- ^^ keyword.operator.haskell --- ^^ meta.name.haskell +-- ^^ variable.other.haskell -- ^ keyword.operator.haskell -- ^^ keyword.operator.haskell --- ^^ meta.name.haskell +-- ^^ variable.other.haskell '\?' -- ^^^^ keyword.operator.haskell - string @@ -2656,21 +2656,21 @@ main = do '\o8' '\o9' -- ^^^^^^^^^^^ - meta.string - string - constant.character -- ^^ keyword.operator.haskell --- ^^^ meta.name.haskell +-- ^^^ variable.other.haskell -- ^^ keyword.operator.haskell --- ^^^ meta.name.haskell +-- ^^^ variable.other.haskell '\xG' '\xh' -- ^^^^^^^^^^^ - meta.string - string - constant.character -- ^^ keyword.operator.haskell --- ^^^ meta.name.haskell +-- ^^^ variable.other.haskell -- ^^ keyword.operator.haskell --- ^^^ meta.name.haskell +-- ^^^ variable.other.haskell '^a' '^)' -- ^^^^^^^^^ - meta.string - string - constant.character -- ^^ keyword.operator.haskell --- ^^ meta.name.haskell +-- ^^ variable.other.haskell -- ^^ keyword.operator.haskell -- ^ keyword.operator.haskell From 17027e013b588276b9908d08916a594feefdbbae Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Tue, 29 Dec 2020 10:41:52 +0100 Subject: [PATCH 088/178] [Haskell] Simplify `variable.other.generic-type` scope This commit removes `generic-type` from type variables as they are handled like any other variable in context of type signatures. Primary goal is to reduce syntax complexity and maintain scope and highlighting consistency in ambiguous statements/expressions. --- Haskell/Haskell.sublime-syntax | 10 +-- Haskell/syntax_test_haskell.hs | 154 ++++++++++++++++----------------- 2 files changed, 80 insertions(+), 84 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 64dd962509..5f9870bffc 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -461,7 +461,7 @@ contexts: - include: ident-anonymous - include: ident-namespaces - include: ident-types - - include: ident-generic-types + - include: ident-variables class-context-tuples: - match: \( @@ -649,7 +649,7 @@ contexts: - include: ident-anonymous - include: ident-namespaces - include: ident-types - - include: ident-generic-types + - include: ident-variables type-forall: - match: ∀(?!{{symbol}}) @@ -664,7 +664,7 @@ contexts: scope: keyword.operator.haskell pop: 1 - include: ident-anonymous - - include: ident-generic-types + - include: ident-variables - include: else-pop type-lists: @@ -822,10 +822,6 @@ contexts: scope: entity.other.inherited-class.haskell pop: 1 - ident-generic-types: - - match: '{{var_id}}' - scope: variable.other.generic-type.haskell - ident-namespaces: - match: ({{con_id}})(\.) captures: diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index cf10bf6235..216f72292c 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -709,7 +709,7 @@ -- ^^^^^^^^^^^^^^ meta.declaration.class.signature.haskell -- ^^^^^ keyword.declaration.class.haskell -- ^^^^^^ storage.type.haskell --- ^^^^^ variable.other.generic-type.haskell +-- ^^^^^ variable.other.haskell class ModId.QTyCls tyVar1 tyVar2, ident -- ^^^^^ meta.declaration.class.haskell @@ -719,8 +719,8 @@ -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell --- ^^^^^^ variable.other.generic-type.haskell --- ^^^^^^ variable.other.generic-type.haskell +-- ^^^^^^ variable.other.haskell +-- ^^^^^^ variable.other.haskell -- ^ punctuation.separator.sequence.haskell -- ^^^^^ variable.other.haskell @@ -733,8 +733,8 @@ -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell --- ^^^^^^ variable.other.generic-type.haskell --- ^^^^^^ variable.other.generic-type.haskell +-- ^^^^^^ variable.other.haskell +-- ^^^^^^ variable.other.haskell -- ^^ keyword.operator.big-arrow.haskell class ModId.QTyCls (tyVar1 tyVar2) => @@ -749,8 +749,8 @@ -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell -- ^ punctuation.section.sequence.begin.haskell --- ^^^^^^ variable.other.generic-type.haskell --- ^^^^^^ variable.other.generic-type.haskell +-- ^^^^^^ variable.other.haskell +-- ^^^^^^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell -- ^^ keyword.operator.big-arrow.haskell @@ -765,8 +765,8 @@ -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell -- ^ punctuation.section.sequence.begin.haskell --- ^^^^^^ variable.other.generic-type.haskell --- ^^^^^^ variable.other.generic-type.haskell +-- ^^^^^^ variable.other.haskell +-- ^^^^^^ variable.other.haskell -- ^^ keyword.operator.big-arrow.haskell class ModId.QTyCls tyVar1 tyVar2 => Traversable t @@ -778,11 +778,11 @@ -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell --- ^^^^^^ variable.other.generic-type.haskell --- ^^^^^^ variable.other.generic-type.haskell +-- ^^^^^^ variable.other.haskell +-- ^^^^^^ variable.other.haskell -- ^^ keyword.operator.big-arrow.haskell -- ^^^^^^^^^^^ support.class.prelude.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell class () => -- ^^^^^ meta.declaration.class.haskell @@ -806,14 +806,14 @@ -- ^^^^^ keyword.declaration.class.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^^^^^ support.class.prelude.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell -- ^ punctuation.separator.sequence.haskell -- ^^^^^^^^ storage.type.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell -- ^^ keyword.operator.big-arrow.haskell -- ^^^^^^^^^^^ support.class.prelude.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell -- ^^^^^ keyword.control.context.haskell -- A class declaration with no where part may be useful for combining @@ -827,11 +827,11 @@ -- ^^^^^^^^ meta.declaration.class.signature.haskell -- ^^^^^ keyword.declaration.class.haskell -- ^^ support.class.prelude.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell -- ^^ keyword.operator.big-arrow.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell -- ^^ keyword.operator.arrow.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell class (Eq a, Show a, Eq b) => [a] -> [b] -> String -- ^^^^^ meta.declaration.class.haskell @@ -842,11 +842,11 @@ -- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.signature.haskell -- ^^^^^ keyword.declaration.class.haskell -- ^^ support.class.prelude.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell -- ^^ keyword.operator.big-arrow.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell -- ^^ keyword.operator.arrow.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell -- ^^ keyword.operator.arrow.haskell -- ^^^^^^ storage.type.haskell @@ -864,25 +864,25 @@ -- ^^^^^ keyword.declaration.class.haskell -- ^^ support.class.prelude.haskell -- ^ punctuation.section.sequence.begin.haskell --- ^ variable.other.generic-type.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell +-- ^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell -- ^ punctuation.separator.sequence.haskell -- ^^^^^^^ support.class.prelude.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell -- ^^ keyword.operator.big-arrow.haskell -- ^ punctuation.section.sequence.begin.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell -- ^^ keyword.operator.arrow.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell -- ^^ keyword.operator.arrow.haskell --- ^ variable.other.generic-type.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell +-- ^ variable.other.haskell -- ^^ keyword.operator.arrow.haskell --- ^ variable.other.generic-type.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell +-- ^ variable.other.haskell -- ^^ keyword.operator.arrow.haskell -- ^^^^ storage.type.haskell @@ -1218,7 +1218,7 @@ -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell instance ModId.QTyCls [a] -- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence @@ -1229,7 +1229,7 @@ -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell -- ^ punctuation.section.sequence.begin.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell instance ModId.QTyCls (a, b) @@ -1241,9 +1241,9 @@ -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell -- ^ punctuation.section.sequence.begin.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell -- ^ punctuation.separator.sequence.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell instance ModId.QTyCls (a -> b) @@ -1255,9 +1255,9 @@ -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell -- ^ punctuation.section.sequence.begin.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell -- ^^ keyword.operator.arrow.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell instance ModId.QTyCls ([] a b) @@ -1272,8 +1272,8 @@ -- ^^^^^^ storage.type.haskell -- ^^ punctuation.section.sequence.begin.haskell -- ^ punctuation.section.sequence.end.haskell --- ^ variable.other.generic-type.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell +-- ^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell instance ModId.QTyCls (() a b) @@ -1288,8 +1288,8 @@ -- ^^^^^^ storage.type.haskell -- ^^ punctuation.section.sequence.begin.haskell -- ^ punctuation.section.sequence.end.haskell --- ^ variable.other.generic-type.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell +-- ^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell instance ModId.QTyCls ((,) a b) @@ -1305,8 +1305,8 @@ -- ^^ punctuation.section.sequence.begin.haskell -- ^ punctuation.separator.sequence.haskell -- ^ punctuation.section.sequence.end.haskell --- ^ variable.other.generic-type.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell +-- ^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell instance ModId.QTyCls ((->) a b) @@ -1322,8 +1322,8 @@ -- ^^ punctuation.section.sequence.begin.haskell -- ^^ keyword.operator.arrow.haskell -- ^ punctuation.section.sequence.end.haskell --- ^ variable.other.generic-type.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell +-- ^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell instance Num a => Bar [a] where ... @@ -1332,11 +1332,11 @@ -- ^ meta.declaration.instance.haskell - meta.sequence -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^ support.class.prelude.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell -- ^^ keyword.operator.big-arrow.haskell -- ^^^ storage.type.haskell -- ^ punctuation.section.sequence.begin.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell -- ^^^^^ keyword.control.context.haskell @@ -1349,15 +1349,15 @@ -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^ support.class.prelude.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell -- ^ punctuation.separator.sequence.haskell -- ^^^^ support.class.prelude.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell -- ^^ keyword.operator.big-arrow.haskell -- ^^^ storage.type.haskell -- ^ punctuation.section.sequence.begin.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell -- ^^^^^ keyword.control.context.haskell @@ -1400,7 +1400,7 @@ -- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.newtype.haskell -- ^^^^^^^ keyword.declaration.newtype.haskell -- ^^^^^^ storage.type.haskell --- ^^^^^ variable.other.generic-type.haskell +-- ^^^^^ variable.other.haskell -- ^^ keyword.operator.big-arrow.haskell newtype () => ModId.QTyCls tyVar1 tyVar2 deriving (Class1, QTyCls2) @@ -1416,8 +1416,8 @@ -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell --- ^^^^^^ variable.other.generic-type.haskell --- ^^^^^^ variable.other.generic-type.haskell +-- ^^^^^^ variable.other.haskell +-- ^^^^^^ variable.other.haskell -- ^^^^^^^^ storage.modifier.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^^^^ entity.other.inherited-class.haskell @@ -1443,7 +1443,7 @@ -- ^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell -- ^^^^ keyword.declaration.type.haskell -- ^^^^^^ storage.type.haskell --- ^^^^^ variable.other.generic-type.haskell +-- ^^^^^ variable.other.haskell type ModId.QTyCls tyVar1 tyVar2 -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell @@ -1451,8 +1451,8 @@ -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell --- ^^^^^^ variable.other.generic-type.haskell --- ^^^^^^ variable.other.generic-type.haskell +-- ^^^^^^ variable.other.haskell +-- ^^^^^^ variable.other.haskell type ModId.QTyCls tyVar1 tyVar2 = -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell @@ -1460,8 +1460,8 @@ -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell --- ^^^^^^ variable.other.generic-type.haskell --- ^^^^^^ variable.other.generic-type.haskell +-- ^^^^^^ variable.other.haskell +-- ^^^^^^ variable.other.haskell type ModId.QTyCls tyVar1 tyVar2 deriving (Class1, QTyCls2) -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell @@ -1472,8 +1472,8 @@ -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell --- ^^^^^^ variable.other.generic-type.haskell --- ^^^^^^ variable.other.generic-type.haskell +-- ^^^^^^ variable.other.haskell +-- ^^^^^^ variable.other.haskell -- ^^^^^^^^ storage.modifier.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^^^^ entity.other.inherited-class.haskell @@ -1484,49 +1484,49 @@ type Id a = a -- ^^^^^^^^^^^^^^ meta.declaration.type.haskell -- ^ keyword.operator.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell type Const a b = a -- ^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell -- ^ keyword.operator.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell type FunctionTo a b = b -> a -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell -- ^ keyword.operator.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell -- ^^ keyword.operator.arrow.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell type Indexed f g = forall i. f i -> g i -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell -- ^ keyword.operator.haskell -- ^^^^^^ keyword.control.forall.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell -- ^ keyword.operator.haskell --- ^ variable.other.generic-type.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell +-- ^ variable.other.haskell -- ^^ keyword.operator.arrow.haskell --- ^ variable.other.generic-type.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell +-- ^ variable.other.haskell type ShowIndexed f g = forall i. (Show i) => f i -> g i -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell -- ^ keyword.operator.haskell -- ^^^^^^ keyword.control.forall.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell -- ^ keyword.operator.haskell -- ^^^^^^^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^^ support.class.prelude.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell -- ^^ keyword.operator.big-arrow.haskell --- ^ variable.other.generic-type.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell +-- ^ variable.other.haskell -- ^^ keyword.operator.arrow.haskell --- ^ variable.other.generic-type.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell +-- ^ variable.other.haskell type ShowConstrained f a = (Show a) => f a -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell @@ -1534,11 +1534,11 @@ -- ^^^^^^^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^^ support.class.prelude.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell -- ^^ keyword.operator.big-arrow.haskell --- ^ variable.other.generic-type.haskell --- ^ variable.other.generic-type.haskell +-- ^ variable.other.haskell +-- ^ variable.other.haskell type CmdRoute = -- ^^^^^^^^^^^^^^ meta.declaration.type.haskell From 223fd48d4ae89db74dcb806e09b6503f7d35cb0a Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Mon, 28 Dec 2020 21:54:54 +0100 Subject: [PATCH 089/178] [Haskell] Fix comments in quoted strings It turns out dashes in quoted strings (e.g.: "--string") don't start comments. The assumption was wrong. --- Haskell/Haskell.sublime-syntax | 2 +- Haskell/syntax_test_haskell.hs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 5f9870bffc..db5a476de2 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -900,7 +900,7 @@ contexts: literal-string-body: - meta_include_prototype: false - meta_scope: meta.string.haskell string.quoted.double.haskell - - match: \"|$|{{comment_ahead}} + - match: \"|$ scope: punctuation.definition.string.end.haskell pop: 1 - match: '{{escape_sequence}}' diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 216f72292c..b84b1591ee 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -2684,12 +2684,12 @@ main = do -- ^ punctuation.definition.string.end.haskell -- ^^^^ constant.character.escape.haskell - "ok\"()--"'ab' --- ^^^^^^^ meta.string.haskell string.quoted.double.haskell - comment --- ^^^^^^^^ comment.line.double-dash.haskell - string + "ok\"()--"'b' +-- ^^^^^^^^^^ meta.string.haskell string.quoted.double.haskell - comment +-- ^^^ meta.string.haskell string.quoted.single.haskell -- ^ punctuation.definition.string.begin.haskell -- ^^ constant.character.escape.haskell --- ^^ punctuation.definition.comment.haskell +-- ^^ - punctuation -- [ INFIX OPERATORS ] -------------------------------------------------------- From d52aee6437d9aae04e1d974a836d2d57b2d65bce Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Tue, 29 Dec 2020 10:54:53 +0100 Subject: [PATCH 090/178] [Haskell] Improve prelude types and variables This commit... 1. renames prelude/builtin variables 2. adds various builtin classes and types 3. adds missing (optional) keywords 4. reorganizes the identifiers section 5. scopes all prelude classes/constants/types `support....` Note: `otherwise` and `return` are prelude/builtin functions but no reserved keywords, hence they are removed from `keywords` context. --- Haskell/Haskell.sublime-syntax | 94 ++++++++++++++++++++-------------- Haskell/syntax_test_haskell.hs | 40 +++++++-------- 2 files changed, 76 insertions(+), 58 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index db5a476de2..2d188aea47 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -34,9 +34,9 @@ variables: var_id: (?:(?!{{reserved_id}})[[:lower:]_][\w']*) reserved_id: |- (?x: - case | class | data | default | deriving | do | else | foreign | if - | import | in | infix | infixl | infixr | instance | let | module | newtype - | of | then | type | where | _ + _ | case | class | data | default | deriving | do | else | family | forall + | foreign | if | import | in | infix | infixl | infixr | instance | let | mdo + | module | newtype | of | proc | rec | signature | then | type | via | where ){{break}} break: (?![\w']) @@ -67,17 +67,29 @@ variables: | (\^[A-Z@\[\]\\\^_]) # Control Chars ) - class_names: |- + builtin_classes: |- (?x: - Monad | Monadoid | Functor | Applicative | Foldableble | Traversable | Eq - | Ord | Read | Show | Num | Fractional | Rational | Enum | Bounded | Real - | RealFrac | RealFloat | Integral | Floating + # 9 Standard Prelude + Applicative | Bounded | Enum | Eq | Floating | Foldableble | Fractional + | Functor | Integral | Monad | Monadoid | Num | Ord | Rational | Read + | Real | RealFloat | RealFrac | Show | Traversable ){{break}} - constant_names: |- + builtin_constants: |- (?x: Just | Nothing | Left | Right | True | False | LT | EQ | GT ){{break}} - function_names: |- + builtin_types: |- + (?x: + # 9 Standard Prelude + Bool | Char | Double | Either | FilePath | Float | Int | Integer | IO + | IOError | Maybe | Ordering | ReadS | ShowS | String | Word + # 24 Foreign + # https://www.haskell.org/onlinereport/haskell2010/haskellch24.html#x32-26200024 + | Int8 | Int16 | Int32 | Int64 | Word8 | Word16 | Word32 | Word64 + | Ptr | FunPtr | StablePtr + ){{break}} + + builtin_functions: |- (?x: abs | acos | acosh | all | and | any | appendFile | asTypeOf | asin | asinh | atan | atan2 | atanh | break | ceiling | compare | concat @@ -201,7 +213,6 @@ contexts: - include: keywords - include: ident-anonymous - include: ident-namespaces - - include: ident-builtin-constants - include: ident-builtin-functions - include: ident-types - include: ident-variables @@ -357,7 +368,6 @@ contexts: push: module-exports-body - match: module{{break}} scope: keyword.declaration.namespace.haskell - - include: ident-builtin-functions - include: ident-functions - include: ident-namespaces - include: ident-types @@ -805,50 +815,60 @@ contexts: ###[ IDENTIFIERS ]############################################################# + ident-anonymous: + - match: _{{break}} + scope: variable.language.anonymous.haskell + ident-builtin-classes: - - match: '{{class_names}}' + # Prelude Class Types + - match: '{{builtin_classes}}' scope: support.class.prelude.haskell + ident-builtin-types: + # Prelude Data Types of special meaning + - match: '{{builtin_constants}}' + scope: support.constant.prelude.haskell + # Prelude Data Types + - match: '{{builtin_types}}' + scope: support.type.prelude.haskell + + ident-builtin-functions: + - match: '{{builtin_functions}}' + scope: support.function.prelude.haskell + + ident-namespaces: + - match: ({{con_id}})(\.) + captures: + 1: variable.namespace.haskell + 2: punctuation.accessor.dot.haskell + ident-inherited-classes: - include: ident-builtin-classes - match: '{{con_id}}' scope: entity.other.inherited-class.haskell ident-inherited-class: - - match: '{{class_names}}' + - match: '{{builtin_classes}}' scope: support.class.prelude.haskell pop: 1 + - match: '{{builtin_types}}' + scope: support.type.prelude.haskell + pop: 1 - match: '{{con_id}}' scope: entity.other.inherited-class.haskell pop: 1 - ident-namespaces: - - match: ({{con_id}})(\.) - captures: - 1: variable.namespace.haskell - 2: punctuation.accessor.dot.haskell - ident-types: - include: ident-builtin-classes + - include: ident-builtin-types - match: '{{con_id}}' scope: storage.type.haskell - ident-builtin-constants: - - match: '{{constant_names}}' - scope: constant.language.haskell - - ident-builtin-functions: - - match: '{{function_names}}' - scope: support.function.prelude.haskell - ident-functions: + - include: ident-builtin-functions - match: '{{var_id}}' scope: variable.function.haskell - ident-anonymous: - - match: _{{break}} - scope: variable.language.anonymous.haskell - ident-variables: - match: '{{var_id}}' scope: variable.other.haskell @@ -914,9 +934,7 @@ contexts: ###[ KEYWORDS AND OPERATORS ]################################################## keywords: - - match: let{{break}} - scope: keyword.declaration.variable.haskell - - match: (?:do|in|where){{break}} + - match: (?:mdo|do|in|rec|where){{break}} scope: keyword.control.context.haskell - match: (?:case|of){{break}} scope: keyword.control.conditional.select.haskell # the construct is commonly called "select" @@ -926,10 +944,10 @@ contexts: scope: keyword.control.conditional.then.haskell - match: else{{break}} scope: keyword.control.conditional.else.haskell - - match: otherwise{{break}} - scope: keyword.control.conditional.otherwise.haskell - - match: return{{break}} - scope: keyword.control.flow.return.haskell + - match: let{{break}} + scope: keyword.declaration.variable.haskell + - match: proc{{break}} + scope: keyword.declaration.function.haskell operators: - include: constructor-separators diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index b84b1591ee..3e08b20fe2 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -848,7 +848,7 @@ -- ^^ keyword.operator.arrow.haskell -- ^ variable.other.haskell -- ^^ keyword.operator.arrow.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ support.type.prelude.haskell class (Eq (f a), Functor f) => (a -> b) -> f a -> f b -> Bool -- ^^^^^ meta.declaration.class.haskell @@ -884,7 +884,7 @@ -- ^ variable.other.haskell -- ^ variable.other.haskell -- ^^ keyword.operator.arrow.haskell --- ^^^^ storage.type.haskell +-- ^^^^ support.type.prelude.haskell -- [ DATA DECLARATIONS ] ------------------------------------------------------ @@ -926,17 +926,17 @@ recordInt :: Int -- ^^^^^^^^^ variable.other.haskell -- ^^ keyword.operator.double-colon.haskell --- ^^^ storage.type.haskell +-- ^^^ support.type.prelude.haskell , recordString :: String -- ^ punctuation.separator.sequence.haskell -- ^^^^^^^^^^^^ variable.other.haskell -- ^^ keyword.operator.double-colon.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ support.type.prelude.haskell , recordDouble :: Double -- ^ punctuation.separator.sequence.haskell -- ^^^^^^^^^^^^ variable.other.haskell -- ^^ keyword.operator.double-colon.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ support.type.prelude.haskell , recordRational :: Rational -- ^ punctuation.separator.sequence.haskell -- ^^^^^^^^^^^^^^ variable.other.haskell @@ -987,22 +987,22 @@ -- ^^^^^^ storage.type.haskell | Int :! Int -- ^ punctuation.separator.sequence.haskell --- ^^^ storage.type.haskell +-- ^^^ support.type.prelude.haskell -- ^^ keyword.operator.haskell --- ^^^ storage.type.haskell +-- ^^^ support.type.prelude.haskell | Double :@ Double -- ^ punctuation.separator.sequence.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ support.type.prelude.haskell -- ^^ keyword.operator.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ support.type.prelude.haskell | Int `Quux` Double -- ^ punctuation.separator.sequence.haskell --- ^^^ storage.type.haskell +-- ^^^ support.type.prelude.haskell -- ^^^^^^ keyword.operator.function.infix.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ support.type.prelude.haskell | String :# Record -- ^ punctuation.separator.sequence.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ support.type.prelude.haskell -- ^^ keyword.operator.haskell -- ^^^^^^ storage.type.haskell | Simple :$ Outrageous @@ -1017,11 +1017,11 @@ -- ^ punctuation.section.block.begin.haskell -- ^^^^^^^^^^^^^ meta.block.haskell variable.other.haskell -- ^^ keyword.operator.double-colon.haskell --- ^^^ storage.type.haskell +-- ^^^ support.type.prelude.haskell -- ^ punctuation.separator.sequence.haskell -- ^^^^^^^^^^^^^^^^ meta.block.haskell variable.other.haskell -- ^^ keyword.operator.double-colon.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ support.type.prelude.haskell -- ^ punctuation.section.block.end.haskell deriving (Eq, Ord, Generic) -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.deriving.haskell @@ -1058,7 +1058,7 @@ -- ^^^^^^^^^ storage.type.haskell , return :: forall m a . Unrestricted.Monad m => a -> m a -- ^ punctuation.separator.sequence.haskell --- ^^^^^^ keyword.control.flow.return.haskell +-- ^^^^^^ support.function.prelude.haskell -- ^^ keyword.operator.double-colon.haskell -- ^^^^^^ keyword.control.forall.haskell -- ^ keyword.operator.haskell @@ -1681,7 +1681,7 @@ test a = case a of main = do -- ^^ keyword.control.context.haskell return () --- ^^^^^^ keyword.control.flow.return.haskell +-- ^^^^^^ support.function.prelude.haskell -- [ BLOCKS / GROUPS / LISTS / TUPLES ] --------------------------------------- @@ -1938,16 +1938,16 @@ main = do -- ^ variable.other.haskell Just --- ^^^^ constant.language.haskell +-- ^^^^ support.constant.prelude.haskell Nothing --- ^^^^^^^ constant.language.haskell +-- ^^^^^^^ support.constant.prelude.haskell False --- ^^^^^ constant.language.haskell +-- ^^^^^ support.constant.prelude.haskell True --- ^^^^ constant.language.haskell +-- ^^^^ support.constant.prelude.haskell map (flip (/)) [1..] -- ^^^ support.function.prelude.haskell From b16551925bcc802b3aae04f6d9dd0a56249af47b Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Tue, 29 Dec 2020 11:32:10 +0100 Subject: [PATCH 091/178] [Haskell] Common module/import scopes This commit simplifies identifier patterns in module declarations and import statements. All path elements use `ident-namespaces` context and the last element is scoped `entity.name` no matter whether it is aliased via `as` keyword or followed by import filters `(...)`. --- Haskell/Haskell.sublime-syntax | 20 ++++++++------------ Haskell/syntax_test_haskell.hs | 24 ++++++++++++------------ 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 2d188aea47..3230446dc7 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -346,12 +346,8 @@ contexts: - include: immediatelly-pop module-name: - - match: ({{con_id}})(\.) - captures: - 1: variable.namespace.haskell - 2: punctuation.accessor.dot.haskell - - match: '{{con_id}}' - scope: entity.name.namespace.haskell + - include: ident-namespaces + - include: ident-modules - match: \( scope: punctuation.section.sequence.begin.haskell set: module-exports-body @@ -409,12 +405,8 @@ contexts: import-body: - match: (?:qualified|as|hiding){{break}} scope: storage.modifier.import.haskell - - match: ({{con_id}})\s*(?:(\.)|(?=\(|as{{break}})) - captures: - 1: variable.namespace.haskell - 2: punctuation.accessor.dot.haskell - - match: '{{con_id}}' - scope: entity.name.namespace.haskell + - include: ident-namespaces + - include: ident-modules - match: \( scope: punctuation.section.sequence.begin.haskell set: import-tuple-body @@ -842,6 +834,10 @@ contexts: 1: variable.namespace.haskell 2: punctuation.accessor.dot.haskell + ident-modules: + - match: '{{con_id}}' + scope: entity.name.namespace.haskell + ident-inherited-classes: - include: ident-builtin-classes - match: '{{con_id}}' diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 3e08b20fe2..49e2e23e30 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -449,7 +449,7 @@ -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^^^ entity.name.namespace.haskell - punctuation -- ^^ storage.modifier.import.haskell -- ^^^^^^^^^^^^^ entity.name.namespace.haskell @@ -482,7 +482,7 @@ -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^^ entity.name.namespace.haskell - punctuation -- ^^^^^^^^^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^^^^^^ variable.function.haskell @@ -499,7 +499,7 @@ -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^^ entity.name.namespace.haskell - punctuation -- ^ punctuation.section.sequence.begin.haskell -- ^^^^^^^^^ storage.type.haskell -- ^ punctuation.section.sequence.begin.haskell @@ -517,7 +517,7 @@ -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^^ entity.name.namespace.haskell - punctuation -- ^ punctuation.section.sequence.begin.haskell -- ^^^^^^^^^ storage.type.haskell -- ^ punctuation.section.sequence.begin.haskell @@ -538,7 +538,7 @@ -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^^ entity.name.namespace.haskell - punctuation -- ^ punctuation.section.sequence.begin.haskell -- ^^^^^^^^^ storage.type.haskell -- ^ punctuation.section.sequence.begin.haskell @@ -559,7 +559,7 @@ -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^^ entity.name.namespace.haskell - punctuation -- ^ punctuation.section.sequence.begin.haskell -- ^^^^^^^^^ storage.type.haskell -- ^ punctuation.section.sequence.begin.haskell @@ -602,7 +602,7 @@ -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^^ entity.name.namespace.haskell - punctuation -- ^^^^ meta.sequence.tuple.haskell -- ^^ punctuation.section.sequence.begin.haskell -- ^^ punctuation.section.sequence.end.haskell @@ -614,7 +614,7 @@ -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^^ entity.name.namespace.haskell - punctuation -- ^^^^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^ comment.line.double-dash.haskell @@ -629,7 +629,7 @@ -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^^ entity.name.namespace.haskell - punctuation -- ^^^^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^^ comment.line.double-dash.haskell @@ -644,7 +644,7 @@ -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^^ entity.name.namespace.haskell - punctuation -- ^^^^^^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^^^ comment.line.double-dash.haskell @@ -659,7 +659,7 @@ -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^^ entity.name.namespace.haskell - punctuation -- ^^^^^^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^^^ comment.line.double-dash.haskell @@ -674,7 +674,7 @@ -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^ variable.namespace.haskell - punctuation +-- ^^^^^^ entity.name.namespace.haskell - punctuation -- ^^^^^^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^^^ comment.line.double-dash.haskell From d9cdfcadcc6bb9759ea3ebb531cffccd7ad306c6 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Tue, 29 Dec 2020 11:41:41 +0100 Subject: [PATCH 092/178] [Haskell] Add data family modifiers --- Haskell/Haskell.sublime-syntax | 3 +++ Haskell/syntax_test_haskell.hs | 43 ++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 3230446dc7..d519728fe6 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -498,6 +498,9 @@ contexts: - match: = scope: keyword.operator.haskell set: data-constructor + # https://wiki.haskell.org/GHC/Type_families + - match: (?:family|instance){{break}} + scope: storage.modifier.family.haskell - include: type-signature-body data-constructor: diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 49e2e23e30..a20488d3a5 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -913,6 +913,49 @@ -- ^^^^ keyword.declaration.data.haskell -- ^ keyword.operator.haskell + -- Declare a list-like data family + data family XList a +-- ^^^^^^^^^^^^^^^^^^^^ meta.declaration.data.haskell +-- ^^^^ keyword.declaration.data.haskell +-- ^^^^^^ storage.modifier.family.haskell +-- ^^^^^ storage.type.haskell +-- ^ variable.other.haskell + + -- Declare a list-like instance for Char + data instance XList Char = XCons !Char !(XList Char) | XNil +-- ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.data.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.declaration +-- ^^^^^^^^^^^^ meta.group.haskell +-- ^^^^ keyword.declaration.data.haskell +-- ^^^^^^^^ storage.modifier.family.haskell +-- ^^^^^ storage.type.haskell +-- ^^^^ support.type.prelude.haskell +-- ^ keyword.operator.haskell +-- ^^^^^ storage.type.haskell +-- ^ keyword.operator.haskell +-- ^^^^ support.type.prelude.haskell +-- ^ keyword.operator.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^^^^^ storage.type.haskell +-- ^^^^ support.type.prelude.haskell +-- ^ punctuation.section.group.end.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^ storage.type.haskell + + -- Declare a number-like instance for () + data instance XList () = XListUnit !Int +-- ^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.data.haskell +-- ^^^^^^^^^^^^^^^^^ - meta.declaration +-- ^^^^ keyword.declaration.data.haskell +-- ^^^^^^^^ storage.modifier.family.haskell +-- ^^^^^ storage.type.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^ keyword.operator.haskell +-- ^^^^^^^^^ storage.type.haskell +-- ^ keyword.operator.haskell +-- ^^^ support.type.prelude.haskell + data Record = -- ^^^^^^^^^^^^ meta.declaration.data.haskell -- ^^^^ keyword.declaration.data.haskell From 216c5ba4e3da06b6db385224f708cad353dc2fce Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Tue, 29 Dec 2020 11:53:34 +0100 Subject: [PATCH 093/178] [Haskell] Add foreign import/export statements https://wiki.haskell.org/Keywords#foreign --- Haskell/Haskell.sublime-syntax | 42 +++++++++++ Haskell/syntax_test_haskell.hs | 126 +++++++++++++++++++++++++++++++++ 2 files changed, 168 insertions(+) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index d519728fe6..84a61932a9 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -189,6 +189,7 @@ contexts: declarations: - include: classes - include: datas + - include: foreigns - include: functions - include: imports - include: instances @@ -429,6 +430,47 @@ contexts: - include: ident-types - include: else-pop +###[ FOREIGN DECLARATIONS ]#################################################### + + foreigns: + # 8.4 Foreign Declarations + # https://www.haskell.org/onlinereport/haskell2010/haskellch8.html#x15-1490008 + - match: foreign{{break}} + scope: storage.modifier.foreign.haskell + branch_point: foreign + branch: + - foreign-import + - foreign-export + + foreign-import: + # 8.4.3 Import Declarations + - meta_scope: meta.declaration.foreign.import.haskell + - match: export{{break}} + fail: foreign + - match: import{{break}} + scope: keyword.declaration.import.haskell + - match: (?:unsafe|safe){{break}} + scope: storage.modifier.import.haskell + - include: foreign-common + + foreign-export: + # 8.4.4 Export Declarations + - meta_scope: meta.declaration.foreign.export.haskell + - match: export{{break}} + scope: keyword.declaration.export.haskell + - match: (?:unsafe|safe){{break}} + scope: invalid.illegal.unexpected-keyword.haskell + - include: foreign-common + + foreign-common: + - include: literal-strings + - include: infix-parens-operators + - match: (?:ccall|cplusplus|dotnet|jvm|stdcall){{break}} + scope: constant.language.convention.haskell + - match: '{{var_id}}' + scope: entity.name.function.haskell + - include: else-pop + ###[ CLASS DECLARATIONS ]###################################################### classes: diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index a20488d3a5..3d5d80bdd9 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -683,6 +683,132 @@ -- ^ punctuation.section.sequence.end.haskell +-- [ FOREIGN EXPORT DECLARATIONS ]--------------------------------------------- + + foreign export +-- ^^^^^^^^^^^^^^^ meta.declaration.foreign.export.haskell +-- ^^^^^^^ storage.modifier.foreign.haskell +-- ^^^^^^ keyword.declaration.export.haskell + + foreign export ccall +-- ^^^^^^^^^^^^^^^^^^^^^ meta.declaration.foreign.export.haskell +-- ^^^^^^^ storage.modifier.foreign.haskell +-- ^^^^^^ keyword.declaration.export.haskell +-- ^^^^^ constant.language.convention.haskell + + foreign export ccall triple :: Int -> Int +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.foreign.export.haskell +-- ^^^^^^^ storage.modifier.foreign.haskell +-- ^^^^^^ keyword.declaration.export.haskell +-- ^^^^^ constant.language.convention.haskell +-- ^^^^^^ entity.name.function.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^^^ support.type.prelude.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^^^ support.type.prelude.haskell + + foreign +-- ^^^^^^^^ meta.declaration.foreign.export.haskell +-- ^^^^^^^ storage.modifier.foreign.haskell + export +-- ^^^^^^^^ meta.declaration.foreign.export.haskell +-- ^^^^^^ keyword.declaration.export.haskell + ccall +-- ^^^^^^^ meta.declaration.foreign.export.haskell +-- ^^^^^ constant.language.convention.haskell + safe +-- ^^^^^^ meta.declaration.foreign.export.haskell +-- ^^^^ invalid.illegal.unexpected-keyword.haskell + triple +-- ^^^^^^^^ meta.declaration.foreign.export.haskell +-- ^^^^^^ entity.name.function.haskell + :: Int -> Int +-- ^ meta.declaration.foreign.export.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^^^ support.type.prelude.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^^^ support.type.prelude.haskell + + foreign export ccall "addInt" (+) :: Int->Int->Int +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.foreign.export.haskell +-- ^^^^^^^ storage.modifier.foreign.haskell +-- ^^^^^^ keyword.declaration.export.haskell +-- ^^^^^ constant.language.convention.haskell +-- ^^^^^^^^ meta.string.haskell string.quoted.double.haskell +-- ^^^ variable.function.infix.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^^^ support.type.prelude.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^^^ support.type.prelude.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^^^ support.type.prelude.haskell + + +-- [ FOREIGN IMPORT DECLARATIONS ]--------------------------------------------- + + foreign +-- ^^^^^^^^ meta.declaration.foreign.import.haskell +-- ^^^^^^^ storage.modifier.foreign.haskell + + foreign import +-- ^^^^^^^^^^^^^^^ meta.declaration.foreign.import.haskell +-- ^^^^^^^ storage.modifier.foreign.haskell +-- ^^^^^^ keyword.declaration.import.haskell + + foreign import ccall +-- ^^^^^^^^^^^^^^^^^^^^^ meta.declaration.foreign.import.haskell +-- ^^^^^^^ storage.modifier.foreign.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^^^^ constant.language.convention.haskell + + foreign import ccall "exp" +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.foreign.import.haskell +-- ^^^^^^^ storage.modifier.foreign.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^^^^ constant.language.convention.haskell +-- ^^^^^ meta.string.haskell string.quoted.double.haskell +-- + + foreign import ccall "exp" c_exp :: Double -> Double +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.foreign.import.haskell +-- ^^^^^^^ storage.modifier.foreign.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^^^^ constant.language.convention.haskell +-- ^^^^^ meta.string.haskell string.quoted.double.haskell +-- ^^^^^ entity.name.function.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^^^^^^ support.type.prelude.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^^^^^^ support.type.prelude.haskell + + foreign import dotnet safe "func" func :: String -> Bool +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.foreign.import.haskell +-- ^^^^^^^ storage.modifier.foreign.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^^^^^ constant.language.convention.haskell +-- ^^^^ storage.modifier.import.haskell +-- ^^^^^^ meta.string.haskell string.quoted.double.haskell +-- ^^^^ entity.name.function.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^^^^^^ support.type.prelude.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^^^^ support.type.prelude.haskell + + foreign import ccall "addInt" (+) :: Int->Int->Int +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.foreign.import.haskell +-- ^^^^^^^ storage.modifier.foreign.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^^^^ constant.language.convention.haskell +-- ^^^^^^^^ meta.string.haskell string.quoted.double.haskell +-- ^^^ variable.function.infix.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^^^ support.type.prelude.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^^^ support.type.prelude.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^^^ support.type.prelude.haskell + + -- [ CLASS DECLARATIONS ] ----------------------------------------------------- 'class From 1ffff85d5bb12447331b1d7c08f7b4136a738c84 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Tue, 29 Dec 2020 12:33:56 +0100 Subject: [PATCH 094/178] [Haskell] Restrict snippet scopes --- Haskell/Snippets/Case.sublime-snippet | 2 +- Haskell/Snippets/Instance.sublime-snippet | 2 +- Haskell/Snippets/Lambda.sublime-snippet | 2 +- Haskell/Snippets/Main.sublime-snippet | 2 +- Haskell/Snippets/module.sublime-snippet | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Haskell/Snippets/Case.sublime-snippet b/Haskell/Snippets/Case.sublime-snippet index 542f43961b..ccfc87a3c8 100644 --- a/Haskell/Snippets/Case.sublime-snippet +++ b/Haskell/Snippets/Case.sublime-snippet @@ -2,6 +2,6 @@ ${3:$1} ${1/./ /g} ${4:otherwise} -> ${0:$1}]]> case - source.haskell + source.haskell - comment - string Case diff --git a/Haskell/Snippets/Instance.sublime-snippet b/Haskell/Snippets/Instance.sublime-snippet index 939fe479ad..d5de6173e0 100644 --- a/Haskell/Snippets/Instance.sublime-snippet +++ b/Haskell/Snippets/Instance.sublime-snippet @@ -2,6 +2,6 @@ instance - source.haskell + source.haskell - comment - string - meta.declaration Instance diff --git a/Haskell/Snippets/Lambda.sublime-snippet b/Haskell/Snippets/Lambda.sublime-snippet index e8dd0b7a12..e1b5b25b90 100644 --- a/Haskell/Snippets/Lambda.sublime-snippet +++ b/Haskell/Snippets/Lambda.sublime-snippet @@ -1,6 +1,6 @@ ${0:f t}]]> \ - source.haskell + source.haskell - comment - string \t -> f t diff --git a/Haskell/Snippets/Main.sublime-snippet b/Haskell/Snippets/Main.sublime-snippet index 8aabb68067..c8dd39870e 100644 --- a/Haskell/Snippets/Main.sublime-snippet +++ b/Haskell/Snippets/Main.sublime-snippet @@ -3,6 +3,6 @@ main = ${1:putStrLn "Hello World"}]]> main - source.haskell + source.haskell - comment - string - meta.declaration Main diff --git a/Haskell/Snippets/module.sublime-snippet b/Haskell/Snippets/module.sublime-snippet index 06feabb7c7..faf61ff5e2 100644 --- a/Haskell/Snippets/module.sublime-snippet +++ b/Haskell/Snippets/module.sublime-snippet @@ -3,6 +3,6 @@ ${2:main = ${3:putStrLn "Hello World"}}]]> mod - source.haskell + source.haskell - comment - string - meta.block - meta.declaration Module From 1ccc0276c0f31429c22ab699edacd79f30714d7d Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Tue, 29 Dec 2020 16:54:31 +0100 Subject: [PATCH 095/178] [Haskell] Add class-block --- Haskell/Haskell.sublime-syntax | 17 +++++++++++++++++ Haskell/syntax_test_haskell.hs | 18 ++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 84a61932a9..116760cea2 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -522,8 +522,25 @@ contexts: class-signature: - meta_content_scope: meta.declaration.class.signature.haskell - include: type-content + - match: where{{break}} + scope: keyword.control.context.haskell + set: class-block - include: else-pop + class-block: + - match: \{ + scope: punctuation.section.block.begin.haskell + set: class-block-body + - match: ^(?!\s*(?:--|{-?|$)) + pop: 1 + + class-block-body: + - meta_scope: meta.block.haskell + - include: block-end + - include: functions + - include: statements + - include: expressions + ###[ DATA DECLARATIONS ]####################################################### datas: diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 3d5d80bdd9..d9e8e76a87 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -1012,6 +1012,24 @@ -- ^^ keyword.operator.arrow.haskell -- ^^^^ support.type.prelude.haskell + class Name where { +-- ^^^^^ keyword.declaration.class.haskell +-- ^^^^ storage.type.haskell +-- ^^^^^ keyword.control.context.haskell +-- ^^ meta.block.haskell +-- ^ punctuation.section.block.begin.haskell + method :: Bool -> Bool +-- ^^^^^^ entity.name.function.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^^^^ support.type.prelude.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^^^^ support.type.prelude.haskell + method = True +-- ^^^^^^ variable.other.haskell +-- ^ keyword.operator.haskell +-- ^^^^ support.constant.prelude.haskell + } + -- [ DATA DECLARATIONS ] ------------------------------------------------------ From 7dd4d6ce8db95528872f54a462f4da5a0c8b7c6b Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Tue, 29 Dec 2020 17:32:51 +0100 Subject: [PATCH 096/178] [Haskell] Ensure reserved unicode operator scopes --- Haskell/Haskell.sublime-syntax | 28 ++++++++++++++++++++-------- Haskell/syntax_test_haskell.hs | 10 +++++----- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 116760cea2..2fdee2c6ea 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -46,6 +46,11 @@ variables: operator_symbol: (?:{{symbol}}+) operator_parens: (?:{{no_comment_ahead}}{{operator_symbol}}) + operator_double_colon: (?:::|∷) + operator_big_arrow: (?:=>|⇒) + operator_left_arrow: (?:<-|←) + operator_right_arrow: (?:->|→) + consym: (?:[:]{{varsym}}) varsym: (?:[{{symbol}}&&[^:]]{{symbol}}*) @@ -492,7 +497,7 @@ contexts: class-context: # The context specifies the superclasses - meta_content_scope: meta.declaration.class.context.haskell - - match: => + - match: '{{operator_big_arrow}}' scope: meta.declaration.class.haskell keyword.operator.big-arrow.haskell @@ -692,7 +697,7 @@ contexts: type-signatures: # 3 Expressions # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html - - match: '::' + - match: '{{operator_double_colon}}' scope: keyword.operator.double-colon.haskell push: type-signature-body @@ -709,7 +714,7 @@ contexts: - include: type-forall - include: type-lists - include: type-tuples - - include: arrow-operators + - include: right-arrow-operators - include: ident-anonymous - include: ident-namespaces - include: ident-types @@ -1010,6 +1015,9 @@ contexts: operators: - include: constructor-separators - include: sequence-separators + - include: big-arrow-operators + - include: left-arrow-operators + - include: right-arrow-operators - include: infix-parens-operators - match: (`)[ \w'.]+(`) scope: keyword.operator.function.infix.haskell @@ -1025,14 +1033,18 @@ contexts: - match: '{{operator_symbol}}' scope: keyword.operator.haskell - arrow-operators: - - match: (?:->|→) - scope: keyword.operator.arrow.haskell - big-arrow-operators: - - match: (?:=>|⇒) + - match: '{{operator_big_arrow}}' scope: keyword.operator.big-arrow.haskell + left-arrow-operators: + - match: '{{operator_left_arrow}}' + scope: keyword.operator.arrow.haskell + + right-arrow-operators: + - match: '{{operator_right_arrow}}' + scope: keyword.operator.arrow.haskell + constructor-operators: - match: (`)\s*{{con_id}}\s*(`) scope: keyword.operator.function.infix.haskell diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index d9e8e76a87..859da7cd3d 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -1955,7 +1955,7 @@ main = do -- ^ variable.other.haskell -- ^ punctuation.separator.sequence.haskell -- ^^ variable.other.haskell --- ^^ keyword.operator.haskell +-- ^^ keyword.operator.arrow.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^ punctuation.section.sequence.begin.haskell @@ -1989,7 +1989,7 @@ main = do -- ^ punctuation.separator.sequence.haskell -- ^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell --- ^^ keyword.operator.haskell +-- ^^ keyword.operator.arrow.haskell -- ^^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell -- @@ -2930,12 +2930,12 @@ main = do -- ^^ keyword.operator.double-colon.haskell -- ^ keyword.operator.haskell -- ^ keyword.operator.haskell --- ^^ keyword.operator.haskell +-- ^^ keyword.operator.arrow.haskell -- ^ punctuation.separator.sequence.haskell --- ^^ keyword.operator.haskell +-- ^^ keyword.operator.arrow.haskell -- ^ keyword.operator.haskell -- ^ keyword.operator.haskell --- ^^ keyword.operator.haskell +-- ^^ keyword.operator.big-arrow.haskell ( ) , ; [ ] ` { } -- special symbols -- ^^^^^^^^^^^^^^^^^ - keyword From ff90c5e5170cb13854217244c80c7dd7c0fe7243 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Tue, 29 Dec 2020 21:07:47 +0100 Subject: [PATCH 097/178] [Haskell] Rework function declarations This commit ... 1. uses branching to detect function declaration names. Any variable or infix operator followed by `::` is a function definition in top-level and class-level statements. 2. removes type signature from function declarations as it is hard and error prone to find their end. It's also no longer required as type variables are scoped as `variable.other` as everything else. This fixes highlighting of function declarations ... a) whose type signature starts at the next line b) with a list of function identifiers followed by `::` c) which don't start at the beginning of a line due to block layout. --- Haskell/Haskell.sublime-syntax | 52 +++++-- Haskell/syntax_test_haskell.hs | 244 +++++++++++++++++++++------------ 2 files changed, 195 insertions(+), 101 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 2fdee2c6ea..bf416cb69d 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -195,11 +195,11 @@ contexts: - include: classes - include: datas - include: foreigns - - include: functions - include: imports - include: instances - include: newtypes - include: types + - include: functions statements: - include: blocks @@ -644,19 +644,47 @@ contexts: ###[ FUNCTION DECLARATIONS ]################################################### functions: - - match: ^(\s*)({{var_id}}|\(({{operator_parens}})\))\s*(::|∷) + - match: (?={{var_id}}|\(\s*{{operator_parens}}\s*\)) + branch_point: functions + branch: + - variable-name + - function-name + + function-name: + - meta_content_scope: meta.function.identifier.haskell + - match: '{{operator_double_colon}}' + scope: keyword.operator.double-colon.haskell + pop: 1 + - match: '{{var_id}}' + scope: entity.name.function.haskell + - match: \(\s*({{operator_parens}})\s*\) + scope: entity.name.function.infix.haskell captures: - 2: entity.name.function.haskell - 3: keyword.operator.infix.haskell - 4: keyword.operator.double-colon.haskell - push: function-body - - function-body: - - meta_scope: meta.function.type-declaration.haskell - - match: ^(?:(?!\s*(?:--|{-|$)|\1\s)|(?=\s*\2)) + 1: keyword.operator.haskell + - include: sequence-separators + + variable-name: + - match: \(\s*({{operator_parens}})\s*\) + scope: variable.function.infix.haskell + captures: + 1: keyword.operator.haskell + push: variable-name-end + - match: '{{builtin_functions}}' + scope: support.function.prelude.haskell + push: variable-name-end + - match: '{{var_id}}' + scope: variable.other.haskell + push: variable-name-end + - include: sequence-separators + - include: else-pop + + variable-name-end: + - match: (?={{operator_double_colon}}) + fail: functions + - match: (?=,) pop: 1 - - include: big-arrow-operators - - include: type-content + - match: (?=\S) + pop: 2 ###[ NEWTYPE DECLARATIONS ]#################################################### diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 859da7cd3d..149a190c29 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -1012,24 +1012,6 @@ -- ^^ keyword.operator.arrow.haskell -- ^^^^ support.type.prelude.haskell - class Name where { --- ^^^^^ keyword.declaration.class.haskell --- ^^^^ storage.type.haskell --- ^^^^^ keyword.control.context.haskell --- ^^ meta.block.haskell --- ^ punctuation.section.block.begin.haskell - method :: Bool -> Bool --- ^^^^^^ entity.name.function.haskell --- ^^ keyword.operator.double-colon.haskell --- ^^^^ support.type.prelude.haskell --- ^^ keyword.operator.arrow.haskell --- ^^^^ support.type.prelude.haskell - method = True --- ^^^^^^ variable.other.haskell --- ^ keyword.operator.haskell --- ^^^^ support.constant.prelude.haskell - } - -- [ DATA DECLARATIONS ] ------------------------------------------------------ @@ -1765,81 +1747,165 @@ -- ^ meta.group.haskell punctuation.section.group.end.haskell --- [ DECLARATIONS ] ----------------------------------------------------------- - - traverse :: Applicative f => --- ^^^^^^^^ entity.name.function.haskell --- ^^ keyword.operator.double-colon.haskell --- ^^^^^^^^^^^ support.class.prelude.haskell --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.type-declaration.haskell --- ^^ keyword.operator.big-arrow.haskell - (a -> f b) --- ^^^^^^^^^^^^ meta.function.type-declaration.haskell --- ^^ keyword.operator.arrow.haskell - -> t a --- ^^^^^^^^ meta.function.type-declaration.haskell --- ^^ keyword.operator.arrow.haskell - -> f (t b) --- ^^^^^^^^^^^^ meta.function.type-declaration.haskell --- ^^ keyword.operator.arrow.haskell - traverse f = sequenceA . fmap f --- ^ keyword.operator.haskell --- ^ keyword.operator.haskell - --- | Evaluate each action in the structure from --- left to right, and collect the results. --- For a version that ignores the results see --- 'Data.Foldable.sequenceA_'. - sequenceA ∷ Applicative f ⇒ t (f a) → f (t a) --- ^^^^^^^^^ entity.name.function.haskell --- ^ keyword.operator.double-colon.haskell --- ^^^^^^^^^^^ support.class.prelude.haskell --- ^ keyword.operator.big-arrow.haskell --- ^ keyword.operator.arrow.haskell - sequenceA = traverse id --- ^ keyword.operator.haskell +-- [ FUNCTION DECLARATIONS ] -------------------------------------------------- - if' --- ^^^ - keyword - --- Tests for #1320, #1880. - - class TooMany a where - tooMany :: a -> Bool --- ^^^^^^^^^^^^^^^^^^^^^^ meta.function.type-declaration.haskell - tooManyToo :: --- ^^^^^^^^^^^^^^^ meta.function.type-declaration.haskell - a -> Bool --- ^^^^^^^^^^^^^ meta.function.type-declaration.haskell - - instance TooMany Int where --- ^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell --- ^^^^^ - meta.declaration.instance --- ^^^^^^^^ keyword.declaration.instance.haskell --- ^^^^^ keyword.control.context.haskell - tooMany n = n > 42 - - foldBoolGuard :: a -> a -> Bool -> a --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.type-declaration.haskell - foldBoolGuard x y z --- ^^^^^^^^^^^^^^^^^^^ source.haskell - | z = y --- ^ punctuation.separator.sequence.haskell - | otherwise = x - - countTheBeforeVowel :: String - -- This comment should not interrupt the type signature. + {- infix operator declaration -} + (<:>) +-- ^^^^^^ meta.function.identifier.haskell +-- ^^^^^ entity.name.function.infix.haskell +-- ^^^ keyword.operator.haskell + :: a -> Bool +-- ^ meta.function.identifier.haskell +-- ^^^^^^^^^^^^^ - meta.function +-- ^^ keyword.operator.double-colon.haskell +-- ^ variable.other.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^^^^ support.type.prelude.haskell + + {- function declaration list -} + isNaN,, isInfinite +-- ^ - meta.function +-- ^^^^^^^^^^^^^^^^^^^ meta.function.identifier.haskell +-- ^^^^^ entity.name.function.haskell +-- ^^ punctuation.separator.sequence.haskell +-- ^^^^^^^^^^ entity.name.function.haskell + :: a -> Bool +-- ^ meta.function.identifier.haskell +-- ^^^^^^^^^^^^^ - meta.function +-- ^^ keyword.operator.double-colon.haskell +-- ^ variable.other..haskell +-- ^^ keyword.operator.arrow.haskell +-- ^^^^ support.type.prelude.haskell + + {- function declaration with context and unicode operators -} + sequenceA ∷ Applicative f ⇒ t (f a) → f (t a) +-- ^^^^^^^^^^ meta.function.identifier.haskell +-- ^^^^^^^^^ entity.name.function.haskell +-- ^ keyword.operator.double-colon.haskell +-- ^^^^^^^^^^^ support.class.prelude.haskell +-- ^ variable.other.haskell +-- ^ keyword.operator.big-arrow.haskell +-- ^ variable.other.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ variable.other.haskell +-- ^ variable.other.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^ keyword.operator.arrow.haskell +-- ^ variable.other.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ variable.other.haskell +-- ^ variable.other.haskell +-- ^ punctuation.section.sequence.end.haskell + {- function body -} + sequenceA = traverse id +-- ^^^^^^^^^ support.function.prelude.haskell +-- ^ keyword.operator.haskell +-- ^^^^^^^^ support.function.prelude.haskell +-- ^^ support.function.prelude.haskell + + {- function declaration with context and ascii operators -} + traverse :: Applicative f => +-- ^^^^^^^^^ meta.function.identifier.haskell +-- ^^^^^^^^^^^^^^^^^^^^ - meta.function +-- ^^^^^^^^ entity.name.function.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^^^^^^^^^^^ support.class.prelude.haskell +-- ^ variable.other.haskell +-- ^^ keyword.operator.big-arrow.haskell + (a -> f b) +-- ^^ keyword.operator.arrow.haskell + -> t a +-- ^^ keyword.operator.arrow.haskell + -> f (t b) +-- ^^ keyword.operator.arrow.haskell + + {- function body -} + traverse f = sequenceA . fmap f +-- ^^^^^^^^ support.function.prelude.haskell +-- ^ variable.other.haskell +-- ^ keyword.operator.haskell +-- ^^^^^^^^^ support.function.prelude.haskell +-- ^ keyword.operator.haskell +-- ^^^^ support.function.prelude.haskell +-- ^ variable.other.haskell - -- The blank line above should not interrupt the type signature. + {- Module Level Function Declarations -} + module ModId.ModName (fun) where + fun :: Bool -> Bool +-- ^^^^ meta.function.identifier.haskell +-- ^^^ entity.name.function.haskell +-- ^^ keyword.operator.double-colon.haskell - {- - This multiline comment should - not interrupt the type signature. - -} + {- Module Level Function Declarations with Block Layout -} + module ModId.ModName (fun1, fun2) where { fun1 :: Bool -> Bool ; fun2 :: } +-- ^^^^^^^^^^^^ meta.declaration.module.haskell meta.sequence.tuple.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^ variable.function.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^ variable.function.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^^^^ keyword.control.context.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.haskell +-- ^ punctuation.section.block.begin.haskell +-- ^^^^^ meta.function.identifier.haskell +-- ^^^^ entity.name.function.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^^^^ support.type.prelude.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^^^^ support.type.prelude.haskell +-- ^ punctuation.terminator.statement.haskell +-- ^^^^ entity.name.function.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^ punctuation.section.block.end.haskell - -> Integer --- ^^^^^^^^^^^^ meta.function.type-declaration.haskell - countTheBeforeVowel = undefined + {- Class Method Declarations -} + class TyCls a where + nethod1 :: a -> Bool +-- ^^^^^^^^ meta.function.identifier.haskell +-- ^^^^^^^ entity.name.function.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^ variable.other.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^^^^ support.type.prelude.haskell + method' :: +-- ^^^^^^^^ meta.function.identifier.haskell +-- ^^^^^^^ entity.name.function.haskell + a -> Bool +-- ^ variable.other.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^^^^ support.type.prelude.haskell + + {- Class Method Declarations with Block Layout -} + class TyCls a where { + method :: Bool -> Bool; +-- ^^^^^^^ meta.block.haskell meta.function.identifier.haskell +-- ^^^^^^^^^^^^^^^^^ meta.block.haskell - meta.function +-- ^^^^^^ entity.name.function.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^^^^ support.type.prelude.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^^^^ support.type.prelude.haskell +-- ^ punctuation.terminator.statement.haskell + method = True; +-- ^^^^^^^^^^^^^^^ meta.block.haskell +-- ^^^^^^ variable.other.haskell +-- ^ keyword.operator.haskell +-- ^^^^ support.constant.prelude.haskell +-- ^ punctuation.terminator.statement.haskell + + {- preceeded by statement terminator -} + ;method :: Bool -> Bool; +-- ^ meta.block.haskell - meta.function +-- ^^^^^^^ meta.block.haskell meta.function.identifier.haskell +-- ^^^^^^^^^^^^^^^^^ meta.block.haskell - meta.function +-- ^ punctuation.terminator.statement.haskell +-- ^^^^^^ entity.name.function.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^^^^ support.type.prelude.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^^^^ support.type.prelude.haskell +-- ^ punctuation.terminator.statement.haskell + } -- [ KEYWORDS ] --------------------------------------------------------------- From c2db0460a898dee9fb8e09220bc2d96f92e0b5ab Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 30 Dec 2020 09:50:39 +0100 Subject: [PATCH 098/178] [Haskell] Tweak type-content --- Haskell/Haskell.sublime-syntax | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index bf416cb69d..6d35c2fddd 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -526,10 +526,10 @@ contexts: class-signature: - meta_content_scope: meta.declaration.class.signature.haskell - - include: type-content - match: where{{break}} scope: keyword.control.context.haskell set: class-block + - include: type-content - include: else-pop class-block: @@ -699,7 +699,6 @@ contexts: pop: 1 - match: =(?!>) scope: keyword.operator.haskell - - include: big-arrow-operators - include: type-content - include: else-pop @@ -716,7 +715,6 @@ contexts: pop: 1 - match: =(?!>) scope: keyword.operator.haskell - - include: big-arrow-operators - include: type-content - include: else-pop @@ -732,17 +730,18 @@ contexts: type-signature-body: # 4.1.2 Syntax of Types # https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-750004.3 - - match: ^(?!\s*(?:--|{-|$)) + - meta_scope: meta.type.haskell + - match: ^(?!\s*(?:--|{-|$|{{symbol}})) pop: 1 - - include: big-arrow-operators - include: type-content - include: else-pop type-content: + - include: big-arrow-operators + - include: right-arrow-operators - include: type-forall - include: type-lists - include: type-tuples - - include: right-arrow-operators - include: ident-anonymous - include: ident-namespaces - include: ident-types From 283455595bf89a37ff87aeb3a7a7351ac05433fa Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 30 Dec 2020 12:25:58 +0100 Subject: [PATCH 099/178] [Haskell] Add extra bailouts to lists,groups,tuples --- Haskell/Haskell.sublime-syntax | 5 ++++- Haskell/syntax_test_haskell.hs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 6d35c2fddd..fee9c0ddc4 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -840,6 +840,7 @@ contexts: - include: list-end - include: records - include: expressions + - include: else-pop groups-or-tuples: # 3.8 Tuples @@ -874,6 +875,7 @@ contexts: - include: group-end - include: records - include: expressions + - include: else-pop tuple: - match: \( @@ -890,6 +892,7 @@ contexts: - include: tuple-end - include: records - include: expressions + - include: else-pop range-tuples: - match: (\()(\.\.)(\)) @@ -1046,7 +1049,7 @@ contexts: - include: left-arrow-operators - include: right-arrow-operators - include: infix-parens-operators - - match: (`)[ \w'.]+(`) + - match: (`)[ \w'.]*(`) scope: keyword.operator.function.infix.haskell captures: 1: punctuation.definition.function.begin.haskell diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 149a190c29..2de8e452a0 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -2138,7 +2138,7 @@ main = do -- ^ keyword.operator.haskell -- ^^ - keyword -- ^ keyword.operator.haskell --- ^^ - keyword +-- ^^ keyword.operator.function.infix.haskell -- ^ punctuation.section.sequence.end.haskell (group) From 1fe1677688f7998ea11886db8b9d4a3f3c9da234 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 30 Dec 2020 13:05:27 +0100 Subject: [PATCH 100/178] [Haskell] Simplify class declarations It is no longer needed to distinguish context and signature. --- Haskell/Haskell.sublime-syntax | 68 ++++++-------------------- Haskell/syntax_test_haskell.hs | 88 +++++++++++----------------------- 2 files changed, 42 insertions(+), 114 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index fee9c0ddc4..9a58bb1956 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -196,7 +196,6 @@ contexts: - include: datas - include: foreigns - include: imports - - include: instances - include: newtypes - include: types - include: functions @@ -485,47 +484,22 @@ contexts: scope: meta.declaration.class.haskell keyword.declaration.class.haskell - branch_point: classes - branch: - - class-context - - class-signature - - class-else-fail: - - match: (?=\S) - fail: classes - - class-context: - # The context specifies the superclasses - - meta_content_scope: meta.declaration.class.context.haskell - - match: '{{operator_big_arrow}}' - scope: - meta.declaration.class.haskell - keyword.operator.big-arrow.haskell - set: class-signature - - include: class-context-decls - - include: class-else-fail - - class-context-decls: - - include: class-context-tuples - - include: ident-anonymous - - include: ident-namespaces - - include: ident-types - - include: ident-variables + push: class-body + # 4.3.2 Instance Declarations + # https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-750004.3 + - match: instance{{break}} + scope: keyword.declaration.instance.haskell + push: instance-body - class-context-tuples: - - match: \( - scope: punctuation.section.sequence.begin.haskell - push: class-context-tuple-body + class-body: + - meta_content_scope: meta.declaration.class.haskell + - include: class-type - class-context-tuple-body: - - meta_scope: meta.sequence.tuple.haskell - - include: tuple-end - - include: sequence-separators - - include: class-context-decls - - include: else-pop + instance-body: + - meta_scope: meta.declaration.instance.haskell + - include: class-type - class-signature: - - meta_content_scope: meta.declaration.class.signature.haskell + class-type: - match: where{{break}} scope: keyword.control.context.haskell set: class-block @@ -536,8 +510,7 @@ contexts: - match: \{ scope: punctuation.section.block.begin.haskell set: class-block-body - - match: ^(?!\s*(?:--|{-?|$)) - pop: 1 + - include: else-pop class-block-body: - meta_scope: meta.block.haskell @@ -628,19 +601,6 @@ contexts: - include: ident-inherited-classes - include: else-pop -###[ INSTANCE DECLARATIONS ]################################################### - - instances: - # 4.3.2 Instance Declarations - # https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-750004.3 - - match: instance{{break}} - scope: keyword.declaration.instance.haskell - push: instance-body - - instance-body: - - meta_scope: meta.declaration.instance.haskell - - include: type-signature-body - ###[ FUNCTION DECLARATIONS ]################################################### functions: diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 2de8e452a0..0ea192c32a 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -819,27 +819,22 @@ -- ^^^^^^ - keyword class --- ^^^^^ meta.declaration.class.haskell --- ^ meta.declaration.class.signature.haskell +-- ^^^^^^ meta.declaration.class.haskell -- ^^^^^ keyword.declaration.class.haskell class => --- ^^^^^ meta.declaration.class.haskell --- ^ meta.declaration.class.context.haskell --- ^^ meta.declaration.class.haskell +-- ^^^^^^^^^ meta.declaration.class.haskell -- ^^^^^ keyword.declaration.class.haskell -- ^^ keyword.operator.big-arrow.haskell class QTyCls tyVar --- ^^^^^ meta.declaration.class.haskell --- ^^^^^^^^^^^^^^ meta.declaration.class.signature.haskell +-- ^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell -- ^^^^^ keyword.declaration.class.haskell -- ^^^^^^ storage.type.haskell -- ^^^^^ variable.other.haskell class ModId.QTyCls tyVar1 tyVar2, ident --- ^^^^^ meta.declaration.class.haskell --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.signature.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell -- ^^^^^^^ - meta.declaration -- ^^^^^ keyword.declaration.class.haskell -- ^^^^^ variable.namespace.haskell @@ -851,10 +846,7 @@ -- ^^^^^ variable.other.haskell class ModId.QTyCls tyVar1 tyVar2 => --- ^^^^^ meta.declaration.class.haskell --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.context.haskell --- ^^ meta.declaration.class.haskell --- ^ meta.declaration.class.signature.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell -- ^^^^^ keyword.declaration.class.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell @@ -864,12 +856,9 @@ -- ^^ keyword.operator.big-arrow.haskell class ModId.QTyCls (tyVar1 tyVar2) => --- ^^^^^ meta.declaration.class.haskell --- ^^^^^^^^^^^^^^ meta.declaration.class.context.haskell --- ^^^^^^^^^^^^^^^ meta.declaration.class.context.haskell meta.sequence.tuple.haskell --- ^ meta.declaration.class.context.haskell - meta.sequence --- ^^ meta.declaration.class.haskell --- ^ meta.declaration.class.signature.haskell +-- ^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^ meta.declaration.class.haskell meta.sequence.tuple.haskell +-- ^^^^ meta.declaration.class.haskell - meta.sequence -- ^^^^^ keyword.declaration.class.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell @@ -880,12 +869,9 @@ -- ^ punctuation.section.sequence.end.haskell -- ^^ keyword.operator.big-arrow.haskell - class ModId.QTyCls (tyVar1 tyVar2 => --- ^^^^^ meta.declaration.class.haskell --- ^^^^^^^^^^^^^^ meta.declaration.class.context.haskell --- ^^^^^^^^^^^^^^^^ meta.declaration.class.context.haskell meta.sequence.tuple.haskell --- ^^ meta.declaration.class.haskell --- ^ meta.declaration.class.signature.haskell + class ModId.QTyCls (tyVar1 tyVar2 => ) +-- ^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell meta.sequence.tuple.haskell -- ^^^^^ keyword.declaration.class.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell @@ -894,12 +880,10 @@ -- ^^^^^^ variable.other.haskell -- ^^^^^^ variable.other.haskell -- ^^ keyword.operator.big-arrow.haskell +-- ^ punctuation.section.sequence.end.haskell class ModId.QTyCls tyVar1 tyVar2 => Traversable t --- ^^^^^ meta.declaration.class.haskell --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.context.haskell --- ^^ meta.declaration.class.haskell --- ^^^^^^^^^^^^^^^ meta.declaration.class.signature.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell -- ^^^^^ keyword.declaration.class.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell @@ -911,11 +895,7 @@ -- ^ variable.other.haskell class () => --- ^^^^^ meta.declaration.class.haskell --- ^ meta.declaration.class.context.haskell - meta.sequence --- ^^ meta.declaration.class.context.haskell meta.sequence.tuple.haskell --- ^ meta.declaration.class.context.haskell - meta.sequence --- ^^ meta.declaration.class.haskell +-- ^^^^^^^^^^^^ meta.declaration.class.haskell -- ^^^^^ keyword.declaration.class.haskell -- ^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell @@ -923,12 +903,9 @@ -- ^^ keyword.operator.big-arrow.haskell class (Functor t, Foldable t) => Traversable t where --- ^^^^^ meta.declaration.class.haskell --- ^ meta.declaration.class.context.haskell - meta.sequence --- ^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.context.haskell meta.sequence.tuple.haskell --- ^ meta.declaration.class.context.haskell - meta.sequence --- ^^ meta.declaration.class.haskell --- ^^^^^^^^^^^^^^^ meta.declaration.class.signature.haskell +-- ^^^^^^ meta.declaration.class.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell meta.sequence.tuple.haskell +-- ^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell - meta.sequence -- ^^^^^ keyword.declaration.class.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^^^^^ support.class.prelude.haskell @@ -947,10 +924,7 @@ -- methods in the original ones. class Eq a => a -> a --- ^^^^^ meta.declaration.class.haskell --- ^^^^^^ meta.declaration.class.context.haskell --- ^^ meta.declaration.class.haskell --- ^^^^^^^^ meta.declaration.class.signature.haskell +-- ^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell -- ^^^^^ keyword.declaration.class.haskell -- ^^ support.class.prelude.haskell -- ^ variable.other.haskell @@ -960,12 +934,9 @@ -- ^ variable.other.haskell class (Eq a, Show a, Eq b) => [a] -> [b] -> String --- ^^^^^ meta.declaration.class.haskell --- ^ meta.declaration.class.context.haskell - meta.sequence --- ^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.context.haskell meta.sequence.tuple.haskell --- ^ meta.declaration.class.context.haskell - meta.sequence --- ^^ meta.declaration.class.haskell --- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.signature.haskell +-- ^^^^^^ meta.declaration.class.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell meta.sequence.tuple.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell -- ^^^^^ keyword.declaration.class.haskell -- ^^ support.class.prelude.haskell -- ^ variable.other.haskell @@ -977,16 +948,13 @@ -- ^^^^^^ support.type.prelude.haskell class (Eq (f a), Functor f) => (a -> b) -> f a -> f b -> Bool --- ^^^^^ meta.declaration.class.haskell --- ^ meta.declaration.class.context.haskell - meta.sequence --- ^^^^ meta.declaration.class.context.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence --- ^^^^^ meta.declaration.class.context.haskell meta.sequence.tuple.haskell meta.sequence.tuple.haskell --- ^^^^^^^^^^^^ meta.declaration.class.context.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence --- ^ meta.declaration.class.context.haskell - meta.sequence --- ^^ meta.declaration.class.haskell --- ^ meta.declaration.class.signature.haskell - meta.group --- ^^^^^^^^ meta.declaration.class.signature.haskell meta.sequence.tuple.haskell --- ^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.signature.haskell - meta.group +-- ^^^^^^ meta.declaration.class.haskell - meta.sequence +-- ^^^^ meta.declaration.class.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence +-- ^^^^^ meta.declaration.class.haskell meta.sequence.tuple.haskell meta.sequence.tuple.haskell +-- ^^^^^^^^^^^^ meta.declaration.class.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence +-- ^^^^ meta.declaration.class.haskell - meta.sequence +-- ^^^^^^^^ meta.declaration.class.haskell meta.sequence.tuple.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell - meta.group -- ^^^^^ keyword.declaration.class.haskell -- ^^ support.class.prelude.haskell -- ^ punctuation.section.sequence.begin.haskell From 8a2e904759cf539e5d594c530701b9fce16027e7 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 30 Dec 2020 13:17:55 +0100 Subject: [PATCH 101/178] [Haskell] Simplify data declarations --- Haskell/Haskell.sublime-syntax | 20 +------------------- Haskell/syntax_test_haskell.hs | 6 +++--- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 9a58bb1956..bc65c11599 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -532,19 +532,10 @@ contexts: data-body: - meta_content_scope: meta.declaration.data.haskell - - match: = - scope: keyword.operator.haskell - set: data-constructor # https://wiki.haskell.org/GHC/Type_families - match: (?:family|instance){{break}} scope: storage.modifier.family.haskell - - include: type-signature-body - - data-constructor: - - include: constructor-operators - - include: constructor-separators - - include: records - - include: ident-types + - include: type-content - include: else-pop ###[ DEFAULT DECLARATIONS ]#################################################### @@ -1035,15 +1026,6 @@ contexts: - match: '{{operator_right_arrow}}' scope: keyword.operator.arrow.haskell - constructor-operators: - - match: (`)\s*{{con_id}}\s*(`) - scope: keyword.operator.function.infix.haskell - captures: - 1: punctuation.definition.function.begin.haskell - 2: punctuation.definition.function.end.haskell - - match: '{{consym}}|!' - scope: keyword.operator.haskell - constructor-separators: - match: \|(?!\|) scope: punctuation.separator.sequence.haskell diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 0ea192c32a..6d9fffc27f 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -1056,8 +1056,8 @@ -- ^^^^^^ storage.type.haskell -- ^ keyword.operator.haskell Record { --- ^^^^^^^ - meta.record --- ^^ meta.record.haskell meta.block.haskell +-- ^^^^^^^ - meta.block +-- ^^ meta.block.haskell -- ^^^^^^ storage.type.haskell -- ^ punctuation.section.block.begin.haskell recordInt :: Int @@ -1080,7 +1080,7 @@ -- ^^ keyword.operator.double-colon.haskell -- ^^^^^^^^ support.class.prelude.haskell } deriving (Eq, Ord, Generic) --- ^^ meta.record.haskell meta.block.haskell +-- ^^ meta.block.haskell -- ^ - meta -- ^^^^^^^^^ meta.declaration.deriving.haskell - meta.sequence -- ^^^^^^^^^^^^^^^^^^ meta.declaration.deriving.haskell meta.sequence.tuple.haskell From 9547e81d19cbc5527d5b6cdc51dd30a75747e918 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 30 Dec 2020 13:27:56 +0100 Subject: [PATCH 102/178] [Haskell] Simplify derived() and via() statements Replace `entity.name.inerhited-class` by `storage.type` as those tokens may be present at other places, too. The `entity.` scope is of no use in this syntax definition, while scoping all data types the same way makes it easier to maintain consistent highlighting in hashed color schemes. --- Haskell/Haskell.sublime-syntax | 19 +++++++------------ Haskell/syntax_test_haskell.hs | 22 +++++++++++----------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index bc65c11599..d83bdc113f 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -581,7 +581,7 @@ contexts: scope: punctuation.section.sequence.begin.haskell set: deriving-tuple-body - include: ident-namespaces - - include: ident-inherited-class + - include: ident-type - include: else-pop deriving-tuple-body: @@ -589,7 +589,7 @@ contexts: - include: tuple-end - include: sequence-separators - include: ident-namespaces - - include: ident-inherited-classes + - include: ident-types - include: else-pop ###[ FUNCTION DECLARATIONS ]################################################### @@ -886,27 +886,22 @@ contexts: - match: '{{con_id}}' scope: entity.name.namespace.haskell - ident-inherited-classes: + ident-types: - include: ident-builtin-classes + - include: ident-builtin-types - match: '{{con_id}}' - scope: entity.other.inherited-class.haskell + scope: storage.type.haskell - ident-inherited-class: + ident-type: - match: '{{builtin_classes}}' scope: support.class.prelude.haskell pop: 1 - match: '{{builtin_types}}' scope: support.type.prelude.haskell pop: 1 - - match: '{{con_id}}' - scope: entity.other.inherited-class.haskell - pop: 1 - - ident-types: - - include: ident-builtin-classes - - include: ident-builtin-types - match: '{{con_id}}' scope: storage.type.haskell + pop: 1 ident-functions: - include: ident-builtin-functions diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 6d9fffc27f..260f9269aa 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -1091,7 +1091,7 @@ -- ^ punctuation.separator.sequence.haskell -- ^^^ support.class.prelude.haskell -- ^ punctuation.separator.sequence.haskell --- ^^^^^^^ entity.other.inherited-class.haskell +-- ^^^^^^^ storage.type.haskell -- ^ punctuation.section.sequence.end.haskell deriving (Read, Show) via (Quiet Record) -- ^^^^^^^^^ meta.declaration.deriving.haskell - meta.sequence @@ -1108,9 +1108,9 @@ -- ^ punctuation.section.sequence.end.haskell -- ^^^ storage.modifier.haskell -- ^ punctuation.section.sequence.begin.haskell --- ^^^^^ entity.other.inherited-class.haskell +-- ^^^^^ storage.type.haskell -- ^ - entity --- ^^^^^^ entity.other.inherited-class.haskell +-- ^^^^^^ storage.type.haskell -- ^ punctuation.section.sequence.end.haskell data Outrageous = @@ -1254,7 +1254,7 @@ -- ^^^^^^^^^^^^^^ meta.declaration.deriving.haskell -- ^^^^^^ - meta.declaration -- ^^^^^^^^ storage.modifier.haskell --- ^^^^^ entity.other.inherited-class.haskell +-- ^^^^^ storage.type.haskell -- ^^^^^ storage.type.haskell deriving ModId.QTyCls ModId.Const @@ -1263,7 +1263,7 @@ -- ^^^^^^^^ storage.modifier.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ entity.other.inherited-class.haskell +-- ^^^^^^ storage.type.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^ storage.type.haskell @@ -1282,11 +1282,11 @@ -- ^ - meta.declaration -- ^^^^^^^^ storage.modifier.haskell -- ^ punctuation.section.sequence.begin.haskell --- ^^^^^ entity.other.inherited-class.haskell +-- ^^^^^ storage.type.haskell -- ^ punctuation.separator.sequence.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ entity.other.inherited-class.haskell +-- ^^^^^^ storage.type.haskell -- ^ punctuation.section.sequence.end.haskell @@ -1557,9 +1557,9 @@ -- ^^^^^^ variable.other.haskell -- ^^^^^^^^ storage.modifier.haskell -- ^ punctuation.section.sequence.begin.haskell --- ^^^^^^ entity.other.inherited-class.haskell +-- ^^^^^^ storage.type.haskell -- ^ punctuation.separator.sequence.haskell --- ^^^^^^^ entity.other.inherited-class.haskell +-- ^^^^^^^ storage.type.haskell -- ^ punctuation.section.sequence.end.haskell @@ -1613,9 +1613,9 @@ -- ^^^^^^ variable.other.haskell -- ^^^^^^^^ storage.modifier.haskell -- ^ punctuation.section.sequence.begin.haskell --- ^^^^^^ entity.other.inherited-class.haskell +-- ^^^^^^ storage.type.haskell -- ^ punctuation.separator.sequence.haskell --- ^^^^^^^ entity.other.inherited-class.haskell +-- ^^^^^^^ storage.type.haskell -- ^ punctuation.section.sequence.end.haskell type Id a = a From 11bb4a3884b65bb616fb44a5a1fed6cb06a94ddb Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 30 Dec 2020 13:35:37 +0100 Subject: [PATCH 103/178] [Haskell] Reorganize records contexts --- Haskell/Haskell.sublime-syntax | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index d83bdc113f..0e5f93e876 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -740,20 +740,7 @@ contexts: - include: type-content - include: else-pop -###[ RECORD CONSTRUCTORS ]##################################################### - - records: - - match: \{ - scope: punctuation.section.block.begin.haskell - push: record-body - - record-body: - - meta_scope: meta.record.haskell meta.block.haskell - - include: block-end - - include: expressions - - include: else-pop - -###[ BLOCKS / GROUPS / LISTS / TUPLES ]######################################## +###[ BLOCKS / RECORDS / GROUPS / LISTS / TUPLES ]############################## blocks: # 2.7 Layout @@ -774,6 +761,17 @@ contexts: - include: expressions - include: else-pop + records: + - match: \{ + scope: punctuation.section.block.begin.haskell + push: record-body + + record-body: + - meta_scope: meta.block.haskell + - include: block-end + - include: expressions + - include: else-pop + lists: # 3.7 Lists # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-340003.7 From 0ee5f67c812203ba78f649f96b0f1ad74509727b Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 30 Dec 2020 13:56:49 +0100 Subject: [PATCH 104/178] [Haskell] Simplify type declarations --- Haskell/Haskell.sublime-syntax | 19 +------------------ Haskell/syntax_test_haskell.hs | 34 +++++++++++++++++----------------- 2 files changed, 18 insertions(+), 35 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 0e5f93e876..a1151d3880 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -646,10 +646,6 @@ contexts: newtype-body: - meta_scope: meta.declaration.newtype.haskell - - match: ^(?!\s*(?:--|{-|$)) - pop: 1 - - match: =(?!>) - scope: keyword.operator.haskell - include: type-content - include: else-pop @@ -662,10 +658,6 @@ contexts: type-body: - meta_scope: meta.declaration.type.haskell - - match: ^(?!\s*(?:--|{-|$)) - pop: 1 - - match: =(?!>) - scope: keyword.operator.haskell - include: type-content - include: else-pop @@ -676,16 +668,7 @@ contexts: # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html - match: '{{operator_double_colon}}' scope: keyword.operator.double-colon.haskell - push: type-signature-body - - type-signature-body: - # 4.1.2 Syntax of Types - # https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-750004.3 - - meta_scope: meta.type.haskell - - match: ^(?!\s*(?:--|{-|$|{{symbol}})) - pop: 1 - - include: type-content - - include: else-pop + - include: type-forall type-content: - include: big-arrow-operators diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 260f9269aa..8371b56f64 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -1592,7 +1592,7 @@ -- ^^^^^^ variable.other.haskell type ModId.QTyCls tyVar1 tyVar2 = --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell -- ^^^^ keyword.declaration.type.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell @@ -1619,24 +1619,24 @@ -- ^ punctuation.section.sequence.end.haskell type Id a = a --- ^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^^^^^^^ meta.declaration.type.haskell -- ^ keyword.operator.haskell -- ^ variable.other.haskell type Const a b = a --- ^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^^^^^^^^^^^^ meta.declaration.type.haskell -- ^ keyword.operator.haskell -- ^ variable.other.haskell type FunctionTo a b = b -> a --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell -- ^ keyword.operator.haskell -- ^ variable.other.haskell -- ^^ keyword.operator.arrow.haskell -- ^ variable.other.haskell type Indexed f g = forall i. f i -> g i --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell -- ^ keyword.operator.haskell -- ^^^^^^ keyword.control.forall.haskell -- ^ variable.other.haskell @@ -1648,16 +1648,16 @@ -- ^ variable.other.haskell type ShowIndexed f g = forall i. (Show i) => f i -> g i --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell -- ^ keyword.operator.haskell -- ^^^^^^ keyword.control.forall.haskell -- ^ variable.other.haskell -- ^ keyword.operator.haskell --- ^^^^^^^^ meta.sequence.tuple.haskell --- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^^^^ meta.group.haskell +-- ^ punctuation.section.group.begin.haskell -- ^^^^ support.class.prelude.haskell -- ^ variable.other.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^ punctuation.section.group.end.haskell -- ^^ keyword.operator.big-arrow.haskell -- ^ variable.other.haskell -- ^ variable.other.haskell @@ -1666,13 +1666,13 @@ -- ^ variable.other.haskell type ShowConstrained f a = (Show a) => f a --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell -- ^ keyword.operator.haskell --- ^^^^^^^^ meta.sequence.tuple.haskell --- ^ punctuation.section.sequence.begin.haskell +-- ^^^^^^^^ meta.group.haskell +-- ^ punctuation.section.group.begin.haskell -- ^^^^ support.class.prelude.haskell -- ^ variable.other.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^ punctuation.section.group.end.haskell -- ^^ keyword.operator.big-arrow.haskell -- ^ variable.other.haskell -- ^ variable.other.haskell @@ -1754,16 +1754,16 @@ -- ^ variable.other.haskell -- ^ keyword.operator.big-arrow.haskell -- ^ variable.other.haskell --- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.group.begin.haskell -- ^ variable.other.haskell -- ^ variable.other.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^ punctuation.section.group.end.haskell -- ^ keyword.operator.arrow.haskell -- ^ variable.other.haskell --- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.group.begin.haskell -- ^ variable.other.haskell -- ^ variable.other.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^ punctuation.section.group.end.haskell {- function body -} sequenceA = traverse id -- ^^^^^^^^^ support.function.prelude.haskell From 6c452ecc23f25b56af5123f7637182ec5d66dc58 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 30 Dec 2020 13:59:01 +0100 Subject: [PATCH 105/178] [Haskell] Add tests to verify instance methods --- Haskell/syntax_test_haskell.hs | 49 ++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 8371b56f64..684d64b77d 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -1875,6 +1875,55 @@ -- ^ punctuation.terminator.statement.haskell } + {- Instance Method Declarations -} + instance TyCls a where + nethod1 :: a -> Bool +-- ^^^^^^^^ meta.function.identifier.haskell +-- ^^^^^^^ entity.name.function.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^ variable.other.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^^^^ support.type.prelude.haskell + method' :: +-- ^^^^^^^^ meta.function.identifier.haskell +-- ^^^^^^^ entity.name.function.haskell + a -> Bool +-- ^ variable.other.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^^^^ support.type.prelude.haskell + + {- Instance Method Declarations with Block Layout -} + instance TyCls a where { + method :: Bool -> Bool; +-- ^^^^^^^ meta.block.haskell meta.function.identifier.haskell +-- ^^^^^^^^^^^^^^^^^ meta.block.haskell - meta.function +-- ^^^^^^ entity.name.function.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^^^^ support.type.prelude.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^^^^ support.type.prelude.haskell +-- ^ punctuation.terminator.statement.haskell + method = True; +-- ^^^^^^^^^^^^^^^ meta.block.haskell +-- ^^^^^^ variable.other.haskell +-- ^ keyword.operator.haskell +-- ^^^^ support.constant.prelude.haskell +-- ^ punctuation.terminator.statement.haskell + + {- preceeded by statement terminator -} + ;method :: Bool -> Bool; +-- ^ meta.block.haskell - meta.function +-- ^^^^^^^ meta.block.haskell meta.function.identifier.haskell +-- ^^^^^^^^^^^^^^^^^ meta.block.haskell - meta.function +-- ^ punctuation.terminator.statement.haskell +-- ^^^^^^ entity.name.function.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^^^^ support.type.prelude.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^^^^ support.type.prelude.haskell +-- ^ punctuation.terminator.statement.haskell + } + -- [ KEYWORDS ] --------------------------------------------------------------- From b336cfb8986dcc6b1e57b9a56a5f3274b7e730da Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 30 Dec 2020 14:13:07 +0100 Subject: [PATCH 106/178] [Haskell] Distinguish type groups and type tuples This commit intends to create consistent group vs. tuple highlighting in both, normal and type expressions. --- Haskell/Haskell.sublime-syntax | 56 ++++++++++----- Haskell/syntax_test_haskell.hs | 121 +++++++++++++++++---------------- 2 files changed, 102 insertions(+), 75 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index a1151d3880..2320e736ce 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -213,7 +213,7 @@ contexts: - include: type-signatures - include: operators - include: splice - - include: groups-or-tuples + - include: parens - include: lists - include: keywords - include: ident-anonymous @@ -673,9 +673,9 @@ contexts: type-content: - include: big-arrow-operators - include: right-arrow-operators - - include: type-forall - include: type-lists - - include: type-tuples + - include: type-parens + - include: type-forall - include: ident-anonymous - include: ident-namespaces - include: ident-types @@ -709,12 +709,33 @@ contexts: - include: type-content - include: else-pop - type-tuples: + type-parens: # 4.1.3 Syntax of Class Assertions and Contexts # https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-630004.1 + - include: empty-tuples + - match: (?=\() + branch_point: type-parens + branch: + - type-group + - type-tuple + + type-group: + - match: \( + scope: punctuation.section.group.begin.haskell + set: type-group-body + + type-group-body: + - meta_scope: meta.group.haskell + - match: ',|:(?!{{symbol}})' + fail: type-parens + - include: group-end + - include: type-content + - include: else-pop + + type-tuple: - match: \( scope: punctuation.section.sequence.begin.haskell - push: type-tuple-body + set: type-tuple-body type-tuple-body: - meta_scope: meta.sequence.tuple.haskell @@ -774,18 +795,12 @@ contexts: - include: expressions - include: else-pop - groups-or-tuples: + parens: # 3.8 Tuples # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-360003.8 - # 3.9 Unit Expressions and Parenthesized Expressions - # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-380003.9 - - match: (\()\s*(\)) - scope: meta.sequence.tuple.haskell - captures: - 1: punctuation.section.sequence.begin.haskell - 2: punctuation.section.sequence.end.haskell + - include: empty-tuples - match: (?=\() - branch_point: groups-or-tuples + branch_point: parens branch: - group - tuple @@ -803,7 +818,7 @@ contexts: group-body: - meta_scope: meta.group.haskell - match: ',|:(?!{{symbol}})' - fail: groups-or-tuples + fail: parens - include: group-end - include: records - include: expressions @@ -826,8 +841,17 @@ contexts: - include: expressions - include: else-pop + empty-tuples: + # 3.9 Unit Expressions and Parenthesized Expressions + # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-380003.9 + - match: (\()\s*(\)) + scope: meta.sequence.tuple.haskell + captures: + 1: punctuation.section.sequence.begin.haskell + 2: punctuation.section.sequence.end.haskell + range-tuples: - - match: (\()(\.\.)(\)) + - match: (\()\s*(\.\.)\s*(\)) scope: meta.sequence.tuple.haskell captures: 1: punctuation.section.sequence.begin.haskell diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 684d64b77d..7085be3b2f 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -856,31 +856,31 @@ -- ^^ keyword.operator.big-arrow.haskell class ModId.QTyCls (tyVar1 tyVar2) => --- ^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell - meta.sequence --- ^^^^^^^^^^^^^^^ meta.declaration.class.haskell meta.sequence.tuple.haskell --- ^^^^ meta.declaration.class.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell - meta.group +-- ^^^^^^^^^^^^^^^ meta.declaration.class.haskell meta.group.haskell +-- ^^^^ meta.declaration.class.haskell - meta.group -- ^^^^^ keyword.declaration.class.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell --- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.group.begin.haskell -- ^^^^^^ variable.other.haskell -- ^^^^^^ variable.other.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^ punctuation.section.group.end.haskell -- ^^ keyword.operator.big-arrow.haskell class ModId.QTyCls (tyVar1 tyVar2 => ) --- ^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell - meta.sequence --- ^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell meta.sequence.tuple.haskell +-- ^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell - meta.group +-- ^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell meta.group.haskell -- ^^^^^ keyword.declaration.class.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell --- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.group.begin.haskell -- ^^^^^^ variable.other.haskell -- ^^^^^^ variable.other.haskell -- ^^ keyword.operator.big-arrow.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^ punctuation.section.group.end.haskell class ModId.QTyCls tyVar1 tyVar2 => Traversable t -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell @@ -948,29 +948,29 @@ -- ^^^^^^ support.type.prelude.haskell class (Eq (f a), Functor f) => (a -> b) -> f a -> f b -> Bool --- ^^^^^^ meta.declaration.class.haskell - meta.sequence --- ^^^^ meta.declaration.class.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence --- ^^^^^ meta.declaration.class.haskell meta.sequence.tuple.haskell meta.sequence.tuple.haskell --- ^^^^^^^^^^^^ meta.declaration.class.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence --- ^^^^ meta.declaration.class.haskell - meta.sequence --- ^^^^^^^^ meta.declaration.class.haskell meta.sequence.tuple.haskell +-- ^^^^^^ meta.declaration.class.haskell - meta.sequence - meta.group +-- ^^^^ meta.declaration.class.haskell meta.sequence.tuple.haskell - meta.sequence meta.group +-- ^^^^^ meta.declaration.class.haskell meta.sequence.tuple.haskell meta.group.haskell +-- ^^^^^^^^^^^^ meta.declaration.class.haskell meta.sequence.tuple.haskell - meta.sequence meta.group +-- ^^^^ meta.declaration.class.haskell - meta.sequence - meta.group +-- ^^^^^^^^ meta.declaration.class.haskell meta.group.haskell -- ^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell - meta.group -- ^^^^^ keyword.declaration.class.haskell -- ^^ support.class.prelude.haskell --- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.group.begin.haskell -- ^ variable.other.haskell -- ^ variable.other.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^ punctuation.section.group.end.haskell -- ^ punctuation.separator.sequence.haskell -- ^^^^^^^ support.class.prelude.haskell -- ^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell -- ^^ keyword.operator.big-arrow.haskell --- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.group.begin.haskell -- ^ variable.other.haskell -- ^^ keyword.operator.arrow.haskell -- ^ variable.other.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^ punctuation.section.group.end.haskell -- ^^ keyword.operator.arrow.haskell -- ^ variable.other.haskell -- ^ variable.other.haskell @@ -1297,7 +1297,7 @@ -- ^^^^^^^^ keyword.declaration.instance.haskell instance ModId.QTyCls --- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell @@ -1338,16 +1338,16 @@ -- ^ punctuation.section.sequence.end.haskell instance ModId.QTyCls (->) --- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence --- ^^^^ meta.declaration.instance.haskell meta.sequence.tuple.haskell --- ^ meta.declaration.instance.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.group +-- ^^^^ meta.declaration.instance.haskell meta.group.haskell +-- ^ meta.declaration.instance.haskell - meta.group -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell --- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.group.begin.haskell -- ^^ keyword.operator.arrow.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^ punctuation.section.group.end.haskell instance ModId.QTyCls a -- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell @@ -1384,84 +1384,87 @@ -- ^ punctuation.section.sequence.end.haskell instance ModId.QTyCls (a -> b) --- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence --- ^^^^^^^^ meta.declaration.instance.haskell meta.sequence.tuple.haskell --- ^ meta.declaration.instance.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.group +-- ^^^^^^^^ meta.declaration.instance.haskell meta.group.haskell +-- ^ meta.declaration.instance.haskell - meta.group -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell --- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.group.begin.haskell -- ^ variable.other.haskell -- ^^ keyword.operator.arrow.haskell -- ^ variable.other.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^ punctuation.section.group.end.haskell instance ModId.QTyCls ([] a b) --- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence --- ^ meta.declaration.instance.haskell meta.sequence.tuple.haskell --- ^^ meta.declaration.instance.haskell meta.sequence.tuple.haskell meta.sequence.list.haskell --- ^^^^^ meta.declaration.instance.haskell meta.sequence.tuple.haskell --- ^ meta.declaration.instance.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.group +-- ^ meta.declaration.instance.haskell meta.group.haskell +-- ^^ meta.declaration.instance.haskell meta.group.haskell meta.sequence.list.haskell +-- ^^^^^ meta.declaration.instance.haskell meta.group.haskell +-- ^ meta.declaration.instance.haskell - meta.group -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell --- ^^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^ punctuation.section.sequence.begin.haskell -- ^ punctuation.section.sequence.end.haskell -- ^ variable.other.haskell -- ^ variable.other.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^ punctuation.section.group.end.haskell instance ModId.QTyCls (() a b) --- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence --- ^ meta.declaration.instance.haskell meta.sequence.tuple.haskell --- ^^ meta.declaration.instance.haskell meta.sequence.tuple.haskell meta.sequence.tuple.haskell --- ^^^^^ meta.declaration.instance.haskell meta.sequence.tuple.haskell --- ^ meta.declaration.instance.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.group +-- ^ meta.declaration.instance.haskell meta.group.haskell +-- ^^ meta.declaration.instance.haskell meta.group.haskell meta.sequence.tuple.haskell +-- ^^^^^ meta.declaration.instance.haskell meta.group.haskell +-- ^ meta.declaration.instance.haskell - meta.group -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell --- ^^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^ punctuation.section.sequence.begin.haskell -- ^ punctuation.section.sequence.end.haskell -- ^ variable.other.haskell -- ^ variable.other.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^ punctuation.section.group.end.haskell instance ModId.QTyCls ((,) a b) --- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence --- ^ meta.declaration.instance.haskell meta.sequence.tuple.haskell --- ^^^ meta.declaration.instance.haskell meta.sequence.tuple.haskell meta.sequence.tuple.haskell --- ^^^^^ meta.declaration.instance.haskell meta.sequence.tuple.haskell --- ^ meta.declaration.instance.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.group +-- ^ meta.declaration.instance.haskell meta.group.haskell +-- ^^^ meta.declaration.instance.haskell meta.group.haskell meta.sequence.tuple.haskell +-- ^^^^^ meta.declaration.instance.haskell meta.group.haskell +-- ^ meta.declaration.instance.haskell - meta.group -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell --- ^^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^ punctuation.section.sequence.begin.haskell -- ^ punctuation.separator.sequence.haskell -- ^ punctuation.section.sequence.end.haskell -- ^ variable.other.haskell -- ^ variable.other.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^ punctuation.section.group.end.haskell instance ModId.QTyCls ((->) a b) --- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence --- ^ meta.declaration.instance.haskell meta.sequence.tuple.haskell --- ^^^^ meta.declaration.instance.haskell meta.sequence.tuple.haskell meta.sequence.tuple.haskell --- ^^^^^ meta.declaration.instance.haskell meta.sequence.tuple.haskell --- ^ meta.declaration.instance.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.group +-- ^ meta.declaration.instance.haskell meta.group.haskell +-- ^^^^ meta.declaration.instance.haskell meta.group.haskell meta.group.haskell +-- ^^^^^ meta.declaration.instance.haskell meta.group.haskell +-- ^ meta.declaration.instance.haskell - meta.group -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell --- ^^ punctuation.section.sequence.begin.haskell +-- ^^ punctuation.section.group.begin.haskell -- ^^ keyword.operator.arrow.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^ punctuation.section.group.end.haskell -- ^ variable.other.haskell -- ^ variable.other.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^ punctuation.section.group.end.haskell instance Num a => Bar [a] where ... -- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence From 5e5eb0a934450bffeeacd835bfb4a8148edb848e Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 30 Dec 2020 14:19:33 +0100 Subject: [PATCH 107/178] [Haskell] Simplify type signatures --- Haskell/Haskell.sublime-syntax | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 2320e736ce..66acecc7ee 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -210,7 +210,7 @@ contexts: - include: literal-chars - include: literal-strings - include: literal-numbers - - include: type-signatures + - include: type-forall - include: operators - include: splice - include: parens @@ -663,13 +663,6 @@ contexts: ###[ TYPE SIGNATURES ]######################################################### - type-signatures: - # 3 Expressions - # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html - - match: '{{operator_double_colon}}' - scope: keyword.operator.double-colon.haskell - - include: type-forall - type-content: - include: big-arrow-operators - include: right-arrow-operators @@ -1011,6 +1004,8 @@ contexts: # Note: Found in real world code but not in specs so far. - match: \' scope: keyword.operator.haskell + - match: '{{operator_double_colon}}' + scope: keyword.operator.double-colon.haskell - match: '{{operator_symbol}}' scope: keyword.operator.haskell From 0cd033537eecc2e8df0ad7bd495161c779a49eba Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 30 Dec 2020 15:15:29 +0100 Subject: [PATCH 108/178] [Haskell] Fix infix declarations `infix` is a declaration keyword, but no operator. --- Haskell/Haskell.sublime-syntax | 5 +++-- Haskell/syntax_test_haskell.hs | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 66acecc7ee..bc4a6d51dc 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -985,6 +985,9 @@ contexts: scope: keyword.declaration.variable.haskell - match: proc{{break}} scope: keyword.declaration.function.haskell + # 4.4.2 Fixity Declarations + - match: infix[lr]?{{break}} + scope: keyword.declaration.fixity.haskell operators: - include: constructor-separators @@ -998,8 +1001,6 @@ contexts: captures: 1: punctuation.definition.function.begin.haskell 2: punctuation.definition.function.end.haskell - - match: infix[lr]?{{break}} - scope: keyword.operator.haskell # Match all not otherwise matched single quotes as promoition operator # Note: Found in real world code but not in specs so far. - match: \' diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 7085be3b2f..8e61599cbf 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -1718,6 +1718,40 @@ -- ^ meta.group.haskell punctuation.section.group.end.haskell +-- [ FIXITY DECLARATIONS ] ---------------------------------------------------- + + infix +-- ^^^^^ keyword.declaration.fixity.haskell + + infix' +-- ^^^^^^ variable.other.haskell + + infixl +-- ^^^^^^ keyword.declaration.fixity.haskell + + infixr +-- ^^^^^^ keyword.declaration.fixity.haskell + + infix 0 :$ +-- ^^^^^ keyword.declaration.fixity.haskell +-- ^ constant.numeric.value.haskell +-- ^^ keyword.operator.haskell + + infix 1 `ConId` +-- ^^^^^ keyword.declaration.fixity.haskell +-- ^ constant.numeric.value.haskell +-- ^^^^^^^ keyword.operator.function.infix.haskell + + infixl 7 ⋆, /, `quot` +-- ^^^^^^ keyword.declaration.fixity.haskell +-- ^ constant.numeric.value.haskell +-- ^ keyword.operator.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^ keyword.operator.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^ keyword.operator.function.infix.haskell + + -- [ FUNCTION DECLARATIONS ] -------------------------------------------------- {- infix operator declaration -} From 0318ada5c39c58604738b414a51bde341448f66a Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 30 Dec 2020 15:15:53 +0100 Subject: [PATCH 109/178] [Haskell] Tweak quoted infix operators --- Haskell/Haskell.sublime-syntax | 13 ++++++++----- Haskell/syntax_test_haskell.hs | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index bc4a6d51dc..a04c5b9865 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -996,11 +996,7 @@ contexts: - include: left-arrow-operators - include: right-arrow-operators - include: infix-parens-operators - - match: (`)[ \w'.]*(`) - scope: keyword.operator.function.infix.haskell - captures: - 1: punctuation.definition.function.begin.haskell - 2: punctuation.definition.function.end.haskell + - include: infix-quoted-operators # Match all not otherwise matched single quotes as promoition operator # Note: Found in real world code but not in specs so far. - match: \' @@ -1032,6 +1028,13 @@ contexts: captures: 1: keyword.operator.haskell + infix-quoted-operators: + - match: (`)[ \w'.]*(`) + scope: keyword.operator.function.infix.haskell + captures: + 1: punctuation.definition.function.begin.haskell + 2: punctuation.definition.function.end.haskell + statement-terminators: # Depending on layout, semicolon may be needed to terminate statements. # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-210002.7 diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 8e61599cbf..bc16af1c0d 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -3130,16 +3130,30 @@ main = do ) -- ^ punctuation.section.group.end.haskell + {- unqualified infix variable operator id -} a `member` x -- ^^^^^^^^ keyword.operator.function.infix.haskell -- ^ punctuation.definition.function.begin.haskell -- ^ punctuation.definition.function.end.haskell + {- qualified infix variable operator id -} a `P.atan2` x -- ^^^^^^^^^ keyword.operator.function.infix.haskell -- ^ punctuation.definition.function.begin.haskell -- ^ punctuation.definition.function.end.haskell + {- unqualified infix constructor operator id -} + a `Quux` x +-- ^^^^^^ keyword.operator.function.infix.haskell +-- ^ punctuation.definition.function.begin.haskell +-- ^ punctuation.definition.function.end.haskell + + {- qualified infix constructor operator id -} + a `Monad.Quux` x +-- ^^^^^^^^^^^^ keyword.operator.function.infix.haskell +-- ^ punctuation.definition.function.begin.haskell +-- ^ punctuation.definition.function.end.haskell + 5 `f `7`f`"3 'ab'" -- ^ constant.numeric.value.haskell -- ^^^^ keyword.operator.function.infix.haskell From c6b1962e28bda893844cd4afb108c307e8a78bd9 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 30 Dec 2020 15:52:13 +0100 Subject: [PATCH 110/178] [Haskell] Add a sophisticated group test --- Haskell/syntax_test_haskell.hs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index bc16af1c0d..f8fdd1d19a 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -2048,6 +2048,18 @@ main = do -- ^ punctuation.separator.sequence.haskell -- ^^ keyword.operator.haskell -- ^ punctuation.section.sequence.end.haskell + [ x :: a +-- ^^^^^^^^^ meta.sequence.list.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ variable.other.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^ variable.other.haskell + B c ] +-- ^^^^^^ meta.sequence.list.haskell +-- ^ - meta.sequence +-- ^ storage.type.haskell +-- ^ variable.other.haskell +-- ^ punctuation.section.sequence.end.haskell -- List comprehension @@ -2200,6 +2212,25 @@ main = do -- ^ punctuation.section.group.begin.haskell -- ^ punctuation.section.group.end.haskell + (\arg opt -> +-- ^^^^^^^^^^^^^ meta.group.haskell +-- ^ punctuation.section.group.begin.haskell + case arg of + "auto" -> return opt{ optWrap = WrapAuto } +-- ^^^^^^^^^^^^^^^^^^^^^ meta.group.haskell - meta.block +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.group.haskell meta.block.haskell + "none" -> return opt{ optWrap = WrapNone } +-- ^^^^^^^^^^^^^^^^^^^^^ meta.group.haskell - meta.block +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.group.haskell meta.block.haskell + "preserve" -> return opt{ optWrap = WrapPreserve } +-- ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.haskell - meta.block +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.haskell meta.block.haskell + _ -> E.throwIO $ PandocOptionError + "--wrap must be auto, none, or preserve") +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.haskell meta.string.haskell string.quoted.double.haskell +-- ^ meta.group.haskell punctuation.section.group.end.haskell +-- ^ - meta.group + -- [ IDENTS ] ----------------------------------------------------------------- From 7b16e70fbf2acdbcb89059cbc48679db87e6e362 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 30 Dec 2020 15:56:53 +0100 Subject: [PATCH 111/178] [Haskell] Tweak module and import statements --- Haskell/Haskell.sublime-syntax | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index a04c5b9865..de13a05ce8 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -351,11 +351,11 @@ contexts: - include: immediatelly-pop module-name: - - include: ident-namespaces - - include: ident-modules - match: \( scope: punctuation.section.sequence.begin.haskell set: module-exports-body + - include: ident-namespaces + - include: ident-modules - include: else-pop module-exports-body: @@ -408,13 +408,13 @@ contexts: - include: immediatelly-pop import-body: + - match: \( + scope: punctuation.section.sequence.begin.haskell + set: import-tuple-body - match: (?:qualified|as|hiding){{break}} scope: storage.modifier.import.haskell - include: ident-namespaces - include: ident-modules - - match: \( - scope: punctuation.section.sequence.begin.haskell - set: import-tuple-body - include: else-pop import-tuple-body: From 2377fbecf2989046e8b53d79b97efb3becede473 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 30 Dec 2020 17:13:18 +0100 Subject: [PATCH 112/178] [Haskell] Simplify quasi quotes --- Haskell/Haskell.sublime-syntax | 56 +++++++++++++--------------------- Haskell/syntax_test_haskell.hs | 25 +++++++++++++++ 2 files changed, 47 insertions(+), 34 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index de13a05ce8..8acbcf885b 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -212,7 +212,7 @@ contexts: - include: literal-numbers - include: type-forall - include: operators - - include: splice + - include: quasi-quotes - include: parens - include: lists - include: keywords @@ -737,7 +737,7 @@ contexts: - include: type-content - include: else-pop -###[ BLOCKS / RECORDS / GROUPS / LISTS / TUPLES ]############################## +###[ BRACES ]################################################################## blocks: # 2.7 Layout @@ -769,6 +769,8 @@ contexts: - include: expressions - include: else-pop +###[ BRACKETS ]################################################################ + lists: # 3.7 Lists # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-340003.7 @@ -788,6 +790,24 @@ contexts: - include: expressions - include: else-pop + quasi-quotes: + # https://wiki.haskell.org/Quasiquotation + - match: (\[)([\w'']+)(\|) + captures: + 1: punctuation.section.quasi-quotes.begin.haskell + 2: variable.function.quasi-quoter.haskell + 3: punctuation.section.quasi-quotes.haskell + push: quasi-quotes-body + + quasi-quotes-body: + - meta_scope: meta.quasi-quotes.haskell + - meta_content_scope: meta.string.haskell string.unquoted.haskell + - match: \|\] + scope: punctuation.section.quasi-quotes.end.haskell + pop: 1 + +###[ PARENTHESES ]############################################################# + parens: # 3.8 Tuples # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-360003.8 @@ -1045,38 +1065,6 @@ contexts: - match: ',' scope: punctuation.separator.sequence.haskell - splice: - - match: '\[(?:|e|d|t|p)\|' - comment: Points out splices in ast quotes - scope: keyword.other.quasibracket.haskell - push: - - meta_scope: meta.other.quasiquote.haskell - - match: '(.*)(\|\])' - captures: - 1: string.quasiquoted.haskell - 2: keyword.other.quasibracket.haskell - pop: 1 - - match: \$\( - scope: keyword.other.splice.haskell - - match: \$ - scope: string.quasiquoted.haskell - - match: '[^$]*' - scope: string.quasiquoted.haskell - - match: \$\( - comment: Highlight the beginning of a splice. - scope: keyword.other.splice.haskell - - match: '\[[\w'']*\|' - scope: keyword.other.quasibracket.haskell - push: - - meta_scope: meta.other.quasiquote.haskell - - match: '(.*)(\|\])' - captures: - 1: string.quasiquoted.haskell - 2: keyword.other.quasibracket.haskell - pop: 1 - - match: .* - scope: string.quasiquoted.haskell - ###[ PROTOTYPES ]############################################################## else-pop: diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index f8fdd1d19a..38d54c06cc 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -2232,6 +2232,31 @@ main = do -- ^ - meta.group +-- [ QUASI QUOTATIONS ]-------------------------------------------------------- + + {- Custom Syntax -} + [expr|$x + $y|] +-- ^^^^^^ meta.quasi-quotes.haskell - meta.string +-- ^^^^^^^ meta.quasi-quotes.haskell meta.string.haskell +-- ^^ meta.quasi-quotes.haskell - meta.string +-- ^ punctuation.section.quasi-quotes.begin.haskell +-- ^^^^ variable.function.quasi-quoter +-- ^ punctuation.section.quasi-quotes.haskell +-- ^^^^^^^ string.unquoted.haskell +-- ^^ punctuation.section.quasi-quotes.end.haskell + + {- Raw Strings -} + [r|\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}|] +-- ^^^ meta.quasi-quotes.haskell - meta.string +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.quasi-quotes.haskell meta.string.haskell +-- ^^ meta.quasi-quotes.haskell - meta.string +-- ^ punctuation.section.quasi-quotes.begin.haskell +-- ^ variable.function.quasi-quoter +-- ^ punctuation.section.quasi-quotes.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.unquoted.haskell +-- ^^ punctuation.section.quasi-quotes.end.haskell + + -- [ IDENTS ] ----------------------------------------------------------------- _ From 11a1de4c8fd2723038e4b4fbe398c512e28d04c9 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 30 Dec 2020 17:28:32 +0100 Subject: [PATCH 113/178] [Haskell] Rename type-content --- Haskell/Haskell.sublime-syntax | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 8acbcf885b..de8aa9a5b3 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -503,7 +503,7 @@ contexts: - match: where{{break}} scope: keyword.control.context.haskell set: class-block - - include: type-content + - include: type-expressions - include: else-pop class-block: @@ -535,7 +535,7 @@ contexts: # https://wiki.haskell.org/GHC/Type_families - match: (?:family|instance){{break}} scope: storage.modifier.family.haskell - - include: type-content + - include: type-expressions - include: else-pop ###[ DEFAULT DECLARATIONS ]#################################################### @@ -646,7 +646,7 @@ contexts: newtype-body: - meta_scope: meta.declaration.newtype.haskell - - include: type-content + - include: type-expressions - include: else-pop ###[ TYPE DECLARATIONS ]####################################################### @@ -658,12 +658,12 @@ contexts: type-body: - meta_scope: meta.declaration.type.haskell - - include: type-content + - include: type-expressions - include: else-pop -###[ TYPE SIGNATURES ]######################################################### +###[ TYPE EXPRESSIONS ]######################################################## - type-content: + type-expressions: - include: big-arrow-operators - include: right-arrow-operators - include: type-lists @@ -699,7 +699,7 @@ contexts: - meta_scope: meta.sequence.list.haskell - include: list-end - include: sequence-separators - - include: type-content + - include: type-expressions - include: else-pop type-parens: @@ -722,7 +722,7 @@ contexts: - match: ',|:(?!{{symbol}})' fail: type-parens - include: group-end - - include: type-content + - include: type-expressions - include: else-pop type-tuple: @@ -734,7 +734,7 @@ contexts: - meta_scope: meta.sequence.tuple.haskell - include: tuple-end - include: sequence-separators - - include: type-content + - include: type-expressions - include: else-pop ###[ BRACES ]################################################################## From fd136b6028fa48de943638fc4587f006d4f68905 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 30 Dec 2020 17:53:48 +0100 Subject: [PATCH 114/178] [Haskell] Rename variable-prefix from builtin_ to prelude_ --- Haskell/Haskell.sublime-syntax | 114 ++++++++++++++++----------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index de8aa9a5b3..83bbb399f1 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -72,56 +72,6 @@ variables: | (\^[A-Z@\[\]\\\^_]) # Control Chars ) - builtin_classes: |- - (?x: - # 9 Standard Prelude - Applicative | Bounded | Enum | Eq | Floating | Foldableble | Fractional - | Functor | Integral | Monad | Monadoid | Num | Ord | Rational | Read - | Real | RealFloat | RealFrac | Show | Traversable - ){{break}} - - builtin_constants: |- - (?x: Just | Nothing | Left | Right | True | False | LT | EQ | GT ){{break}} - - builtin_types: |- - (?x: - # 9 Standard Prelude - Bool | Char | Double | Either | FilePath | Float | Int | Integer | IO - | IOError | Maybe | Ordering | ReadS | ShowS | String | Word - # 24 Foreign - # https://www.haskell.org/onlinereport/haskell2010/haskellch24.html#x32-26200024 - | Int8 | Int16 | Int32 | Int64 | Word8 | Word16 | Word32 | Word64 - | Ptr | FunPtr | StablePtr - ){{break}} - - builtin_functions: |- - (?x: - abs | acos | acosh | all | and | any | appendFile | asTypeOf | asin - | asinh | atan | atan2 | atanh | break | ceiling | compare | concat - | concatMap | const | cos | cosh | curry | cycle | decodeFloat | div - | divMod | drop | dropWhile | either | elem | encodeFloat | enumFrom - | enumFromThen | enumFromThenTo | enumFromTo | error | errorWithoutStackTrace - | even | exp | exponent | fail | filter | flip | floatDigits | floatRadix - | floatRange | floor | fmap | foldMap | foldl | foldl1 | foldr | foldr1 - | fromEnum | fromInteger | fromIntegral | fromRational | fst | gcd | getChar - | getContents | getLine | head | id | init | interact | ioError - | isDenormalized | isIEEE | isInfinite | isNaN | isNegativeZero | iterate - | last | lcm | length | lex | lines | log | logBase | lookup | map | mapM - | mapM_ | mappend | max | maxBound | maximum | maybe | mconcat | mempty - | min | minBound | minimum | mod | negate | not | notElem | null | odd | or - | otherwise | pi | pred | print | product | properFraction | pure | putChar - | putStr | putStrLn | quot | quotRem | read | readFile | readIO | readList - | readLn | readParen | reads | readsPrec | realToFrac | recip | rem | repeat - | replicate | return | reverse | round | scaleFloat | scanl | scanl1 | scanr - | scanr1 | seq | sequence | sequenceA | sequence_ | show | showChar - | showList | showParen | showString | shows | showsPrec | significand - | signum | sin | sinh | snd | span | splitAt | sqrt | subtract | succ | sum - | tail | take | takeWhile | tan | tanh | toEnum | toInteger | toRational - | traverse | truncate | uncurry | undefined | unlines | until | unwords - | unzip | unzip3 | userError | words | writeFile | zip | zip3 | zipWith - | zipWith3 - ){{break}} - # https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#pragmas pragma_keys: |- (?x: @@ -177,6 +127,56 @@ variables: | UnliftedFFITypes | UnliftedNewtypes | ViewPatterns ){{break}} + prelude_classes: |- + (?x: + # 9 Standard Prelude + Applicative | Bounded | Enum | Eq | Floating | Foldableble | Fractional + | Functor | Integral | Monad | Monadoid | Num | Ord | Rational | Read + | Real | RealFloat | RealFrac | Show | Traversable + ){{break}} + + prelude_constants: |- + (?x: Just | Nothing | Left | Right | True | False | LT | EQ | GT ){{break}} + + prelude_types: |- + (?x: + # 9 Standard Prelude + Bool | Char | Double | Either | FilePath | Float | Int | Integer | IO + | IOError | Maybe | Ordering | ReadS | ShowS | String | Word + # 24 Foreign + # https://www.haskell.org/onlinereport/haskell2010/haskellch24.html#x32-26200024 + | Int8 | Int16 | Int32 | Int64 | Word8 | Word16 | Word32 | Word64 + | Ptr | FunPtr | StablePtr + ){{break}} + + prelude_functions: |- + (?x: + abs | acos | acosh | all | and | any | appendFile | asTypeOf | asin + | asinh | atan | atan2 | atanh | break | ceiling | compare | concat + | concatMap | const | cos | cosh | curry | cycle | decodeFloat | div + | divMod | drop | dropWhile | either | elem | encodeFloat | enumFrom + | enumFromThen | enumFromThenTo | enumFromTo | error | errorWithoutStackTrace + | even | exp | exponent | fail | filter | flip | floatDigits | floatRadix + | floatRange | floor | fmap | foldMap | foldl | foldl1 | foldr | foldr1 + | fromEnum | fromInteger | fromIntegral | fromRational | fst | gcd | getChar + | getContents | getLine | head | id | init | interact | ioError + | isDenormalized | isIEEE | isInfinite | isNaN | isNegativeZero | iterate + | last | lcm | length | lex | lines | log | logBase | lookup | map | mapM + | mapM_ | mappend | max | maxBound | maximum | maybe | mconcat | mempty + | min | minBound | minimum | mod | negate | not | notElem | null | odd | or + | otherwise | pi | pred | print | product | properFraction | pure | putChar + | putStr | putStrLn | quot | quotRem | read | readFile | readIO | readList + | readLn | readParen | reads | readsPrec | realToFrac | recip | rem | repeat + | replicate | return | reverse | round | scaleFloat | scanl | scanl1 | scanr + | scanr1 | seq | sequence | sequenceA | sequence_ | show | showChar + | showList | showParen | showString | shows | showsPrec | significand + | signum | sin | sinh | snd | span | splitAt | sqrt | subtract | succ | sum + | tail | take | takeWhile | tan | tanh | toEnum | toInteger | toRational + | traverse | truncate | uncurry | undefined | unlines | until | unwords + | unzip | unzip3 | userError | words | writeFile | zip | zip3 | zipWith + | zipWith3 + ){{break}} + ############################################################################### contexts: @@ -620,7 +620,7 @@ contexts: captures: 1: keyword.operator.haskell push: variable-name-end - - match: '{{builtin_functions}}' + - match: '{{prelude_functions}}' scope: support.function.prelude.haskell push: variable-name-end - match: '{{var_id}}' @@ -879,19 +879,19 @@ contexts: ident-builtin-classes: # Prelude Class Types - - match: '{{builtin_classes}}' + - match: '{{prelude_classes}}' scope: support.class.prelude.haskell ident-builtin-types: # Prelude Data Types of special meaning - - match: '{{builtin_constants}}' + - match: '{{prelude_constants}}' scope: support.constant.prelude.haskell # Prelude Data Types - - match: '{{builtin_types}}' + - match: '{{prelude_types}}' scope: support.type.prelude.haskell ident-builtin-functions: - - match: '{{builtin_functions}}' + - match: '{{prelude_functions}}' scope: support.function.prelude.haskell ident-namespaces: @@ -911,10 +911,10 @@ contexts: scope: storage.type.haskell ident-type: - - match: '{{builtin_classes}}' + - match: '{{prelude_classes}}' scope: support.class.prelude.haskell pop: 1 - - match: '{{builtin_types}}' + - match: '{{prelude_types}}' scope: support.type.prelude.haskell pop: 1 - match: '{{con_id}}' From d41fffddc6aa43ba0ab1af90fefda7a9ad0f39d8 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 30 Dec 2020 18:01:37 +0100 Subject: [PATCH 115/178] [Haskell] Merge sequence separator patterns --- Haskell/Haskell.sublime-syntax | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 83bbb399f1..47c5eef600 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -304,7 +304,7 @@ contexts: - meta_include_prototype: false - meta_content_scope: meta.preprocessor.pragma.value.other.haskell - include: preprocessor-pragma-common - - include: constructor-separators + - include: sequence-separators - include: literal-numbers - include: literal-strings - match: (-*)[-\w]+ @@ -1010,7 +1010,6 @@ contexts: scope: keyword.declaration.fixity.haskell operators: - - include: constructor-separators - include: sequence-separators - include: big-arrow-operators - include: left-arrow-operators @@ -1038,10 +1037,6 @@ contexts: - match: '{{operator_right_arrow}}' scope: keyword.operator.arrow.haskell - constructor-separators: - - match: \|(?!\|) - scope: punctuation.separator.sequence.haskell - infix-parens-operators: - match: \(\s*({{operator_parens}})\s*\) scope: variable.function.infix.haskell @@ -1062,7 +1057,7 @@ contexts: scope: punctuation.terminator.statement.haskell sequence-separators: - - match: ',' + - match: ',|\|(?!\|)' scope: punctuation.separator.sequence.haskell ###[ PROTOTYPES ]############################################################## From 96f39e36336d7d81ca46de0a2239de942aea4267 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 30 Dec 2020 18:10:03 +0100 Subject: [PATCH 116/178] [Haskell] Add a note upon forall . --- Haskell/Haskell.sublime-syntax | 1 + 1 file changed, 1 insertion(+) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 47c5eef600..24da75327d 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -683,6 +683,7 @@ contexts: push: type-forall-body type-forall-body: + # Note: This is the only situation a dot is allowed within type expressions. - match: \. scope: keyword.operator.haskell pop: 1 From c8ab692ec7a4665307f398337fec2b5d157365d0 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 30 Dec 2020 18:21:29 +0100 Subject: [PATCH 117/178] [Haskell] Update Symbol Lists This commit... 1. Removes the normal Symbol List.tmPreferences as function declarations are already covered by ST's Default package. That's possible because function declarations are scoped `meta.function entity.name.function`. 2. Adds a symbol list for module declarations. --- ...st.tmPreferences => Symbol List - Modules.tmPreferences} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename Haskell/{Symbol List.tmPreferences => Symbol List - Modules.tmPreferences} (58%) diff --git a/Haskell/Symbol List.tmPreferences b/Haskell/Symbol List - Modules.tmPreferences similarity index 58% rename from Haskell/Symbol List.tmPreferences rename to Haskell/Symbol List - Modules.tmPreferences index f4f8e95966..83be88b927 100644 --- a/Haskell/Symbol List.tmPreferences +++ b/Haskell/Symbol List - Modules.tmPreferences @@ -1,14 +1,14 @@ - name - Symbol List scope - source.haskell entity.name.function - entity.name.function.infix + meta.declaration.module.haskell entity.name.namespace.haskell settings showInSymbolList 1 + showInIndexedSymbolList + 1 From 8f0345a2e40ba7925ee1c6fac301de6564bac3d3 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 30 Dec 2020 18:31:40 +0100 Subject: [PATCH 118/178] [Haskell] Tidy up tmPreferences This commit... 1. renames Indent Patterns to `Indentation Rules.tmPreferences` 2. removes name parts from tmPreferences files. --- Haskell/Comments.tmPreferences | 2 -- ...t Patterns.tmPreferences => Indentation Rules.tmPreferences} | 2 -- 2 files changed, 4 deletions(-) rename Haskell/{Indent Patterns.tmPreferences => Indentation Rules.tmPreferences} (86%) diff --git a/Haskell/Comments.tmPreferences b/Haskell/Comments.tmPreferences index f73f94787d..0d90aec780 100644 --- a/Haskell/Comments.tmPreferences +++ b/Haskell/Comments.tmPreferences @@ -1,8 +1,6 @@ - name - Comments scope source.haskell settings diff --git a/Haskell/Indent Patterns.tmPreferences b/Haskell/Indentation Rules.tmPreferences similarity index 86% rename from Haskell/Indent Patterns.tmPreferences rename to Haskell/Indentation Rules.tmPreferences index cefcfb85cc..02151c1355 100644 --- a/Haskell/Indent Patterns.tmPreferences +++ b/Haskell/Indentation Rules.tmPreferences @@ -1,8 +1,6 @@ - name - Indent Patterns scope source.haskell settings From 7e67d13edd2e4b8931c4b067d489c6bfd2cc77e9 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 31 Dec 2020 10:35:20 +0100 Subject: [PATCH 119/178] [Haskell] Remove word separator settings As `'` is used to denote character literals it should probably not be removed from word_separators, even though it is a legal identifier character as well. --- Haskell/Haskell.sublime-settings | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 Haskell/Haskell.sublime-settings diff --git a/Haskell/Haskell.sublime-settings b/Haskell/Haskell.sublime-settings deleted file mode 100644 index 76c0385c00..0000000000 --- a/Haskell/Haskell.sublime-settings +++ /dev/null @@ -1,4 +0,0 @@ -{ - // Default word boundaries except: ' - "word_separators": "./\\()\"-:,.;<>~!@#$%^&*|+=[]{}`~?", -} \ No newline at end of file From 4b5c1371ec161e4000ddd72e316596490c969942 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 31 Dec 2020 13:24:23 +0100 Subject: [PATCH 120/178] [Haskell] Fix module scope in export list --- Haskell/Haskell.sublime-syntax | 21 ++++++++++++++++----- Haskell/syntax_test_haskell.hs | 4 ++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 24da75327d..ee6704230a 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -331,6 +331,7 @@ contexts: push: - module-block - module-meta + - module-export - module-name # https://wiki.haskell.org/Module_signature - match: signature{{break}} @@ -338,6 +339,7 @@ contexts: push: - module-block - signature-meta + - module-export - module-name module-meta: @@ -351,14 +353,17 @@ contexts: - include: immediatelly-pop module-name: + - include: ident-namespaces + - include: ident-module + - include: else-pop + + module-export: - match: \( scope: punctuation.section.sequence.begin.haskell - set: module-exports-body - - include: ident-namespaces - - include: ident-modules + set: module-export-body - include: else-pop - module-exports-body: + module-export-body: - meta_scope: meta.sequence.tuple.haskell - include: tuple-end - include: range-tuples @@ -366,9 +371,10 @@ contexts: - include: sequence-separators - match: \( scope: punctuation.section.sequence.begin.haskell - push: module-exports-body + push: module-export-body - match: module{{break}} scope: keyword.declaration.namespace.haskell + push: module-name - include: ident-functions - include: ident-namespaces - include: ident-types @@ -905,6 +911,11 @@ contexts: - match: '{{con_id}}' scope: entity.name.namespace.haskell + ident-module: + - match: '{{con_id}}' + scope: entity.name.namespace.haskell + pop: 1 + ident-types: - include: ident-builtin-classes - include: ident-builtin-types diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 38d54c06cc..e7f97b3b61 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -305,7 +305,7 @@ -- ^^^^^^ keyword.declaration.namespace.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ entity.name.namespace.haskell -- ^ punctuation.section.sequence.end.haskell -- ^^^^^ keyword.control.context.haskell -- ^ punctuation.section.block.begin.haskell @@ -408,7 +408,7 @@ -- ^^^^^^ keyword.declaration.namespace.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ entity.name.namespace.haskell -- ^ punctuation.section.sequence.end.haskell -- ^^^^^ keyword.control.context.haskell -- ^ punctuation.section.block.begin.haskell From f620c80193b4df06647237fac0b1a68344ee3ee5 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 31 Dec 2020 13:32:52 +0100 Subject: [PATCH 121/178] [Haskell] Tweak module declaration statement Align context usage strategy and scope boundaries with class declarations. --- Haskell/Haskell.sublime-syntax | 37 +++++++++++++++++----------------- Haskell/syntax_test_haskell.hs | 18 +++++++++++------ 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index ee6704230a..514a285e70 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -327,31 +327,23 @@ contexts: # 5.1 Module Structure # https://www.haskell.org/onlinereport/haskell2010/haskellch5.html#x11-990005.1 - match: module{{break}} - scope: keyword.declaration.namespace.haskell + scope: + meta.declaration.module.haskell + keyword.declaration.namespace.haskell push: - - module-block - - module-meta + - module-where - module-export - module-name # https://wiki.haskell.org/Module_signature - match: signature{{break}} - scope: keyword.declaration.namespace.haskell + scope: + meta.declaration.signature.haskell + keyword.declaration.namespace.haskell push: - - module-block - - signature-meta + - signature-where - module-export - module-name - module-meta: - - meta_include_prototype: false - - meta_scope: meta.declaration.module.haskell - - include: immediatelly-pop - - signature-meta: - - meta_include_prototype: false - - meta_scope: meta.declaration.signature.haskell - - include: immediatelly-pop - module-name: - include: ident-namespaces - include: ident-module @@ -380,14 +372,23 @@ contexts: - include: ident-types - include: else-pop + signature-where: + - meta_content_scope: meta.declaration.signature.haskell + - include: module-where + + module-where: + - meta_content_scope: meta.declaration.module.haskell + - match: where{{break}} + scope: keyword.control.context.haskell + set: module-block + - include: else-pop + module-block: # The module body may be wrapped into braces, which still needs to be # handled as top-level block containing top-level declarations. - match: \{ scope: punctuation.section.block.begin.haskell set: module-block-body - - match: where{{break}} - scope: keyword.control.context.haskell - include: else-pop module-block-body: diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index e7f97b3b61..ffa538999c 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -256,7 +256,8 @@ module Name () where -- ^^^^^^^^^^^^ meta.declaration.module.haskell - meta.sequence -- ^^ meta.declaration.module.haskell meta.sequence.tuple.haskell --- ^^^^^^^ - meta.declaration.module +-- ^ meta.declaration.module.haskell - meta.sequence +-- ^^^^^^ - meta.declaration.module -- ^^^^^^ keyword.declaration.namespace.haskell -- ^^^^ entity.name.namespace.haskell -- ^ punctuation.section.sequence.begin.haskell @@ -266,7 +267,8 @@ module Ns.Name (sym1, sym2) where { import Ns.Other; import Ns.Other2 } -- ^^^^^^^^^^^^^^^ meta.declaration.module.haskell - meta.sequence -- ^^^^^^^^^^^^ meta.declaration.module.haskell meta.sequence.tuple.haskell --- ^^^^^^ - meta.declaration.module - meta.block - meta.sequence +-- ^ meta.declaration.module.haskell - meta.sequence +-- ^^^^^ - meta.declaration.module - meta.block - meta.sequence -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.haskell - meta.declaration.module -- ^ - meta.block -- ^^^^^^ keyword.declaration.namespace.haskell @@ -294,7 +296,8 @@ module Name (module Other.Module) where { import Other.Module } -- ^^^^^^^^^^^^ meta.declaration.module.haskell - meta.sequence -- ^^^^^^^^^^^^^^^^^^^^^ meta.declaration.module.haskell meta.sequence.tuple.haskell --- ^^^^^^^ - meta.declaration - meta.block - meta.sequence +-- ^ meta.declaration.module.haskell - meta.sequence +-- ^^^^^^ - meta.declaration - meta.block - meta.sequence -- ^^ meta.block.haskell - meta.import -- ^^^^^^^^^^^^^^^^^^^^ meta.block.haskell meta.import.haskell -- ^ meta.block.haskell - meta.import @@ -359,7 +362,8 @@ signature Name () where -- ^^^^^^^^^^^^^^^ meta.declaration.signature.haskell - meta.sequence -- ^^ meta.declaration.signature.haskell meta.sequence.tuple.haskell --- ^^^^^^^ - meta.declaration.signature +-- ^ meta.declaration.signature.haskell - meta.sequence +-- ^^^^^^ - meta.declaration.signature -- ^^^^^^^^^ keyword.declaration.namespace.haskell -- ^^^^ entity.name.namespace.haskell -- ^ punctuation.section.sequence.begin.haskell @@ -369,7 +373,8 @@ signature Ns.Name (sym1, sym2) where { import Ns.Other; import Ns.Other2 } -- ^^^^^^^^^^^^^^^^^^ meta.declaration.signature.haskell - meta.sequence -- ^^^^^^^^^^^^ meta.declaration.signature.haskell meta.sequence.tuple.haskell --- ^^^^^^ - meta.declaration.signature - meta.block - meta.sequence +-- ^ meta.declaration.signature.haskell - meta.sequence +-- ^^^^^ - meta.declaration.signature - meta.block - meta.sequence -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.haskell - meta.declaration.signature -- ^ - meta.block -- ^^^^^^^^^ keyword.declaration.namespace.haskell @@ -397,7 +402,8 @@ signature Name (module Other.Module) where { import Other.Module } -- ^^^^^^^^^^^^^^^ meta.declaration.signature.haskell - meta.sequence -- ^^^^^^^^^^^^^^^^^^^^^ meta.declaration.signature.haskell meta.sequence.tuple.haskell --- ^^^^^^^ - meta.declaration - meta.block - meta.sequence +-- ^ meta.declaration.signature.haskell - meta.sequence +-- ^^^^^^ - meta.declaration - meta.block - meta.sequence -- ^^ meta.block.haskell - meta.import -- ^^^^^^^^^^^^^^^^^^^^ meta.block.haskell meta.import.haskell -- ^ meta.block.haskell - meta.import From 4ab78dc44023e66c4b198b6e296697bae6664381 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 31 Dec 2020 13:39:00 +0100 Subject: [PATCH 122/178] [Haskell] Scope Just/Left/Right as prelude type Those are builtin constructors of special meaning but no constants. --- Haskell/Haskell.sublime-syntax | 8 ++++---- Haskell/syntax_test_haskell.hs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 514a285e70..2945140cfc 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -136,16 +136,16 @@ variables: ){{break}} prelude_constants: |- - (?x: Just | Nothing | Left | Right | True | False | LT | EQ | GT ){{break}} + (?x: Nothing | True | False | LT | EQ | GT ){{break}} prelude_types: |- (?x: # 9 Standard Prelude - Bool | Char | Double | Either | FilePath | Float | Int | Integer | IO - | IOError | Maybe | Ordering | ReadS | ShowS | String | Word + Bool | Char | Double | Either | FilePath | Float | Integer | IO | IOError + | Maybe | Just | Left | Ordering | ReadS | Right | ShowS | String # 24 Foreign # https://www.haskell.org/onlinereport/haskell2010/haskellch24.html#x32-26200024 - | Int8 | Int16 | Int32 | Int64 | Word8 | Word16 | Word32 | Word64 + | Int | Int8 | Int16 | Int32 | Int64 | Word | Word8 | Word16 | Word32 | Word64 | Ptr | FunPtr | StablePtr ){{break}} diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index ffa538999c..589d16c71b 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -2307,7 +2307,7 @@ main = do -- ^ variable.other.haskell Just --- ^^^^ support.constant.prelude.haskell +-- ^^^^ support.type.prelude.haskell Nothing -- ^^^^^^^ support.constant.prelude.haskell From d065b66fd744aa7d08c99d143a7c4ef9526040a7 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 31 Dec 2020 14:05:17 +0100 Subject: [PATCH 123/178] [Haskell] Add some pattern/function binding tests This commit adds some missing tests for bindings within classes. A statement like `variable { patterns } | { guards } =` maybe a pattern binding or a function binding. A pattern or guard may consist of arbitrary expressions. It's therefore hard to distinguish them, without adding sophisticated context switches which tend to be error prone due to lack of reliable boundary detection. Thus both use `variable.other` only, atm. see: 4.4.3 Function and Pattern Bindings https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-800004.4 --- Haskell/syntax_test_haskell.hs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 589d16c71b..8c4e0e96f8 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -1878,6 +1878,13 @@ -- ^ variable.other.haskell -- ^^ keyword.operator.arrow.haskell -- ^^^^ support.type.prelude.haskell + + {- maybe function or pattern binding -} + method1 = True +-- ^^^^^^^ variable.other.haskell +-- ^ keyword.operator.haskell +-- ^^^^ support.constant.prelude.haskell + method' :: -- ^^^^^^^^ meta.function.identifier.haskell -- ^^^^^^^ entity.name.function.haskell @@ -1897,6 +1904,8 @@ -- ^^ keyword.operator.arrow.haskell -- ^^^^ support.type.prelude.haskell -- ^ punctuation.terminator.statement.haskell + + {- maybe function or pattern binding -} method = True; -- ^^^^^^^^^^^^^^^ meta.block.haskell -- ^^^^^^ variable.other.haskell @@ -1927,6 +1936,13 @@ -- ^ variable.other.haskell -- ^^ keyword.operator.arrow.haskell -- ^^^^ support.type.prelude.haskell + + {- maybe function or pattern binding -} + method1 = True +-- ^^^^^^^ variable.other.haskell +-- ^ keyword.operator.haskell +-- ^^^^ support.constant.prelude.haskell + method' :: -- ^^^^^^^^ meta.function.identifier.haskell -- ^^^^^^^ entity.name.function.haskell @@ -1946,6 +1962,8 @@ -- ^^ keyword.operator.arrow.haskell -- ^^^^ support.type.prelude.haskell -- ^ punctuation.terminator.statement.haskell + + {- maybe function or pattern binding -} method = True; -- ^^^^^^^^^^^^^^^ meta.block.haskell -- ^^^^^^ variable.other.haskell From cf8f67c695cd9092c0c34ac0384caa2c2a658ea9 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 31 Dec 2020 14:13:29 +0100 Subject: [PATCH 124/178] [Haskell] Add exported type test Add a test case to ensure scope of exported data types. Exports are considered references and thus don't use `entity.name`. --- Haskell/syntax_test_haskell.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 8c4e0e96f8..b55d3e0fcf 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -264,7 +264,7 @@ -- ^ punctuation.section.sequence.end.haskell -- ^^^^^ keyword.control.context.haskell - module Ns.Name (sym1, sym2) where { import Ns.Other; import Ns.Other2 } + module Ns.Name (sym1, Sym2) where { import Ns.Other; import Ns.Other2 } -- ^^^^^^^^^^^^^^^ meta.declaration.module.haskell - meta.sequence -- ^^^^^^^^^^^^ meta.declaration.module.haskell meta.sequence.tuple.haskell -- ^ meta.declaration.module.haskell - meta.sequence @@ -278,7 +278,7 @@ -- ^ punctuation.section.sequence.begin.haskell -- ^^^^ variable.function.haskell -- ^ punctuation.separator.sequence.haskell --- ^^^^ variable.function.haskell +-- ^^^^ storage.type.haskell -- ^ punctuation.section.sequence.end.haskell -- ^^^^^ keyword.control.context.haskell -- ^ punctuation.section.block.begin.haskell @@ -370,7 +370,7 @@ -- ^ punctuation.section.sequence.end.haskell -- ^^^^^ keyword.control.context.haskell - signature Ns.Name (sym1, sym2) where { import Ns.Other; import Ns.Other2 } + signature Ns.Name (sym1, Sym2) where { import Ns.Other; import Ns.Other2 } -- ^^^^^^^^^^^^^^^^^^ meta.declaration.signature.haskell - meta.sequence -- ^^^^^^^^^^^^ meta.declaration.signature.haskell meta.sequence.tuple.haskell -- ^ meta.declaration.signature.haskell - meta.sequence @@ -384,7 +384,7 @@ -- ^ punctuation.section.sequence.begin.haskell -- ^^^^ variable.function.haskell -- ^ punctuation.separator.sequence.haskell --- ^^^^ variable.function.haskell +-- ^^^^ storage.type.haskell -- ^ punctuation.section.sequence.end.haskell -- ^^^^^ keyword.control.context.haskell -- ^ punctuation.section.block.begin.haskell From aa0890d975e46f5dac205c13ded1601a710f220d Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 31 Dec 2020 16:14:53 +0100 Subject: [PATCH 125/178] [Haskell] Limit constant scope in pragmas to OPTIONS --- Haskell/Haskell.sublime-syntax | 16 ++++++--- Haskell/syntax_test_haskell.hs | 62 ++++++++++++++++++++-------------- 2 files changed, 49 insertions(+), 29 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 2945140cfc..8951bcc459 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -283,6 +283,9 @@ contexts: - match: LANGUAGE{{break}} scope: keyword.directive.language.haskell set: preprocessor-pragma-language-value + - match: (?:OPTIONS_GHC|OPTIONS_HADDOCK){{break}} + scope: keyword.directive.options.haskell + set: preprocessor-pragma-options-value - match: '{{pragma_keys}}' scope: keyword.directive.builtin.haskell set: preprocessor-pragma-other-value @@ -300,6 +303,15 @@ contexts: - match: '{{pragma_deprecated_constants}}' scope: constant.language.extension.haskell invalid.deprecated.haskell + preprocessor-pragma-options-value: + - meta_include_prototype: false + - meta_content_scope: meta.preprocessor.pragma.value.options.haskell + - include: preprocessor-pragma-common + - match: (-*)[-\w]+ + scope: constant.other.pragma.haskell + captures: + 1: punctuation.definition.constant.haskell + preprocessor-pragma-other-value: - meta_include_prototype: false - meta_content_scope: meta.preprocessor.pragma.value.other.haskell @@ -307,10 +319,6 @@ contexts: - include: sequence-separators - include: literal-numbers - include: literal-strings - - match: (-*)[-\w]+ - scope: constant.other.pragma.haskell - captures: - 1: punctuation.definition.constant.haskell preprocessor-pragma-common: - match: '#-\}' diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index b55d3e0fcf..f6fa57c902 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -124,6 +124,13 @@ -- [ PREPROCESSOR ] ----------------------------------------------------------- + + {-# INLINABLE unless #-} +-- ^^^^^^^^^^^^^ meta.preprocessor.pragma.directive.haskell +-- ^^^^^^^^ meta.preprocessor.pragma.value.other.haskell +-- ^^^ meta.preprocessor.pragma.value.haskell +-- ^ - meta.preprocessor.haskell + {-# MINIMAL traverse | sequenceA LANGUAGE #-} -- ^^^^^^^^^^^ meta.preprocessor.pragma.directive.haskell -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.pragma.value.other.haskell @@ -131,34 +138,10 @@ -- ^ - meta.preprocessor.haskell -- ^^^ punctuation.section.preprocessor.begin.haskell -- ^^^^^^^ keyword.directive.builtin.haskell --- ^^^^^^^^ constant.other.pragma.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - constant - keyword -- ^ punctuation.separator.sequence.haskell --- ^^^^^^^^^ constant.other.pragma.haskell --- ^^^^^^^^ constant.other.pragma.haskell --- ^^^^^^^^ - keyword.directive -- ^^^ punctuation.section.preprocessor.end.haskell - {-# OPTIONS_GHC -Drelease #-} --- ^^^^^^^^^^^^^^^ meta.preprocessor.pragma.directive.haskell --- ^^^^^^^^^^^ meta.preprocessor.pragma.value.other.haskell --- ^^^ meta.preprocessor.pragma.value.haskell --- ^ - meta.preprocessor.haskell --- ^^^ punctuation.section.preprocessor.begin.haskell --- ^^^^^^^^^^^ keyword.directive.builtin.haskell --- ^^^^^^^^^ constant.other.pragma.haskell --- ^ punctuation.definition.constant.haskell --- ^^^ punctuation.section.preprocessor.end.haskell - - {-# OPTIONS_HADDOCK not-home #-} --- ^^^^^^^^^^^^^^^^^^^ meta.preprocessor.pragma.directive.haskell --- ^^^^^^^^^^ meta.preprocessor.pragma.value.other.haskell --- ^^^ meta.preprocessor.pragma.value.haskell --- ^ - meta.preprocessor.haskell --- ^^^ punctuation.section.preprocessor.begin.haskell --- ^^^^^^^^^^^^^^^ keyword.directive.builtin.haskell --- ^^^^^^^^ constant.other.pragma.haskell --- ^^^ punctuation.section.preprocessor.end.haskell - {-# LANGUAGE -- ^^^^^^^^^^^^ meta.preprocessor.pragma.directive.haskell -- ^ meta.preprocessor.pragma.value.language.haskell @@ -192,6 +175,35 @@ #-} -- ^^^ meta.preprocessor.pragma.value.haskell punctuation.section.preprocessor.end.haskell + {-# OPTIONS_GHC -Drelease #-} +-- ^^^^^^^^^^^^^^^ meta.preprocessor.pragma.directive.haskell +-- ^^^^^^^^^^^ meta.preprocessor.pragma.value.options.haskell +-- ^^^ meta.preprocessor.pragma.value.haskell +-- ^ - meta.preprocessor.haskell +-- ^^^ punctuation.section.preprocessor.begin.haskell +-- ^^^^^^^^^^^ keyword.directive.options.haskell +-- ^^^^^^^^^ constant.other.pragma.haskell +-- ^ punctuation.definition.constant.haskell +-- ^^^ punctuation.section.preprocessor.end.haskell + + {-# OPTIONS_HADDOCK not-home #-} +-- ^^^^^^^^^^^^^^^^^^^ meta.preprocessor.pragma.directive.haskell +-- ^^^^^^^^^^ meta.preprocessor.pragma.value.options.haskell +-- ^^^ meta.preprocessor.pragma.value.haskell +-- ^ - meta.preprocessor.haskell +-- ^^^ punctuation.section.preprocessor.begin.haskell +-- ^^^^^^^^^^^^^^^ keyword.directive.options.haskell +-- ^^^^^^^^ constant.other.pragma.haskell +-- ^^^ punctuation.section.preprocessor.end.haskell + + {-# SPECIALISE unless :: Bool -> IO () -> IO () #-} +-- ^^^^^^^^^^^^^^ meta.preprocessor.pragma.directive.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.pragma.value.other.haskell +-- ^^^ meta.preprocessor.pragma.value.haskell +-- ^^^ punctuation.section.preprocessor.begin.haskell +-- ^^^^^^^^^^ keyword.directive.builtin.haskell +-- ^^^ punctuation.section.preprocessor.end.haskell + {-# WARNING "Not supported" #-} -- ^^^^^^^^^^^ meta.preprocessor.pragma.directive.haskell -- ^^^^^^^^^^^^^^^^^ meta.preprocessor.pragma.value.other.haskell From 60f4683f7c072ddcb0c89f314ed7a47cddf10781 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 31 Dec 2020 17:30:57 +0100 Subject: [PATCH 126/178] [Haskell] Fix infix operators in parentheses Operators may be wrapped into parentheses to use them in uncommon positions, but this does not turn the whole parenthesis expression into a function. It keeps a normal group which just contains a single operator. --- Haskell/Haskell.sublime-syntax | 32 ++--- Haskell/Symbol List - Operators.tmPreferences | 12 ++ Haskell/syntax_test_haskell.hs | 120 ++++++++++++++---- 3 files changed, 121 insertions(+), 43 deletions(-) create mode 100644 Haskell/Symbol List - Operators.tmPreferences diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 8951bcc459..c767323f83 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -366,7 +366,6 @@ contexts: module-export-body: - meta_scope: meta.sequence.tuple.haskell - include: tuple-end - - include: range-tuples - include: infix-parens-operators - include: sequence-separators - match: \( @@ -435,7 +434,6 @@ contexts: import-tuple-body: - meta_scope: meta.sequence.tuple.haskell - include: tuple-end - - include: range-tuples - include: infix-parens-operators - include: sequence-separators - match: \( @@ -623,17 +621,16 @@ contexts: pop: 1 - match: '{{var_id}}' scope: entity.name.function.haskell - - match: \(\s*({{operator_parens}})\s*\) - scope: entity.name.function.infix.haskell - captures: - 1: keyword.operator.haskell + - include: infix-parens-operators - include: sequence-separators variable-name: - - match: \(\s*({{operator_parens}})\s*\) - scope: variable.function.infix.haskell + - match: (\()\s*({{operator_parens}})\s*(\)) + scope: meta.group.haskell captures: - 1: keyword.operator.haskell + 1: punctuation.section.group.begin.haskell + 2: keyword.operator.haskell + 3: punctuation.section.group.end.haskell push: variable-name-end - match: '{{prelude_functions}}' scope: support.function.prelude.haskell @@ -879,14 +876,6 @@ contexts: 1: punctuation.section.sequence.begin.haskell 2: punctuation.section.sequence.end.haskell - range-tuples: - - match: (\()\s*(\.\.)\s*(\)) - scope: meta.sequence.tuple.haskell - captures: - 1: punctuation.section.sequence.begin.haskell - 2: keyword.operator.range.haskell - 3: punctuation.section.sequence.end.haskell - ###[ IDENTIFIERS ]############################################################# ident-anonymous: @@ -1035,7 +1024,6 @@ contexts: - include: big-arrow-operators - include: left-arrow-operators - include: right-arrow-operators - - include: infix-parens-operators - include: infix-quoted-operators # Match all not otherwise matched single quotes as promoition operator # Note: Found in real world code but not in specs so far. @@ -1059,10 +1047,12 @@ contexts: scope: keyword.operator.arrow.haskell infix-parens-operators: - - match: \(\s*({{operator_parens}})\s*\) - scope: variable.function.infix.haskell + - match: (\()\s*({{operator_parens}})\s*(\)) + scope: meta.group.haskell captures: - 1: keyword.operator.haskell + 1: punctuation.section.group.begin.haskell + 2: keyword.operator.haskell + 3: punctuation.section.group.end.haskell infix-quoted-operators: - match: (`)[ \w'.]*(`) diff --git a/Haskell/Symbol List - Operators.tmPreferences b/Haskell/Symbol List - Operators.tmPreferences new file mode 100644 index 0000000000..7e6ce51fc4 --- /dev/null +++ b/Haskell/Symbol List - Operators.tmPreferences @@ -0,0 +1,12 @@ + + + + scope + meta.function.identifier.haskell meta.group keyword.operator + settings + + showInSymbolList + 1 + + + diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index f6fa57c902..bc94a29861 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -509,7 +509,7 @@ import Mod1.Mod2.Module (ClassName(..)) -- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell - meta.sequence -- ^^^^^^^^^^ meta.import.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence --- ^^^^ meta.import.haskell meta.sequence.tuple.haskell meta.sequence.tuple.haskell +-- ^^^^ meta.import.haskell meta.sequence.tuple.haskell meta.group.haskell -- ^ meta.import.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence -- ^ - meta.import -- ^^^^^^ keyword.declaration.import.haskell @@ -520,9 +520,10 @@ -- ^^^^^^ entity.name.namespace.haskell - punctuation -- ^ punctuation.section.sequence.begin.haskell -- ^^^^^^^^^ storage.type.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^^ keyword.operator.range.haskell --- ^^ punctuation.section.sequence.end.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^^ keyword.operator.haskell +-- ^ punctuation.section.group.end.haskell +-- ^ punctuation.section.sequence.end.haskell import Mod1.Mod2.Module (ClassName (SubClass), funcName) -- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell - meta.sequence @@ -593,9 +594,15 @@ -- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell - meta.sequence -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence -- ^ punctuation.section.sequence.begin.haskell --- ^^^^^ variable.function.infix.haskell +-- ^^^^^ meta.group.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^^^ keyword.operator.haskell +-- ^ punctuation.section.group.end.haskell -- ^ punctuation.separator.sequence.haskell --- ^^^^^ variable.function.infix.haskell +-- ^^^^^ meta.group.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^^^ keyword.operator.haskell +-- ^ punctuation.section.group.end.haskell -- ^ punctuation.separator.sequence.haskell -- ^^^^ variable.function.haskell -- ^ punctuation.separator.sequence.haskell @@ -753,7 +760,10 @@ -- ^^^^^^ keyword.declaration.export.haskell -- ^^^^^ constant.language.convention.haskell -- ^^^^^^^^ meta.string.haskell string.quoted.double.haskell --- ^^^ variable.function.infix.haskell +-- ^^^ meta.group.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^ keyword.operator.haskell +-- ^ punctuation.section.group.end.haskell -- ^^ keyword.operator.double-colon.haskell -- ^^^ support.type.prelude.haskell -- ^^ keyword.operator.arrow.haskell @@ -818,7 +828,10 @@ -- ^^^^^^ keyword.declaration.import.haskell -- ^^^^^ constant.language.convention.haskell -- ^^^^^^^^ meta.string.haskell string.quoted.double.haskell --- ^^^ variable.function.infix.haskell +-- ^^^ meta.group.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^ keyword.operator.haskell +-- ^ punctuation.section.group.end.haskell -- ^^ keyword.operator.double-colon.haskell -- ^^^ support.type.prelude.haskell -- ^^ keyword.operator.arrow.haskell @@ -1186,7 +1199,10 @@ data BuilderType = Builder { (>>=) :: forall m a b. Unrestricted.Monad m => m a -> (a -> m b) -> m b --- ^^^^^ variable.function.infix.haskell +-- ^^^^^ meta.block.haskell meta.group.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^^^ keyword.operator.haskell +-- ^ punctuation.section.group.end.haskell -- ^^ keyword.operator.double-colon.haskell -- ^^^^^^ keyword.control.forall.haskell -- ^ keyword.operator.haskell @@ -1195,7 +1211,10 @@ -- ^^^^^ support.class.prelude.haskell , (>>) :: forall m b . Unrestricted.Monad m => m() -> m b -> m b -- ^ punctuation.separator.sequence.haskell --- ^^^^ variable.function.infix.haskell +-- ^^^^ meta.block.haskell meta.group.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^^ keyword.operator.haskell +-- ^ punctuation.section.group.end.haskell -- ^^ keyword.operator.double-colon.haskell -- ^^^^^^ keyword.control.forall.haskell -- ^ keyword.operator.haskell @@ -1774,8 +1793,8 @@ {- infix operator declaration -} (<:>) --- ^^^^^^ meta.function.identifier.haskell --- ^^^^^ entity.name.function.infix.haskell +-- ^^^^^ meta.function.identifier.haskell meta.group.haskell +-- ^ meta.function.identifier.haskell - meta.group -- ^^^ keyword.operator.haskell :: a -> Bool -- ^ meta.function.identifier.haskell @@ -3166,44 +3185,74 @@ main = do a a = (+) a 2 -- ^ keyword.operator.haskell --- ^^^ variable.function.infix.haskell +-- ^^^ meta.group.haskell +-- ^ punctuation.section.group.begin.haskell -- ^ keyword.operator.haskell +-- ^ punctuation.section.group.end.haskell -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell a a = ( + ) a 2 -- ^ keyword.operator.haskell --- ^^^^^ variable.function.infix.haskell +-- ^^^^^ meta.group.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^ - punctuation - keyword -- ^ keyword.operator.haskell +-- ^ - punctuation - keyword +-- ^ punctuation.section.group.end.haskell -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell a a = (-) a 2 -- ^ keyword.operator.haskell --- ^^^ variable.function.infix.haskell +-- ^^^ meta.group.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^ keyword.operator.haskell +-- ^ punctuation.section.group.end.haskell -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell a a = ( - ) a 2 -- ^ keyword.operator.haskell --- ^^^^^ variable.function.infix.haskell +-- ^^^^^ meta.group.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^ - punctuation - keyword +-- ^ keyword.operator.haskell +-- ^ - punctuation - keyword +-- ^ punctuation.section.group.end.haskell -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell a a = (*) a 2 -- ^ keyword.operator.haskell --- ^^^ variable.function.infix.haskell +-- ^^^ meta.group.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^ keyword.operator.haskell +-- ^ punctuation.section.group.end.haskell -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell a a = ( * ) a 2 -- ^ keyword.operator.haskell --- ^^^^^ variable.function.infix.haskell +-- ^^^^^ meta.group.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^ - punctuation - keyword +-- ^ keyword.operator.haskell +-- ^ - punctuation - keyword +-- ^ punctuation.section.group.end.haskell -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell a a = (/) a 2 -- ^ keyword.operator.haskell --- ^^^ variable.function.infix.haskell +-- ^^^ meta.group.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^ keyword.operator.haskell +-- ^ punctuation.section.group.end.haskell -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell a a = ( / ) a 2 -- ^ keyword.operator.haskell --- ^^^^^ variable.function.infix.haskell +-- ^^^^^ meta.group.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^ - punctuation - keyword +-- ^ keyword.operator.haskell +-- ^ - punctuation - keyword +-- ^ punctuation.section.group.end.haskell -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell a a = (--) a 2 @@ -3279,13 +3328,40 @@ main = do genOutrageous = Gen.recursive Gen.choice [ Flipper <$> genRecord +-- ^^^ keyword.operator.haskell , (:!) <$> genInt <*> genInt +-- ^ punctuation.separator.sequence.haskell +-- ^^^^ meta.sequence.list.haskell meta.group.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^^ keyword.operator.haskell +-- ^ punctuation.section.group.end.haskell +-- ^^^ keyword.operator.haskell +-- ^^^ keyword.operator.haskell , (:@) <$> genDouble <*> genDouble --- ^^ variable.function.infix.haskell keyword.operator.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^ meta.sequence.list.haskell meta.group.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^^ keyword.operator.haskell +-- ^ punctuation.section.group.end.haskell +-- ^^^ keyword.operator.haskell +-- ^^^ keyword.operator.haskell , Quux <$> genInt <*> genDouble +-- ^ punctuation.separator.sequence.haskell +-- ^^^^ storage.type.haskell +-- ^^^ keyword.operator.haskell +-- ^^^ keyword.operator.haskell , (:#) <$> genString <*> genRecord --- ^^ variable.function.infix.haskell keyword.operator.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^ meta.sequence.list.haskell meta.group.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^^ keyword.operator.haskell +-- ^ punctuation.section.group.end.haskell +-- ^^^ keyword.operator.haskell +-- ^^^ keyword.operator.haskell , DontDoThis <$> genInt <*> genString +-- ^ punctuation.separator.sequence.haskell +-- ^^^ keyword.operator.haskell +-- ^^^ keyword.operator.haskell ] [ Gen.subtermM genOutrageous (\x -> (:$) <$> genSimple <*> pure x) ] From 8395640d9b3fa89e2de823dde3ebd9b8fb57ba11 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 1 Jan 2021 12:36:36 +0100 Subject: [PATCH 127/178] [Haskell] Add tests for `let` expressions This commit adds some tests to illustrate some sophisticated situations which would need to be handled in a more complex implementation. --- Haskell/syntax_test_haskell.hs | 127 ++++++++++++++++++++++++++++++++- 1 file changed, 126 insertions(+), 1 deletion(-) diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index bc94a29861..48a2f63b10 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -2017,17 +2017,142 @@ } --- [ KEYWORDS ] --------------------------------------------------------------- +-- [ LET EXPRESSIONS ]--------------------------------------------------------- + + let a +-- ^^^ keyword.declaration.variable.haskell +-- ^ variable.other.haskell + + let a = 5 +-- ^^^ keyword.declaration.variable.haskell +-- ^ variable.other.haskell +-- ^ keyword.operator.haskell +-- ^ constant.numeric.value.haskell + + let (a, b) = split arg +-- ^^^ keyword.declaration.variable.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ variable.other.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^ variable.other.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^ keyword.operator.haskell +-- ^^^^^ variable.other.haskell +-- ^^^ variable.other.haskell + + let a = 2 in a * b where b = 1 +-- ^^^ keyword.declaration.variable.haskell +-- ^ variable.other.haskell +-- ^ keyword.operator.haskell +-- ^ constant.numeric.value.haskell +-- ^^ keyword.control.context.haskell +-- ^ variable.other.haskell +-- ^ keyword.operator.haskell +-- ^ variable.other.haskell +-- ^^^^^ keyword.control.context.haskell +-- ^ variable.other.haskell +-- ^ keyword.operator.haskell +-- ^ constant.numeric.value.haskell + + let +-- ^^^ keyword.declaration.variable.haskell + a = 2 ; d = 5 +-- ^ variable.other.haskell +-- ^ keyword.operator.haskell +-- ^ constant.numeric.value.haskell +-- ^ punctuation.terminator.statement.haskell +-- ^ variable.other.haskell +-- ^ keyword.operator.haskell +-- ^ constant.numeric.value.haskell + b = 4 +-- ^ variable.other.haskell +-- ^ keyword.operator.haskell +-- ^ constant.numeric.value.haskell + in +-- ^^ keyword.control.context.haskell + a * b + c +-- ^ variable.other.haskell +-- ^ keyword.operator.haskell +-- ^ variable.other.haskell +-- ^ keyword.operator.haskell +-- ^ variable.other.haskell + where +-- ^^^^^ keyword.control.context.haskell + c = 4 +-- ^ variable.other.haskell +-- ^ keyword.operator.haskell +-- ^ constant.numeric.value.haskell + + let { a = 2 ; b = 4 } in { a * b + c } where { c = 4 ; d = 5 } +-- ^^^ keyword.declaration.variable.haskell +-- ^ punctuation.section.block.begin.haskell +-- ^ variable.other.haskell +-- ^ keyword.operator.haskell +-- ^ constant.numeric.value.haskell +-- ^ punctuation.terminator.statement.haskell +-- ^ variable.other.haskell +-- ^ keyword.operator.haskell +-- ^ constant.numeric.value.haskell +-- ^ punctuation.section.block.end.haskell +-- ^^ keyword.control.context.haskell +-- ^ punctuation.section.block.begin.haskell +-- ^ variable.other.haskell +-- ^ keyword.operator.haskell +-- ^ variable.other.haskell +-- ^ keyword.operator.haskell +-- ^ variable.other.haskell +-- ^ punctuation.section.block.end.haskell +-- ^^^^^ keyword.control.context.haskell +-- ^ punctuation.section.block.begin.haskell +-- ^ variable.other.haskell +-- ^ keyword.operator.haskell +-- ^ constant.numeric.value.haskell +-- ^ punctuation.terminator.statement.haskell +-- ^ variable.other.haskell +-- ^ keyword.operator.haskell +-- ^ constant.numeric.value.haskell +-- ^ punctuation.section.block.end.haskell test = +-- <- variable.other.haskell -- ^ keyword.operator.haskell let x = 2 in x * y -- ^^^ keyword.declaration.variable.haskell +-- ^ variable.other.haskell +-- ^ keyword.operator.haskell +-- ^ constant.numeric.value.haskell -- ^^ keyword.control.context.haskell +-- ^ variable.other.haskell +-- ^ keyword.operator.haskell +-- ^ variable.other.haskell where -- ^^^^^ keyword.control.context.haskell y = 1 +-- ^ variable.other.haskell -- ^ keyword.operator.haskell +-- ^ constant.numeric.value.haskell + + let runIO' :: PandocIO a -> IO a +--^^^ keyword.declaration.variable.haskell +-- ^^^^^^^ meta.function.identifier.haskell +-- ^^^^^^ entity.name.function.haskell +-- ^^ keyword.operator.double-colon.haskell + runIO' f = do + let isWarning msg = messageVerbosity msg == WARNING +-- ^^^ keyword.declaration.variable.haskell +-- ^^^^^^^^^ variable.other.haskell +-- ^^^ variable.other.haskell +-- ^ keyword.operator.haskell +-- ^^^^^^^^^^^^^^^^ variable.other.haskell +-- ^^^ variable.other.haskell +-- ^^ keyword.operator.haskell +-- ^^^^^^^ storage.type.haskell + when (optFailIfWarnings opts && any isWarning reports) $ + E.throwIO PandocFailOnWarningError + return res + + +-- [ KEYWORDS ] --------------------------------------------------------------- test a = case a of -- ^^^^ keyword.control.conditional.select.haskell From 163d6a17eeb3bda7c8555b158e5dc763a63f0e23 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 1 Jan 2021 12:41:52 +0100 Subject: [PATCH 128/178] [Haskell] Add some real world function declaration tests This is to illustrate what complex constructs need to be handled well. --- Haskell/syntax_test_haskell.hs | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 48a2f63b10..8b502af155 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -1871,6 +1871,43 @@ -- ^^^^ support.function.prelude.haskell -- ^ variable.other.haskell + {- guarded function declarations -} + toAsciiChar :: Char -> Maybe Char + toAsciiChar c | isAscii c = Just c +-- ^^^^^^^^^^^ variable.other.haskell +-- ^ variable.other.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^ variable.other.haskell +-- ^ variable.other.haskell +-- ^ keyword.operator.haskell +-- ^^^^ support.type.prelude.haskell +-- ^ variable.other.haskell + | otherwise = M.lookup c asciiMap +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^^^ support.function.prelude.haskell +-- ^ keyword.operator.haskell +-- ^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ support.function.prelude.haskell +-- ^ variable.other.haskell +-- ^^^^^^^^ variable.other.haskell + + fromEntities' :: Text -> String +-- ^^^^^^^^^^^^^ entity.name.function.haskell + fromEntities' (T.uncons -> Just ('&', xs)) = +-- ^^^^^^^^^^^^^ variable.other.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.haskell +-- ^ keyword.operator.haskell + case lookupEntity $ T.unpack ent' of + Just c -> c <> fromEntities' rest + Nothing -> "&" <> fromEntities' xs + fromEntities' t = case T.uncons t of +-- ^^^^^^^^^^^^^ variable.other.haskell +-- ^ variable.other.haskell +-- ^ keyword.operator.haskell + Just (x, xs) -> x : fromEntities' xs + Nothing -> "" + {- Module Level Function Declarations -} module ModId.ModName (fun) where fun :: Bool -> Bool From 0c1f8c518e2f20a79e73b734cffac91bd0e8de8a Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 1 Jan 2021 14:05:28 +0100 Subject: [PATCH 129/178] [Haskell] Highlight SPECIALIZE pragma values --- Haskell/Haskell.sublime-syntax | 19 ++++++++++++++++++- Haskell/syntax_test_haskell.hs | 7 ++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index c767323f83..7b933429c8 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -1,5 +1,6 @@ %YAML 1.2 --- +# https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts.html # https://www.haskell.org/onlinereport/haskell2010 # https://www.sublimetext.com/docs/syntax.html name: Haskell @@ -286,6 +287,16 @@ contexts: - match: (?:OPTIONS_GHC|OPTIONS_HADDOCK){{break}} scope: keyword.directive.options.haskell set: preprocessor-pragma-options-value + - match: (?:SPECIALISE|SPECIALIZE){{break}} + scope: + meta.preprocessor.pragma.directive.haskell + keyword.directive.builtin.haskell + embed: preprocessor-pragma-specialize-value + pop: 1 + escape: '#-\}' + escape_captures: + 0: meta.preprocessor.pragma.value.haskell + punctuation.section.preprocessor.end.haskell - match: '{{pragma_keys}}' scope: keyword.directive.builtin.haskell set: preprocessor-pragma-other-value @@ -312,11 +323,17 @@ contexts: captures: 1: punctuation.definition.constant.haskell + preprocessor-pragma-specialize-value: + - meta_include_prototype: false + - meta_content_scope: meta.preprocessor.pragma.value.specialize.haskell + - include: comments + - include: functions + - include: type-expressions + preprocessor-pragma-other-value: - meta_include_prototype: false - meta_content_scope: meta.preprocessor.pragma.value.other.haskell - include: preprocessor-pragma-common - - include: sequence-separators - include: literal-numbers - include: literal-strings diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 8b502af155..8cbfceb752 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -198,10 +198,15 @@ {-# SPECIALISE unless :: Bool -> IO () -> IO () #-} -- ^^^^^^^^^^^^^^ meta.preprocessor.pragma.directive.haskell --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.pragma.value.other.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.pragma.value.specialize.haskell -- ^^^ meta.preprocessor.pragma.value.haskell -- ^^^ punctuation.section.preprocessor.begin.haskell -- ^^^^^^^^^^ keyword.directive.builtin.haskell +-- ^^^^^^ entity.name.function.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^^^^ support.type.prelude.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^^ support.type.prelude.haskell -- ^^^ punctuation.section.preprocessor.end.haskell {-# WARNING "Not supported" #-} From c79366407f9ebf03add9770560b7954a44b74746 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 1 Jan 2021 14:24:57 +0100 Subject: [PATCH 130/178] [Haskell] Scope exported symbols `entity.name.export` This commit scopes all exported entities the same way so that we can create an "Symbol List - Exports". We don't care about a possible type an exported symbol is of. Note: ST doesn't provide kind info in Goto Symbol Quick Panels so far. --- Haskell/Haskell.sublime-syntax | 11 +++++++---- Haskell/Symbol List - Exports.tmPreferences | 14 ++++++++++++++ Haskell/syntax_test_haskell.hs | 16 ++++++++-------- 3 files changed, 29 insertions(+), 12 deletions(-) create mode 100644 Haskell/Symbol List - Exports.tmPreferences diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 7b933429c8..ada2578d6f 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -385,15 +385,18 @@ contexts: - include: tuple-end - include: infix-parens-operators - include: sequence-separators + - include: ident-namespaces - match: \( scope: punctuation.section.sequence.begin.haskell push: module-export-body - match: module{{break}} scope: keyword.declaration.namespace.haskell - push: module-name - - include: ident-functions - - include: ident-namespaces - - include: ident-types + # class / constructor / data / module / type + - match: '{{con_id}}' + scope: entity.name.export.haskell + # function / pattern / variable + - match: '{{var_id}}' + scope: entity.name.export.haskell - include: else-pop signature-where: diff --git a/Haskell/Symbol List - Exports.tmPreferences b/Haskell/Symbol List - Exports.tmPreferences new file mode 100644 index 0000000000..ab0061905c --- /dev/null +++ b/Haskell/Symbol List - Exports.tmPreferences @@ -0,0 +1,14 @@ + + + + scope + meta.declaration.module.haskell entity.name.export.haskell + settings + + showInSymbolList + 1 + showInIndexedSymbolList + 1 + + + diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 8cbfceb752..ba2dbfa448 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -293,9 +293,9 @@ -- ^ punctuation.accessor.dot.haskell -- ^^^^ entity.name.namespace.haskell -- ^ punctuation.section.sequence.begin.haskell --- ^^^^ variable.function.haskell +-- ^^^^ entity.name.export.haskell -- ^ punctuation.separator.sequence.haskell --- ^^^^ storage.type.haskell +-- ^^^^ entity.name.export.haskell -- ^ punctuation.section.sequence.end.haskell -- ^^^^^ keyword.control.context.haskell -- ^ punctuation.section.block.begin.haskell @@ -325,7 +325,7 @@ -- ^^^^^^ keyword.declaration.namespace.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ entity.name.namespace.haskell +-- ^^^^^^ entity.name.export.haskell -- ^ punctuation.section.sequence.end.haskell -- ^^^^^ keyword.control.context.haskell -- ^ punctuation.section.block.begin.haskell @@ -399,9 +399,9 @@ -- ^ punctuation.accessor.dot.haskell -- ^^^^ entity.name.namespace.haskell -- ^ punctuation.section.sequence.begin.haskell --- ^^^^ variable.function.haskell +-- ^^^^ entity.name.export.haskell -- ^ punctuation.separator.sequence.haskell --- ^^^^ storage.type.haskell +-- ^^^^ entity.name.export.haskell -- ^ punctuation.section.sequence.end.haskell -- ^^^^^ keyword.control.context.haskell -- ^ punctuation.section.block.begin.haskell @@ -431,7 +431,7 @@ -- ^^^^^^ keyword.declaration.namespace.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ entity.name.namespace.haskell +-- ^^^^^^ entity.name.export.haskell -- ^ punctuation.section.sequence.end.haskell -- ^^^^^ keyword.control.context.haskell -- ^ punctuation.section.block.begin.haskell @@ -1924,9 +1924,9 @@ module ModId.ModName (fun1, fun2) where { fun1 :: Bool -> Bool ; fun2 :: } -- ^^^^^^^^^^^^ meta.declaration.module.haskell meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell --- ^^^^ variable.function.haskell +-- ^^^^ entity.name.export.haskell -- ^ punctuation.separator.sequence.haskell --- ^^^^ variable.function.haskell +-- ^^^^ entity.name.export.haskell -- ^ punctuation.section.sequence.end.haskell -- ^^^^^ keyword.control.context.haskell -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.haskell From ffdfde96fde34ecf575be119785a3f6b49439507 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 1 Jan 2021 15:01:16 +0100 Subject: [PATCH 131/178] [Haskell] Rework import statements This commit... 1. Adds detailed `meta.import.[module|alias|filter]` scopes to each import term. 2. Scopes the whole import module identifier `variable.namespace` because `entity.name.namespace` caused all imports to be globally indexed, which is obviously not useful and correct. 3. Scopes all kinds of imported symbols `entity.name.import` without respect of their possible type. --- Haskell/Haskell.sublime-syntax | 54 ++++-- Haskell/Symbol List - Imports.tmPreferences | 14 ++ Haskell/syntax_test_haskell.hs | 190 +++++++++++--------- 3 files changed, 156 insertions(+), 102 deletions(-) create mode 100644 Haskell/Symbol List - Imports.tmPreferences diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index ada2578d6f..bceb8f2dc2 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -431,26 +431,42 @@ contexts: # 5.3 Import Declarations # https://www.haskell.org/onlinereport/haskell2010/haskellch5.html#x11-1010005.3 - match: import{{break}} - scope: keyword.declaration.import.haskell + scope: meta.import.haskell keyword.declaration.import.haskell push: - - import-meta - - import-body + - import-filter + - import-module + + import-module: + - meta_content_scope: meta.import.module.haskell + - match: as{{break}} + scope: keyword.declaration.import.as.haskell + set: import-alias + - match: (?:qualified|hiding){{break}} + scope: storage.modifier.import.haskell + - match: ({{con_id}})(\.)? + captures: + 1: variable.namespace.haskell + 2: punctuation.accessor.dot.haskell + - include: else-pop - import-meta: - - meta_include_prototype: false - - meta_scope: meta.import.haskell - - include: immediatelly-pop + import-alias: + - meta_scope: meta.import.alias.haskell + - include: ident-namespaces + - match: '{{con_id}}' + scope: entity.name.import.namespace.haskell + pop: 1 + - include: else-pop - import-body: + import-filter: - match: \( scope: punctuation.section.sequence.begin.haskell - set: import-tuple-body - - match: (?:qualified|as|hiding){{break}} - scope: storage.modifier.import.haskell - - include: ident-namespaces - - include: ident-modules + set: import-filter-body - include: else-pop + import-filter-body: + - meta_scope: meta.import.filter.haskell meta.sequence.tuple.haskell + - include: import-tuple-body + import-tuple-body: - meta_scope: meta.sequence.tuple.haskell - include: tuple-end @@ -463,8 +479,12 @@ contexts: scope: invalid.illegal.accessor.haskell - match: module{{break}} scope: invalid.illegal.unexpected-keyword.haskell - - include: ident-functions - - include: ident-types + # class / constructor / data / module / type + - match: '{{con_id}}' + scope: entity.name.import.haskell + # function / pattern / variable + - match: '{{var_id}}' + scope: entity.name.import.haskell - include: else-pop ###[ FOREIGN DECLARATIONS ]#################################################### @@ -925,10 +945,6 @@ contexts: 1: variable.namespace.haskell 2: punctuation.accessor.dot.haskell - ident-modules: - - match: '{{con_id}}' - scope: entity.name.namespace.haskell - ident-module: - match: '{{con_id}}' scope: entity.name.namespace.haskell diff --git a/Haskell/Symbol List - Imports.tmPreferences b/Haskell/Symbol List - Imports.tmPreferences new file mode 100644 index 0000000000..36309a991f --- /dev/null +++ b/Haskell/Symbol List - Imports.tmPreferences @@ -0,0 +1,14 @@ + + + + scope + source.haskell meta.import entity.name.import + settings + + showInSymbolList + 1 + showInIndexedSymbolList + 0 + + + diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index ba2dbfa448..c767c1a144 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -302,12 +302,12 @@ -- ^^^^^^ keyword.declaration.import.haskell -- ^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^ entity.name.namespace.haskell +-- ^^^^^ variable.namespace.haskell -- ^ punctuation.terminator.statement.haskell -- ^^^^^^ keyword.declaration.import.haskell -- ^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ entity.name.namespace.haskell +-- ^^^^^^ variable.namespace.haskell -- ^ punctuation.section.block.end.haskell module Name (module Other.Module) where { import Other.Module } @@ -316,7 +316,8 @@ -- ^ meta.declaration.module.haskell - meta.sequence -- ^^^^^^ - meta.declaration - meta.block - meta.sequence -- ^^ meta.block.haskell - meta.import --- ^^^^^^^^^^^^^^^^^^^^ meta.block.haskell meta.import.haskell +-- ^^^^^^ meta.block.haskell meta.import.haskell +-- ^^^^^^^^^^^^^^ meta.block.haskell meta.import.module.haskell -- ^ meta.block.haskell - meta.import -- ^ - meta.declaration - meta.block -- ^^^^^^ keyword.declaration.namespace.haskell @@ -332,7 +333,7 @@ -- ^^^^^^ keyword.declaration.import.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ entity.name.namespace.haskell +-- ^^^^^^ variable.namespace.haskell -- ^ punctuation.section.block.end.haskell @@ -408,12 +409,12 @@ -- ^^^^^^ keyword.declaration.import.haskell -- ^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^ entity.name.namespace.haskell +-- ^^^^^ variable.namespace.haskell -- ^ punctuation.terminator.statement.haskell -- ^^^^^^ keyword.declaration.import.haskell -- ^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ entity.name.namespace.haskell +-- ^^^^^^ variable.namespace.haskell -- ^ punctuation.section.block.end.haskell signature Name (module Other.Module) where { import Other.Module } @@ -422,7 +423,8 @@ -- ^ meta.declaration.signature.haskell - meta.sequence -- ^^^^^^ - meta.declaration - meta.block - meta.sequence -- ^^ meta.block.haskell - meta.import --- ^^^^^^^^^^^^^^^^^^^^ meta.block.haskell meta.import.haskell +-- ^^^^^^ meta.block.haskell meta.import.haskell +-- ^^^^^^^^^^^^^^ meta.block.haskell meta.import.module.haskell -- ^ meta.block.haskell - meta.import -- ^ - meta.declaration - meta.block -- ^^^^^^^^^ keyword.declaration.namespace.haskell @@ -438,7 +440,7 @@ -- ^^^^^^ keyword.declaration.import.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ entity.name.namespace.haskell +-- ^^^^^^ variable.namespace.haskell -- ^ punctuation.section.block.end.haskell -- [ IMPORT DECLARATIONS ] ---------------------------------------------------- @@ -452,152 +454,163 @@ import import -- ^ - meta.import --- ^^^^^^^^^^^^^^ meta.import.haskell --- ^^^^^^ keyword.declaration.import.haskell --- ^^^^^^ keyword.declaration.import.haskell +-- ^^^^^^ meta.import.haskell keyword.declaration.import.haskell +-- ^ meta.import.module.haskell - keyword +-- ^^^^^^ meta.import.haskell keyword.declaration.import.haskell +-- ^ meta.import.module.haskell - keyword import ; import --- ^^^^^^^ meta.import.haskell +-- ^^^^^^ meta.import.haskell +-- ^ meta.import.module.haskell -- ^^ - meta.import --- ^^^^^^^ meta.import.haskell +-- ^^^^^^ meta.import.haskell +-- ^ meta.import.module.haskell -- ^^^^^^ keyword.declaration.import.haskell -- ^ punctuation.terminator.statement.haskell -- ^^^^^^ meta.import.haskell keyword.declaration.import.haskell import qualified Data.Vector.Mutable as MutableVector --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^^^^ meta.import.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.module.haskell +-- ^^^^^^^^^^^^^^^^ meta.import.alias.haskell -- ^^^^^^ keyword.declaration.import.haskell -- ^^^^^^^^^ storage.modifier.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^^ entity.name.namespace.haskell - punctuation --- ^^ storage.modifier.import.haskell --- ^^^^^^^^^^^^^ entity.name.namespace.haskell +-- ^^^^^^^ variable.namespace.haskell - punctuation +-- ^^ keyword.declaration.import.as.haskell +-- ^^^^^^^^^^^^^ entity.name.import.namespace.haskell import --- ^^^^^^^ meta.import.haskell --- ^^^^^^ keyword.declaration.import.haskell +-- ^^^^^^ meta.import.haskell keyword.declaration.import.haskell +-- ^ meta.import.module.haskell - keyword qualified --- ^^^^^^^^^^ meta.import.haskell +-- ^^^^^^^^^^ meta.import.module.haskell -- ^^^^^^^^^ storage.modifier.import.haskell Data.Vector.Mutable --- ^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^^^^^^^^^^^^^^^^^^ meta.import.module.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^^ entity.name.namespace.haskell - punctuation +-- ^^^^^^^ variable.namespace.haskell - punctuation as --- ^^^ meta.import.haskell --- ^^ storage.modifier.import.haskell +-- ^^^ meta.import.alias.haskell +-- ^^ keyword.declaration.import.as.haskell MutableVector --- ^^^^^^^^^^^^^^ meta.import.haskell --- ^^^^^^^^^^^^^ entity.name.namespace.haskell +-- ^^^^^^^^^^^^^ meta.import.alias.haskell entity.name.import.namespace.haskell +-- ^ - meta.import - entity import Mod1.Mod2.Module (funcName) --- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell - meta.sequence --- ^^^^^^^^^^ meta.import.haskell meta.sequence.tuple.haskell +-- ^^^^^^ meta.import.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^ meta.import.module.haskell - meta.sequence +-- ^^^^^^^^^^ meta.import.filter.haskell meta.sequence.tuple.haskell -- ^ - meta.import -- ^^^^^^ keyword.declaration.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^ entity.name.namespace.haskell - punctuation +-- ^^^^^^ variable.namespace.haskell - punctuation -- ^^^^^^^^^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell --- ^^^^^^^^ variable.function.haskell +-- ^^^^^^^^ entity.name.import.haskell -- ^ punctuation.section.sequence.end.haskell import Mod1.Mod2.Module (ClassName(..)) --- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell - meta.sequence --- ^^^^^^^^^^ meta.import.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence --- ^^^^ meta.import.haskell meta.sequence.tuple.haskell meta.group.haskell --- ^ meta.import.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence +-- ^^^^^^ meta.import.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^ meta.import.module.haskell - meta.sequence +-- ^^^^^^^^^^ meta.import.filter.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence +-- ^^^^ meta.import.filter.haskell meta.sequence.tuple.haskell meta.group.haskell +-- ^ meta.import.filter.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence -- ^ - meta.import -- ^^^^^^ keyword.declaration.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^ entity.name.namespace.haskell - punctuation +-- ^^^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.section.sequence.begin.haskell --- ^^^^^^^^^ storage.type.haskell +-- ^^^^^^^^^ entity.name.import.haskell -- ^ punctuation.section.group.begin.haskell -- ^^ keyword.operator.haskell -- ^ punctuation.section.group.end.haskell -- ^ punctuation.section.sequence.end.haskell import Mod1.Mod2.Module (ClassName (SubClass), funcName) --- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell - meta.sequence --- ^^^^^^^^^^^ meta.import.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence --- ^^^^^^^^^^ meta.import.haskell meta.sequence.tuple.haskell meta.sequence.tuple.haskell --- ^^^^^^^^^^^ meta.import.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence +-- ^^^^^^ meta.import.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^ meta.import.module.haskell - meta.sequence +-- ^^^^^^^^^^^ meta.import.filter.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence +-- ^^^^^^^^^^ meta.import.filter.haskell meta.sequence.tuple.haskell meta.sequence.tuple.haskell +-- ^^^^^^^^^^^ meta.import.filter.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence -- ^ - meta.import -- ^^^^^^ keyword.declaration.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^ entity.name.namespace.haskell - punctuation +-- ^^^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.section.sequence.begin.haskell --- ^^^^^^^^^ storage.type.haskell +-- ^^^^^^^^^ entity.name.import.haskell -- ^ punctuation.section.sequence.begin.haskell --- ^^^^^^^^ storage.type.haskell +-- ^^^^^^^^ entity.name.import.haskell -- ^ punctuation.section.sequence.end.haskell -- ^ punctuation.separator.sequence.haskell --- ^^^^^^^^ variable.function.haskell +-- ^^^^^^^^ entity.name.import.haskell -- ^ punctuation.section.sequence.end.haskell import Mod1.Mod2.Module (ClassName (memberName), funcName) --- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell - meta.sequence --- ^^^^^^^^^^^ meta.import.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence --- ^^^^^^^^^^^^ meta.import.haskell meta.sequence.tuple.haskell meta.sequence.tuple.haskell --- ^^^^^^^^^^^ meta.import.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence +-- ^^^^^^ meta.import.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^ meta.import.module.haskell - meta.sequence +-- ^^^^^^^^^^^ meta.import.filter.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence +-- ^^^^^^^^^^^^ meta.import.filter.haskell meta.sequence.tuple.haskell meta.sequence.tuple.haskell +-- ^^^^^^^^^^^ meta.import.filter.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence -- ^ - meta.import -- ^^^^^^ keyword.declaration.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^ entity.name.namespace.haskell - punctuation +-- ^^^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.section.sequence.begin.haskell --- ^^^^^^^^^ storage.type.haskell +-- ^^^^^^^^^ entity.name.import.haskell -- ^ punctuation.section.sequence.begin.haskell --- ^^^^^^^^^^ variable.function.haskell +-- ^^^^^^^^^^ entity.name.import.haskell -- ^ punctuation.section.sequence.end.haskell -- ^ punctuation.separator.sequence.haskell --- ^^^^^^^^ variable.function.haskell +-- ^^^^^^^^ entity.name.import.haskell -- ^ punctuation.section.sequence.end.haskell import Mod1.Mod2.Module (ClassName (SubClass, memberName), funcName) --- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell - meta.sequence --- ^^^^^^^^^^^ meta.import.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence --- ^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell meta.sequence.tuple.haskell meta.sequence.tuple.haskell --- ^^^^^^^^^^^ meta.import.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence +-- ^^^^^^ meta.import.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^ meta.import.module.haskell - meta.sequence +-- ^^^^^^^^^^^ meta.import.filter.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.import.filter.haskell meta.sequence.tuple.haskell meta.sequence.tuple.haskell +-- ^^^^^^^^^^^ meta.import.filter.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence -- ^ - meta.import -- ^^^^^^ keyword.declaration.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^ entity.name.namespace.haskell - punctuation +-- ^^^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.section.sequence.begin.haskell --- ^^^^^^^^^ storage.type.haskell +-- ^^^^^^^^^ entity.name.import.haskell -- ^ punctuation.section.sequence.begin.haskell --- ^^^^^^^^ storage.type.haskell +-- ^^^^^^^^ entity.name.import.haskell -- ^ punctuation.separator.sequence.haskell --- ^^^^^^^^^^ variable.function.haskell +-- ^^^^^^^^^^ entity.name.import.haskell -- ^ punctuation.section.sequence.end.haskell -- ^ punctuation.separator.sequence.haskell --- ^^^^^^^^ variable.function.haskell +-- ^^^^^^^^ entity.name.import.haskell -- ^ punctuation.section.sequence.end.haskell import Mod1.Mod2.Module ((), (<.>), fun1, fun2, --- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell - meta.sequence --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence +-- ^^^^^^ meta.import.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^ meta.import.module.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.filter.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence -- ^ punctuation.section.sequence.begin.haskell -- ^^^^^ meta.group.haskell -- ^ punctuation.section.group.begin.haskell @@ -609,42 +622,45 @@ -- ^^^ keyword.operator.haskell -- ^ punctuation.section.group.end.haskell -- ^ punctuation.separator.sequence.haskell --- ^^^^ variable.function.haskell +-- ^^^^ entity.name.import.haskell -- ^ punctuation.separator.sequence.haskell --- ^^^^ variable.function.haskell +-- ^^^^ entity.name.import.haskell -- ^ punctuation.separator.sequence.haskell fun3, fun4) --- ^^^^^^^^^^^ meta.import.haskell meta.sequence.tuple.haskell +-- ^^^^^^^^^^^ meta.import.filter.haskell meta.sequence.tuple.haskell -- ^ - meta.import --- ^^^^ variable.function.haskell +-- ^^^^ entity.name.import.haskell -- ^ punctuation.separator.sequence.haskell --- ^^^^ variable.function.haskell +-- ^^^^ entity.name.import.haskell -- ^ punctuation.section.sequence.end.haskell import Mod1.Mod2.Module (()) --- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell - meta.sequence --- ^ meta.import.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence --- ^^ meta.import.haskell meta.sequence.tuple.haskell meta.sequence.tuple.haskell --- ^ meta.import.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence +-- ^^^^^^ meta.import.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^ meta.import.module.haskell - meta.sequence +-- ^ meta.import.filter.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence +-- ^^ meta.import.filter.haskell meta.sequence.tuple.haskell meta.sequence.tuple.haskell +-- ^ meta.import.filter.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence -- ^ - meta.import -- ^^^^^^ keyword.declaration.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^ entity.name.namespace.haskell - punctuation +-- ^^^^^^ variable.namespace.haskell - punctuation -- ^^^^ meta.sequence.tuple.haskell -- ^^ punctuation.section.sequence.begin.haskell -- ^^ punctuation.section.sequence.end.haskell import Mod1.Mod2.Module (-- --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^^^^ meta.import.haskell +-- ^^^^^^^^^^^^^^^^^^ meta.import.module.haskell +-- ^^^^ meta.import.filter.haskell meta.sequence.tuple.haskell -- ^^^^^^ keyword.declaration.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^ entity.name.namespace.haskell - punctuation +-- ^^^^^^ variable.namespace.haskell - punctuation -- ^^^^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^ comment.line.double-dash.haskell @@ -653,13 +669,15 @@ -- ^ punctuation.section.sequence.end.haskell import Mod1.Mod2.Module (--) --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^^^^ meta.import.haskell +-- ^^^^^^^^^^^^^^^^^^ meta.import.module.haskell +-- ^^^^^ meta.import.filter.haskell meta.sequence.tuple.haskell -- ^^^^^^ keyword.declaration.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^ entity.name.namespace.haskell - punctuation +-- ^^^^^^ variable.namespace.haskell - punctuation -- ^^^^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^^ comment.line.double-dash.haskell @@ -668,13 +686,15 @@ -- ^ punctuation.section.sequence.end.haskell import Mod1.Mod2.Module ((--)) --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^^^^ meta.import.haskell +-- ^^^^^^^^^^^^^^^^^^ meta.import.module.haskell +-- ^^^^^^^ meta.import.filter.haskell meta.sequence.tuple.haskell -- ^^^^^^ keyword.declaration.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^ entity.name.namespace.haskell - punctuation +-- ^^^^^^ variable.namespace.haskell - punctuation -- ^^^^^^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^^^ comment.line.double-dash.haskell @@ -683,13 +703,15 @@ -- ^ punctuation.section.sequence.end.haskell import Mod1.Mod2.Module ((--]) --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^^^^ meta.import.haskell +-- ^^^^^^^^^^^^^^^^^^ meta.import.module.haskell +-- ^^^^^^^ meta.import.filter.haskell meta.sequence.tuple.haskell -- ^^^^^^ keyword.declaration.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^ entity.name.namespace.haskell - punctuation +-- ^^^^^^ variable.namespace.haskell - punctuation -- ^^^^^^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^^^ comment.line.double-dash.haskell @@ -698,13 +720,15 @@ -- ^ punctuation.section.sequence.end.haskell import Mod1.Mod2.Module ((--") --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.haskell +-- ^^^^^^ meta.import.haskell +-- ^^^^^^^^^^^^^^^^^^ meta.import.module.haskell +-- ^^^^^^^ meta.import.filter.haskell meta.sequence.tuple.haskell -- ^^^^^^ keyword.declaration.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^ entity.name.namespace.haskell - punctuation +-- ^^^^^^ variable.namespace.haskell - punctuation -- ^^^^^^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^^^ comment.line.double-dash.haskell From 3c5e2ba212a6d3df2ca250cef45ea736aee8ed54 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 1 Jan 2021 17:01:52 +0100 Subject: [PATCH 132/178] [Haskell] Add support for MagicHash see: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/magic_hash.html --- Haskell/Haskell.sublime-syntax | 102 +++++++++++-- Haskell/syntax_test_haskell.hs | 256 +++++++++++++++++++++++++-------- 2 files changed, 280 insertions(+), 78 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index bceb8f2dc2..54fd62d788 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -31,15 +31,15 @@ variables: # 2.4 Identifiers and Operators # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-180002.4 - con_id: (?:[[:upper:]][\w']*) - var_id: (?:(?!{{reserved_id}})[[:lower:]_][\w']*) + con_id: (?:[[:upper:]][\w']*(#)*) + var_id: (?:(?!{{reserved_id}})[[:lower:]_][\w']*(#)*) reserved_id: |- (?x: _ | case | class | data | default | deriving | do | else | family | forall | foreign | if | import | in | infix | infixl | infixr | instance | let | mdo | module | newtype | of | proc | rec | signature | then | type | via | where ){{break}} - break: (?![\w']) + break: (?![\w'#]) # In case this regex seems overly general, note that Haskell permits # the definition of new operators which can be nearly any string @@ -178,6 +178,9 @@ variables: | zipWith3 ){{break}} + unboxed_types: |- + (?x: Addr | Array | Double | Float | Int )(#+) + ############################################################################### contexts: @@ -394,9 +397,13 @@ contexts: # class / constructor / data / module / type - match: '{{con_id}}' scope: entity.name.export.haskell + captures: + 1: storage.modifier.unboxed.haskell # function / pattern / variable - match: '{{var_id}}' scope: entity.name.export.haskell + captures: + 1: storage.modifier.unboxed.haskell - include: else-pop signature-where: @@ -446,7 +453,8 @@ contexts: - match: ({{con_id}})(\.)? captures: 1: variable.namespace.haskell - 2: punctuation.accessor.dot.haskell + 2: storage.modifier.haskell + 3: punctuation.accessor.dot.haskell - include: else-pop import-alias: @@ -454,6 +462,8 @@ contexts: - include: ident-namespaces - match: '{{con_id}}' scope: entity.name.import.namespace.haskell + captures: + 1: storage.modifier.unboxed.haskell pop: 1 - include: else-pop @@ -482,9 +492,13 @@ contexts: # class / constructor / data / module / type - match: '{{con_id}}' scope: entity.name.import.haskell + captures: + 1: storage.modifier.unboxed.haskell # function / pattern / variable - match: '{{var_id}}' scope: entity.name.import.haskell + captures: + 1: storage.modifier.unboxed.haskell - include: else-pop ###[ FOREIGN DECLARATIONS ]#################################################### @@ -526,6 +540,8 @@ contexts: scope: constant.language.convention.haskell - match: '{{var_id}}' scope: entity.name.function.haskell + captures: + 1: storage.modifier.unboxed.haskell - include: else-pop ###[ CLASS DECLARATIONS ]###################################################### @@ -661,6 +677,8 @@ contexts: pop: 1 - match: '{{var_id}}' scope: entity.name.function.haskell + captures: + 1: storage.modifier.unboxed.haskell - include: infix-parens-operators - include: sequence-separators @@ -677,6 +695,8 @@ contexts: push: variable-name-end - match: '{{var_id}}' scope: variable.other.haskell + captures: + 1: storage.modifier.unboxed.haskell push: variable-name-end - include: sequence-separators - include: else-pop @@ -865,6 +885,7 @@ contexts: # 3.8 Tuples # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-360003.8 - include: empty-tuples + - include: unboxed-tuples - match: (?=\() branch_point: parens branch: @@ -916,6 +937,26 @@ contexts: 1: punctuation.section.sequence.begin.haskell 2: punctuation.section.sequence.end.haskell + unboxed-tuples: + # 6.16.3. Unboxed tuples + # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/primitives.html#unboxed-tuples + - match: (\()(#) + captures: + 1: punctuation.section.sequence.begin.haskell + 2: storage.modifier.unboxed.haskell + push: unboxed-tuple-body + + unboxed-tuple-body: + - meta_scope: meta.sequence.tuple.haskell + - match: (#)(\)) + captures: + 1: storage.modifier.unboxed.haskell + 2: punctuation.section.sequence.end.haskell + pop: 1 + - include: records + - include: expressions + - include: else-pop + ###[ IDENTIFIERS ]############################################################# ident-anonymous: @@ -934,6 +975,11 @@ contexts: # Prelude Data Types - match: '{{prelude_types}}' scope: support.type.prelude.haskell + # Unboxed Data Types + - match: '{{unboxed_types}}' + scope: support.type.unboxed.haskell + captures: + 1: storage.modifier.unboxed.haskell ident-builtin-functions: - match: '{{prelude_functions}}' @@ -943,11 +989,14 @@ contexts: - match: ({{con_id}})(\.) captures: 1: variable.namespace.haskell - 2: punctuation.accessor.dot.haskell + 2: storage.modifier.haskell + 3: punctuation.accessor.dot.haskell ident-module: - match: '{{con_id}}' scope: entity.name.namespace.haskell + captures: + 1: storage.modifier.unboxed.haskell pop: 1 ident-types: @@ -955,6 +1004,8 @@ contexts: - include: ident-builtin-types - match: '{{con_id}}' scope: storage.type.haskell + captures: + 1: storage.modifier.unboxed.haskell ident-type: - match: '{{prelude_classes}}' @@ -963,45 +1014,63 @@ contexts: - match: '{{prelude_types}}' scope: support.type.prelude.haskell pop: 1 + - match: '{{unboxed_types}}' + scope: support.type.unboxed.haskell + pop: 1 + captures: + 1: storage.modifier.unboxed.haskell - match: '{{con_id}}' scope: storage.type.haskell + captures: + 1: storage.modifier.unboxed.haskell pop: 1 ident-functions: - include: ident-builtin-functions - match: '{{var_id}}' scope: variable.function.haskell + captures: + 1: storage.modifier.unboxed.haskell ident-variables: - match: '{{var_id}}' scope: variable.other.haskell + captures: + 1: storage.modifier.unboxed.haskell ###[ LITERALS ]################################################################ literal-numbers: # 2.5 Numeric Literals # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-190002.5 - - match: \d+(?:(\.)\d+(?:[eE][-+]?\d+)?|[eE][-+]?\d+){{break}} - scope: meta.number.float.decimal.haskell constant.numeric.value.haskell + - match: (\d+(?:(\.)\d+(?:[eE][-+]?\d+)?|[eE][-+]?\d+))(#*){{break}} + scope: meta.number.float.decimal.haskell captures: - 1: punctuation.separator.decimal.haskell - - match: (0[oO])([0-7]+){{break}} + 1: constant.numeric.value.haskell + 2: punctuation.separator.decimal.haskell + 3: constant.numeric.suffix.haskell + - match: (0[oO])([0-7]+)(#*){{break}} scope: meta.number.integer.octal.haskell captures: 1: constant.numeric.base.haskell 2: constant.numeric.value.haskell - - match: (0[xX])(\h+){{break}} + 3: constant.numeric.suffix.haskell + - match: (0[xX])(\h+)(#*){{break}} scope: meta.number.integer.hexadecimal.haskell captures: 1: constant.numeric.base.haskell 2: constant.numeric.value.haskell - - match: \d+{{break}} - scope: meta.number.integer.decimal.haskell constant.numeric.value.haskell + 3: constant.numeric.suffix.haskell + - match: (\d+)(#*){{break}} + scope: meta.number.integer.decimal.haskell + captures: + 1: constant.numeric.value.haskell + 2: constant.numeric.suffix.haskell literal-chars: # 2.6 Character and String Literals # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-200002.6 - - match: (')(?:([ [\S&&[^\\'']]])|{{escape_sequence}})?(?:(')|{{comment_ahead}}) + - match: (')(?:([ [\S&&[^\\'']]])|{{escape_sequence}})?(?:(')(#*)|{{comment_ahead}}) scope: meta.string.haskell string.quoted.single.haskell captures: 1: punctuation.definition.string.begin.haskell @@ -1012,6 +1081,7 @@ contexts: 6: constant.character.escape.hexadecimal.haskell 7: constant.character.escape.control.haskell 8: punctuation.definition.string.end.haskell + 9: storage.modifier.unboxed.haskell literal-strings: # 2.6 Character and String Literals @@ -1023,8 +1093,10 @@ contexts: literal-string-body: - meta_include_prototype: false - meta_scope: meta.string.haskell string.quoted.double.haskell - - match: \"|$ - scope: punctuation.definition.string.end.haskell + - match: (\")(#*)|$ + captures: + 1: punctuation.definition.string.end.haskell + 2: storage.modifier.unboxed.haskell pop: 1 - match: '{{escape_sequence}}' captures: diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index c767c1a144..cc42336103 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -281,13 +281,13 @@ -- ^ punctuation.section.sequence.end.haskell -- ^^^^^ keyword.control.context.haskell - module Ns.Name (sym1, Sym2) where { import Ns.Other; import Ns.Other2 } + module Ns.Name (sym1, Sym2, sym2#, Sym3#) where { import Ns.Other; import Ns.Other2 } -- ^^^^^^^^^^^^^^^ meta.declaration.module.haskell - meta.sequence --- ^^^^^^^^^^^^ meta.declaration.module.haskell meta.sequence.tuple.haskell --- ^ meta.declaration.module.haskell - meta.sequence --- ^^^^^ - meta.declaration.module - meta.block - meta.sequence --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.haskell - meta.declaration.module --- ^ - meta.block +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.module.haskell meta.sequence.tuple.haskell +-- ^ meta.declaration.module.haskell - meta.sequence +-- ^^^^^ - meta.declaration.module - meta.block - meta.sequence +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.haskell - meta.declaration.module +-- ^ - meta.block -- ^^^^^^ keyword.declaration.namespace.haskell -- ^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell @@ -296,19 +296,25 @@ -- ^^^^ entity.name.export.haskell -- ^ punctuation.separator.sequence.haskell -- ^^^^ entity.name.export.haskell --- ^ punctuation.section.sequence.end.haskell --- ^^^^^ keyword.control.context.haskell --- ^ punctuation.section.block.begin.haskell --- ^^^^^^ keyword.declaration.import.haskell --- ^^ variable.namespace.haskell --- ^ punctuation.accessor.dot.haskell --- ^^^^^ variable.namespace.haskell --- ^ punctuation.terminator.statement.haskell --- ^^^^^^ keyword.declaration.import.haskell --- ^^ variable.namespace.haskell --- ^ punctuation.accessor.dot.haskell --- ^^^^^^ variable.namespace.haskell --- ^ punctuation.section.block.end.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^ entity.name.export.haskell +-- ^ storage.modifier.unboxed.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^ entity.name.export.haskell +-- ^ storage.modifier.unboxed.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^^^^ keyword.control.context.haskell +-- ^ punctuation.section.block.begin.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.terminator.statement.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ variable.namespace.haskell +-- ^ punctuation.section.block.end.haskell module Name (module Other.Module) where { import Other.Module } -- ^^^^^^^^^^^^ meta.declaration.module.haskell - meta.sequence @@ -388,13 +394,13 @@ -- ^ punctuation.section.sequence.end.haskell -- ^^^^^ keyword.control.context.haskell - signature Ns.Name (sym1, Sym2) where { import Ns.Other; import Ns.Other2 } + signature Ns.Name (sym1, Sym2, sym2#, Sym3#) where { import Ns.Other; import Ns.Other2 } -- ^^^^^^^^^^^^^^^^^^ meta.declaration.signature.haskell - meta.sequence --- ^^^^^^^^^^^^ meta.declaration.signature.haskell meta.sequence.tuple.haskell --- ^ meta.declaration.signature.haskell - meta.sequence --- ^^^^^ - meta.declaration.signature - meta.block - meta.sequence --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.haskell - meta.declaration.signature --- ^ - meta.block +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.signature.haskell meta.sequence.tuple.haskell +-- ^ meta.declaration.signature.haskell - meta.sequence +-- ^^^^^ - meta.declaration.signature - meta.block - meta.sequence +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.haskell - meta.declaration.signature +-- ^ - meta.block -- ^^^^^^^^^ keyword.declaration.namespace.haskell -- ^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell @@ -403,19 +409,25 @@ -- ^^^^ entity.name.export.haskell -- ^ punctuation.separator.sequence.haskell -- ^^^^ entity.name.export.haskell --- ^ punctuation.section.sequence.end.haskell --- ^^^^^ keyword.control.context.haskell --- ^ punctuation.section.block.begin.haskell --- ^^^^^^ keyword.declaration.import.haskell --- ^^ variable.namespace.haskell --- ^ punctuation.accessor.dot.haskell --- ^^^^^ variable.namespace.haskell --- ^ punctuation.terminator.statement.haskell --- ^^^^^^ keyword.declaration.import.haskell --- ^^ variable.namespace.haskell --- ^ punctuation.accessor.dot.haskell --- ^^^^^^ variable.namespace.haskell --- ^ punctuation.section.block.end.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^ entity.name.export.haskell +-- ^ storage.modifier.unboxed.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^ entity.name.export.haskell +-- ^ storage.modifier.unboxed.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^^^^ keyword.control.context.haskell +-- ^ punctuation.section.block.begin.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.terminator.statement.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ variable.namespace.haskell +-- ^ punctuation.section.block.end.haskell signature Name (module Other.Module) where { import Other.Module } -- ^^^^^^^^^^^^^^^ meta.declaration.signature.haskell - meta.sequence @@ -503,11 +515,11 @@ -- ^^^^^^^^^^^^^ meta.import.alias.haskell entity.name.import.namespace.haskell -- ^ - meta.import - entity - import Mod1.Mod2.Module (funcName) + import Mod1.Mod2.Module (funcName, unboxed#, Type#) -- ^^^^^^ meta.import.haskell - meta.sequence -- ^^^^^^^^^^^^^^^^^^ meta.import.module.haskell - meta.sequence --- ^^^^^^^^^^ meta.import.filter.haskell meta.sequence.tuple.haskell --- ^ - meta.import +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.filter.haskell meta.sequence.tuple.haskell +-- ^ - meta.import -- ^^^^^^ keyword.declaration.import.haskell -- ^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.accessor.dot.haskell - variable @@ -517,7 +529,13 @@ -- ^^^^^^^^^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^^^^^^ entity.name.import.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^^ entity.name.import.haskell +-- ^ storage.modifier.unboxed.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^ entity.name.import.haskell +-- ^ storage.modifier.unboxed.haskell +-- ^ punctuation.section.sequence.end.haskell import Mod1.Mod2.Module (ClassName(..)) -- ^^^^^^ meta.import.haskell - meta.sequence @@ -783,6 +801,18 @@ -- ^^ keyword.operator.arrow.haskell -- ^^^ support.type.prelude.haskell + foreign export ccall triple# :: Int -> Int +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.foreign.export.haskell +-- ^^^^^^^ storage.modifier.foreign.haskell +-- ^^^^^^ keyword.declaration.export.haskell +-- ^^^^^ constant.language.convention.haskell +-- ^^^^^^^ entity.name.function.haskell +-- ^ storage.modifier.unboxed.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^^^ support.type.prelude.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^^^ support.type.prelude.haskell + foreign export ccall "addInt" (+) :: Int->Int->Int -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.foreign.export.haskell -- ^^^^^^^ storage.modifier.foreign.haskell @@ -838,18 +868,19 @@ -- ^^ keyword.operator.arrow.haskell -- ^^^^^^ support.type.prelude.haskell - foreign import dotnet safe "func" func :: String -> Bool --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.foreign.import.haskell + foreign import dotnet safe "func" func# :: String -> Bool +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.foreign.import.haskell -- ^^^^^^^ storage.modifier.foreign.haskell -- ^^^^^^ keyword.declaration.import.haskell -- ^^^^^^ constant.language.convention.haskell -- ^^^^ storage.modifier.import.haskell -- ^^^^^^ meta.string.haskell string.quoted.double.haskell --- ^^^^ entity.name.function.haskell --- ^^ keyword.operator.double-colon.haskell --- ^^^^^^ support.type.prelude.haskell --- ^^ keyword.operator.arrow.haskell --- ^^^^ support.type.prelude.haskell +-- ^^^^^ entity.name.function.haskell +-- ^ storage.modifier.unboxed.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^^^^^^ support.type.prelude.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^^^^ support.type.prelude.haskell foreign import ccall "addInt" (+) :: Int->Int->Int -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.foreign.import.haskell @@ -893,6 +924,14 @@ -- ^^^^^^ storage.type.haskell -- ^^^^^ variable.other.haskell + class QTyCls# tyVar# +-- ^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell +-- ^^^^^ keyword.declaration.class.haskell +-- ^^^^^^^ storage.type.haskell +-- ^ storage.modifier.unboxed.haskell +-- ^^^^^^ variable.other.haskell +-- ^ storage.modifier.unboxed.haskell + class ModId.QTyCls tyVar1 tyVar2, ident -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell -- ^^^^^^^ - meta.declaration @@ -915,19 +954,20 @@ -- ^^^^^^ variable.other.haskell -- ^^ keyword.operator.big-arrow.haskell - class ModId.QTyCls (tyVar1 tyVar2) => + class ModId.QTyCls (tyVar1 tyVar2#) => -- ^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell - meta.group --- ^^^^^^^^^^^^^^^ meta.declaration.class.haskell meta.group.haskell --- ^^^^ meta.declaration.class.haskell - meta.group +-- ^^^^^^^^^^^^^^^^ meta.declaration.class.haskell meta.group.haskell +-- ^^^^ meta.declaration.class.haskell - meta.group -- ^^^^^ keyword.declaration.class.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell -- ^ punctuation.section.group.begin.haskell -- ^^^^^^ variable.other.haskell --- ^^^^^^ variable.other.haskell --- ^ punctuation.section.group.end.haskell --- ^^ keyword.operator.big-arrow.haskell +-- ^^^^^^^ variable.other.haskell +-- ^ storage.modifier.unboxed.haskell +-- ^ punctuation.section.group.end.haskell +-- ^^ keyword.operator.big-arrow.haskell class ModId.QTyCls (tyVar1 tyVar2 => ) -- ^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell - meta.group @@ -1129,11 +1169,12 @@ -- ^^^^^^^^^^^^ variable.other.haskell -- ^^ keyword.operator.double-colon.haskell -- ^^^^^^ support.type.prelude.haskell - , recordDouble :: Double + , recordDouble :: Double# -- ^ punctuation.separator.sequence.haskell -- ^^^^^^^^^^^^ variable.other.haskell -- ^^ keyword.operator.double-colon.haskell --- ^^^^^^ support.type.prelude.haskell +-- ^^^^^^^ support.type.unboxed.haskell +-- ^ storage.modifier.unboxed.haskell , recordRational :: Rational -- ^ punctuation.separator.sequence.haskell -- ^^^^^^^^^^^^^^ variable.other.haskell @@ -2391,8 +2432,8 @@ main = do -- ^^^^^ meta.sequence.tuple.haskell -- ^ - meta.sequence -- ^ punctuation.section.sequence.begin.haskell --- ^ keyword.operator.haskell --- ^ keyword.operator.haskell +-- ^ storage.modifier.unboxed.haskell +-- ^ storage.modifier.unboxed.haskell -- ^ punctuation.section.sequence.end.haskell ( , , ) @@ -2407,8 +2448,8 @@ main = do -- ^^^^^^^^^ meta.sequence.tuple.haskell -- ^ - meta.sequence -- ^ punctuation.section.sequence.begin.haskell --- ^ keyword.operator.haskell --- ^ keyword.operator.haskell +-- ^ storage.modifier.unboxed.haskell +-- ^ storage.modifier.unboxed.haskell -- ^ punctuation.section.sequence.end.haskell (group,) @@ -2420,9 +2461,9 @@ main = do (#group,#) -- ^^^^^^^^^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell --- ^ keyword.operator.haskell +-- ^ storage.modifier.unboxed.haskell -- ^ punctuation.separator.sequence.haskell --- ^ keyword.operator.haskell +-- ^ storage.modifier.unboxed.haskell -- ^ punctuation.section.sequence.end.haskell ('<':'b':'r':_) @@ -2520,6 +2561,14 @@ main = do a' -- ^^ variable.other.haskell + a# +-- ^ variable.other.haskell - storage.modifer +-- ^ variable.other.haskell storage.modifier.unboxed.haskell + + a'# +-- ^^ variable.other.haskell - storage.modifer +-- ^ variable.other.haskell storage.modifier.unboxed.haskell + _a'b'c_D'0123456789' -- ^^^^^^^^^^^^^^^^^^^^ variable.other.haskell @@ -2541,14 +2590,31 @@ main = do -- ^ punctuation.accessor.dot.haskell -- ^ variable.other.haskell + T#.a# +-- ^ variable.namespace.haskell - storage.modifier +-- ^ variable.namespace.haskell storage.modifier.haskell +-- ^ punctuation.accessor.dot.haskell - variable +-- ^ variable.other.haskell - storage.modifier +-- ^ variable.other.haskell storage.modifier.unboxed.haskell + T . a -- ^ storage.type.haskell -- ^ keyword.operator.haskell -- ^ variable.other.haskell + T# . a +-- ^ storage.type.haskell - storage.modifier +-- ^ storage.type.haskell storage.modifier.unboxed.haskell +-- ^ keyword.operator.haskell +-- ^ variable.other.haskell + Just -- ^^^^ support.type.prelude.haskell + Just# +-- ^^^^ storage.type.haskell - storage.modifier +-- ^ storage.type.haskell storage.modifier.unboxed.haskell + Nothing -- ^^^^^^^ support.constant.prelude.haskell @@ -2568,26 +2634,58 @@ main = do 0 -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell + 0# +-- ^^ meta.number.integer.decimal.haskell +-- ^ constant.numeric.value.haskell +-- ^ constant.numeric.suffix.haskell + 1234567890 -- ^^^^^^^^^^ meta.number.integer.decimal.haskell constant.numeric.value.haskell + 1234567890## +-- ^^^^^^^^^^^^ meta.number.integer.decimal.haskell +-- ^^^^^^^^^^ constant.numeric.value.haskell +-- ^^ constant.numeric.suffix.haskell + 0o1234567 -- ^^^^^^^^^ meta.number.integer.octal.haskell -- ^^ constant.numeric.base.haskell -- ^^^^^^^ constant.numeric.value.haskell + 0o1234567# +-- ^^^^^^^^^^ meta.number.integer.octal.haskell +-- ^^ constant.numeric.base.haskell +-- ^^^^^^^ constant.numeric.value.haskell +-- ^ constant.numeric.suffix.haskell + 1. -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell -- ^ keyword.operator.haskell + 1.# +-- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell +-- ^^ keyword.operator.haskell + .2 -- ^ keyword.operator.haskell -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell + .2# +-- ^ keyword.operator.haskell +-- ^^ meta.number.integer.decimal.haskell +-- ^ constant.numeric.value.haskell +-- ^ constant.numeric.suffix.haskell + 12.345 -- ^^^^^^ meta.number.float.decimal.haskell constant.numeric.value.haskell -- ^ punctuation.separator.decimal + 12.345# +-- ^^^^^^^ meta.number.float.decimal.haskell +-- ^^^^^^ constant.numeric.value.haskell +-- ^ punctuation.separator.decimal +-- ^ constant.numeric.suffix.haskell + 1e10 -- ^^^^ meta.number.float.decimal.haskell constant.numeric.value.haskell @@ -2595,6 +2693,12 @@ main = do -- ^^^^^^ meta.number.float.decimal.haskell constant.numeric.value.haskell -- ^ punctuation.separator.decimal.haskell + 0.5e+0# +-- ^^^^^^^ meta.number.float.decimal.haskell +-- ^^^^^^ constant.numeric.value.haskell +-- ^ punctuation.separator.decimal.haskell +-- ^ constant.numeric.suffix.haskell + 9e-1 -- ^^^^ meta.number.float.decimal.haskell constant.numeric.value.haskell @@ -2607,6 +2711,12 @@ main = do -- ^^ constant.numeric.base.haskell -- ^^^^^^^^^^ constant.numeric.value.haskell + 0XdeafBEEF42## +-- ^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.haskell +-- ^^ constant.numeric.base.haskell +-- ^^^^^^^^^^ constant.numeric.value.haskell +-- ^^ constant.numeric.suffix.haskell + -- [ LITERAL CHARACTERS ] ----------------------------------------------------- @@ -2633,6 +2743,13 @@ main = do -- ^ constant.character.literal.haskell -- ^ punctuation.definition.string.end.haskell + 'a'# -- unboxed literal character +-- ^^^^ meta.string.haskell string.quoted.single.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ constant.character.literal.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ storage.modifier.unboxed.haskell + '5' -- literal digit character -- ^^^ meta.string.haskell string.quoted.single.haskell -- ^ punctuation.definition.string.begin.haskell @@ -3300,6 +3417,19 @@ main = do -- ^^ constant.character.escape.haskell -- ^^ - punctuation + "string"# -- unboxed literal string +-- ^^^^^^^^^ meta.string.haskell string.quoted.double.haskell +-- ^ punctuation.definition.string.begin.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ storage.modifier.unboxed.haskell + + "string" # +-- ^^^^^^^^ meta.string.haskell string.quoted.double.haskell +-- ^^^ - meta.string - string +-- ^ punctuation.definition.string.begin.haskell +-- ^ punctuation.definition.string.end.haskell +-- ^ keyword.operator.haskell + -- [ INFIX OPERATORS ] -------------------------------------------------------- From 84d256613da06e2d991933606b802ee093b3a30a Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 1 Jan 2021 18:09:11 +0100 Subject: [PATCH 133/178] [Haskell] Add operators to indexed reference list --- Haskell/Reference List - Operators.tmPreferences | 12 ++++++++++++ Haskell/syntax_test_haskell.hs | 11 +++++++++++ 2 files changed, 23 insertions(+) create mode 100644 Haskell/Reference List - Operators.tmPreferences diff --git a/Haskell/Reference List - Operators.tmPreferences b/Haskell/Reference List - Operators.tmPreferences new file mode 100644 index 0000000000..0e25b1d2ff --- /dev/null +++ b/Haskell/Reference List - Operators.tmPreferences @@ -0,0 +1,12 @@ + + + + scope + source.haskell keyword.operator - meta.function.identifier + settings + + showInIndexedReferenceList + 1 + + + diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index cc42336103..c8ca2eaa20 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -1873,6 +1873,17 @@ -- ^ variable.other.haskell -- ^^ keyword.operator.arrow.haskell -- ^^^^ support.type.prelude.haskell + {- infix operator body -} + (<:>) = do a <:> b +-- ^^^^^ meta.group.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^^^ keyword.operator.haskell +-- ^ punctuation.section.group.end.haskell +-- ^ keyword.operator.haskell +-- ^^ keyword.control.context.haskell +-- ^ variable.other.haskell +-- ^^^ keyword.operator.haskell +-- ^ variable.other.haskell {- function declaration list -} isNaN,, isInfinite From d1829734607be865f628d61e5caf959f04a042ad Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 1 Jan 2021 18:32:15 +0100 Subject: [PATCH 134/178] [Haskell] Add operator declarations to indexed symbol list --- Haskell/Symbol List - Operators.tmPreferences | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Haskell/Symbol List - Operators.tmPreferences b/Haskell/Symbol List - Operators.tmPreferences index 7e6ce51fc4..7cdfa4a321 100644 --- a/Haskell/Symbol List - Operators.tmPreferences +++ b/Haskell/Symbol List - Operators.tmPreferences @@ -7,6 +7,8 @@ showInSymbolList 1 + showInIndexedSymbolList + 1 From a50a411586a69dda9c1b96b76dce6eeec71547e9 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 1 Jan 2021 18:34:44 +0100 Subject: [PATCH 135/178] [Haskell] Tweak infix operators This commit... 1. scopes the whole backticked region (e.g.: ` opid `) as `meta.infix` 2. restricts `keyword.operator` to `opid` only 3. adapts punctuation scopes. --- Haskell/Haskell.sublime-syntax | 10 ++-- Haskell/syntax_test_haskell.hs | 96 +++++++++++++++++++++++++--------- 2 files changed, 77 insertions(+), 29 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 54fd62d788..7e513f42e0 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -1163,11 +1163,13 @@ contexts: 3: punctuation.section.group.end.haskell infix-quoted-operators: - - match: (`)[ \w'.]*(`) - scope: keyword.operator.function.infix.haskell + - match: (`)\s*([\w'.]*(#*))\s*(`) + scope: meta.infix.haskell captures: - 1: punctuation.definition.function.begin.haskell - 2: punctuation.definition.function.end.haskell + 1: punctuation.definition.infix.begin.haskell + 2: keyword.operator.function.infix.haskell + 3: storage.modifier.unboxed.haskell + 4: punctuation.definition.infix.end.haskell statement-terminators: # Depending on layout, semicolon may be needed to terminate statements. diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index c8ca2eaa20..8b7d118af2 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -1236,7 +1236,9 @@ | Int `Quux` Double -- ^ punctuation.separator.sequence.haskell -- ^^^ support.type.prelude.haskell --- ^^^^^^ keyword.operator.function.infix.haskell +-- ^ meta.infix.haskell punctuation.definition.infix.begin.haskell +-- ^^^^ meta.infix.haskell keyword.operator.function.infix.haskell +-- ^ meta.infix.haskell punctuation.definition.infix.end.haskell -- ^^^^^^ support.type.prelude.haskell | String :# Record -- ^ punctuation.separator.sequence.haskell @@ -1847,7 +1849,9 @@ infix 1 `ConId` -- ^^^^^ keyword.declaration.fixity.haskell -- ^ constant.numeric.value.haskell --- ^^^^^^^ keyword.operator.function.infix.haskell +-- ^ meta.infix.haskell punctuation.definition.infix.begin.haskell +-- ^^^^^ meta.infix.haskell keyword.operator.function.infix.haskell +-- ^ meta.infix.haskell punctuation.definition.infix.end.haskell infixl 7 ⋆, /, `quot` -- ^^^^^^ keyword.declaration.fixity.haskell @@ -1856,7 +1860,9 @@ -- ^ punctuation.separator.sequence.haskell -- ^ keyword.operator.haskell -- ^ punctuation.separator.sequence.haskell --- ^^^^^^ keyword.operator.function.infix.haskell +-- ^ meta.infix.haskell punctuation.definition.infix.begin.haskell +-- ^^^^ meta.infix.haskell keyword.operator.function.infix.haskell +-- ^ meta.infix.haskell punctuation.definition.infix.end.haskell -- [ FUNCTION DECLARATIONS ] -------------------------------------------------- @@ -2502,7 +2508,7 @@ main = do -- ^ keyword.operator.haskell -- ^^ - keyword -- ^ keyword.operator.haskell --- ^^ keyword.operator.function.infix.haskell +-- ^^ meta.infix.haskell -- ^ punctuation.section.sequence.end.haskell (group) @@ -3605,46 +3611,54 @@ main = do {- unqualified infix variable operator id -} a `member` x --- ^^^^^^^^ keyword.operator.function.infix.haskell --- ^ punctuation.definition.function.begin.haskell --- ^ punctuation.definition.function.end.haskell +-- ^^^^^^^^ meta.infix.haskell +-- ^ punctuation.definition.infix.begin.haskell - keyword +-- ^^^^^^ keyword.operator.function.infix.haskell +-- ^ punctuation.definition.infix.end.haskell - keyword {- qualified infix variable operator id -} a `P.atan2` x --- ^^^^^^^^^ keyword.operator.function.infix.haskell --- ^ punctuation.definition.function.begin.haskell --- ^ punctuation.definition.function.end.haskell +-- ^^^^^^^^^ meta.infix.haskell +-- ^ punctuation.definition.infix.begin.haskell - keyword +-- ^^^^^^^ keyword.operator.function.infix.haskell +-- ^ punctuation.definition.infix.end.haskell - keyword {- unqualified infix constructor operator id -} a `Quux` x --- ^^^^^^ keyword.operator.function.infix.haskell --- ^ punctuation.definition.function.begin.haskell --- ^ punctuation.definition.function.end.haskell +-- ^^^^^^ meta.infix.haskell +-- ^ punctuation.definition.infix.begin.haskell - keyword +-- ^^^^ keyword.operator.function.infix.haskell +-- ^ punctuation.definition.infix.end.haskell - keyword {- qualified infix constructor operator id -} a `Monad.Quux` x --- ^^^^^^^^^^^^ keyword.operator.function.infix.haskell --- ^ punctuation.definition.function.begin.haskell --- ^ punctuation.definition.function.end.haskell +-- ^^^^^^^^^^^^ meta.infix.haskell +-- ^ punctuation.definition.infix.begin.haskell - keyword +-- ^^^^^^^^^^ keyword.operator.function.infix.haskell +-- ^ punctuation.definition.infix.end.haskell - keyword 5 `f `7`f`"3 'ab'" -- ^ constant.numeric.value.haskell --- ^^^^ keyword.operator.function.infix.haskell --- ^ punctuation.definition.function.begin.haskell --- ^ punctuation.definition.function.end.haskell +-- ^^^^ meta.infix.haskell +-- ^ punctuation.definition.infix.begin.haskell - keyword +-- ^ keyword.operator.function.infix.haskell +-- ^ - keyword - punctuation +-- ^ punctuation.definition.infix.end.haskell - keyword -- ^ constant.numeric.value.haskell --- ^^^ keyword.operator.function.infix.haskell --- ^ punctuation.definition.function.begin.haskell --- ^ punctuation.definition.function.end.haskell +-- ^^^ meta.infix.haskell +-- ^ punctuation.definition.infix.begin.haskell - keyword +-- ^ keyword.operator.function.infix.haskell +-- ^ punctuation.definition.infix.end.haskell - keyword -- ^^^^^^^^ meta.string.haskell string.quoted.double.haskell -- ^ punctuation.definition.string.begin.haskell -- ^^^^^^ - constant - punctuation -- ^ punctuation.definition.string.end.haskell a ` f` b --- ^^^^ keyword.operator.function.infix.haskell --- ^ punctuation.definition.function.begin.haskell --- ^ punctuation.definition.function.end.haskell +-- ^^^^ meta.infix.haskell +-- ^ punctuation.definition.infix.begin.haskell - keyword +-- ^ keyword.operator.function.infix.haskell +-- ^ punctuation.definition.infix.end.haskell - keyword a `--` b -- ^ - illegal - keyword - operator - punctuation @@ -3653,6 +3667,34 @@ main = do a ` -- ^ - illegal - keyword - operator - punctuation + a `shiftL#` b +-- ^^^^^^^^^ meta.infix.haskell +-- ^ punctuation.definition.infix.begin.haskell - keyword +-- ^^^^^^^ keyword.operator.function.infix.haskell +-- ^ storage.modifier.unboxed.haskell +-- ^ punctuation.definition.infix.end.haskell - keyword + + a ` shiftL# ` b +-- ^^^^^^^^^^^ meta.infix.haskell +-- ^ punctuation.definition.infix.begin.haskell - keyword +-- ^^^^^^^ keyword.operator.function.infix.haskell +-- ^ storage.modifier.unboxed.haskell +-- ^ punctuation.definition.infix.end.haskell - keyword + + a `Ns.shiftL#` b +-- ^^^^^^^^^^^^ meta.infix.haskell +-- ^ punctuation.definition.infix.begin.haskell - keyword +-- ^^^^^^^^^^ keyword.operator.function.infix.haskell +-- ^ storage.modifier.unboxed.haskell +-- ^ punctuation.definition.infix.end.haskell - keyword + + a `Unboxed#` b +-- ^^^^^^^^^^ meta.infix.haskell +-- ^ punctuation.definition.infix.begin.haskell - keyword +-- ^^^^^^^^ keyword.operator.function.infix.haskell +-- ^ storage.modifier.unboxed.haskell +-- ^ punctuation.definition.infix.end.haskell - keyword + -- [ INFIX OPERATORS IN CONTEXT ]---------------------------------------------- @@ -3705,3 +3747,7 @@ myManageHook = composeAll -- ^^^ keyword.operator ] + +shiftL# :: Word# -> Int# -> Word# +a `shiftL#` b | isTrue# (b >=# WORD_SIZE_IN_BITS#) = 0## + | otherwise = a `uncheckedShiftL#` b \ No newline at end of file From b79e7373a64e5524ad3538d8c04aa80f694fb3f3 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 1 Jan 2021 18:38:53 +0100 Subject: [PATCH 136/178] [Haskell] Scope forall unicode keyword the same as its ascii counterpart --- Haskell/Haskell.sublime-syntax | 5 +---- Haskell/syntax_test_haskell.hs | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 7e513f42e0..d1bdbe136e 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -747,10 +747,7 @@ contexts: - include: ident-variables type-forall: - - match: ∀(?!{{symbol}}) - scope: keyword.operator.forall.haskell - push: type-forall-body - - match: forall{{break}} + - match: forall{{break}}|∀(?!{{symbol}}) scope: keyword.control.forall.haskell push: type-forall-body diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 8b7d118af2..dd5dd1cd62 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -1297,7 +1297,7 @@ -- ^ punctuation.separator.sequence.haskell -- ^^^^ support.function.prelude.haskell -- ^^ keyword.operator.double-colon.haskell --- ^ keyword.operator.forall.haskell +-- ^ keyword.control.forall.haskell -- ^ keyword.operator.haskell -- ^^^^^^^^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell From c4c934c0b7c65ad02f4e6e84abc071039ced55f1 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 1 Jan 2021 18:40:46 +0100 Subject: [PATCH 137/178] [Haskell] Scope forall-expression terminator as punctuation --- Haskell/Haskell.sublime-syntax | 2 +- Haskell/syntax_test_haskell.hs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index d1bdbe136e..2abc38714b 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -754,7 +754,7 @@ contexts: type-forall-body: # Note: This is the only situation a dot is allowed within type expressions. - match: \. - scope: keyword.operator.haskell + scope: punctuation.separator.sequence.haskell pop: 1 - include: ident-anonymous - include: ident-variables diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index dd5dd1cd62..0c2b3ed589 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -1277,7 +1277,7 @@ -- ^ punctuation.section.group.end.haskell -- ^^ keyword.operator.double-colon.haskell -- ^^^^^^ keyword.control.forall.haskell --- ^ keyword.operator.haskell +-- ^ punctuation.separator.sequence.haskell -- ^^^^^^^^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^ support.class.prelude.haskell @@ -1289,7 +1289,7 @@ -- ^ punctuation.section.group.end.haskell -- ^^ keyword.operator.double-colon.haskell -- ^^^^^^ keyword.control.forall.haskell --- ^ keyword.operator.haskell +-- ^ punctuation.separator.sequence.haskell -- ^^^^^^^^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^ support.class.prelude.haskell @@ -1298,7 +1298,7 @@ -- ^^^^ support.function.prelude.haskell -- ^^ keyword.operator.double-colon.haskell -- ^ keyword.control.forall.haskell --- ^ keyword.operator.haskell +-- ^ punctuation.separator.sequence.haskell -- ^^^^^^^^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^^^^ storage.type.haskell @@ -1307,7 +1307,7 @@ -- ^^^^^^ support.function.prelude.haskell -- ^^ keyword.operator.double-colon.haskell -- ^^^^^^ keyword.control.forall.haskell --- ^ keyword.operator.haskell +-- ^ punctuation.separator.sequence.haskell -- ^^^^^^^^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^ support.class.prelude.haskell @@ -1752,7 +1752,7 @@ -- ^ keyword.operator.haskell -- ^^^^^^ keyword.control.forall.haskell -- ^ variable.other.haskell --- ^ keyword.operator.haskell +-- ^ punctuation.separator.sequence.haskell -- ^ variable.other.haskell -- ^ variable.other.haskell -- ^^ keyword.operator.arrow.haskell @@ -1764,7 +1764,7 @@ -- ^ keyword.operator.haskell -- ^^^^^^ keyword.control.forall.haskell -- ^ variable.other.haskell --- ^ keyword.operator.haskell +-- ^ punctuation.separator.sequence.haskell -- ^^^^^^^^ meta.group.haskell -- ^ punctuation.section.group.begin.haskell -- ^^^^ support.class.prelude.haskell From 24a16741c2a01afb93a3dc78dd6ca1fbc3f8b556 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 1 Jan 2021 18:47:15 +0100 Subject: [PATCH 138/178] [Haskell] Add exported operators to index --- Haskell/Symbol List - Operators.tmPreferences | 5 ++- Haskell/syntax_test_haskell.hs | 44 +++++++++++-------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/Haskell/Symbol List - Operators.tmPreferences b/Haskell/Symbol List - Operators.tmPreferences index 7cdfa4a321..d09a74426a 100644 --- a/Haskell/Symbol List - Operators.tmPreferences +++ b/Haskell/Symbol List - Operators.tmPreferences @@ -2,7 +2,10 @@ scope - meta.function.identifier.haskell meta.group keyword.operator + + meta.declaration.module.haskell meta.sequence keyword.operator + meta.function.identifier.haskell meta.group keyword.operator + settings showInSymbolList diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 0c2b3ed589..8ecd97428c 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -281,13 +281,15 @@ -- ^ punctuation.section.sequence.end.haskell -- ^^^^^ keyword.control.context.haskell - module Ns.Name (sym1, Sym2, sym2#, Sym3#) where { import Ns.Other; import Ns.Other2 } + module Ns.Name (sym1, Sym2, sym2#, Sym3#, (<:>)) where { import Ns.Other; import Ns.Other2 } -- ^^^^^^^^^^^^^^^ meta.declaration.module.haskell - meta.sequence --- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.module.haskell meta.sequence.tuple.haskell --- ^ meta.declaration.module.haskell - meta.sequence --- ^^^^^ - meta.declaration.module - meta.block - meta.sequence --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.haskell - meta.declaration.module --- ^ - meta.block +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.module.haskell meta.sequence.tuple.haskell - meta.group +-- ^^^^^ meta.declaration.module.haskell meta.sequence.tuple.haskell meta.group.haskell +-- ^ meta.declaration.module.haskell meta.sequence.tuple.haskell - meta.group +-- ^ meta.declaration.module.haskell - meta.sequence +-- ^^^^^ - meta.declaration.module - meta.block - meta.sequence +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.haskell - meta.declaration.module +-- ^ - meta.block -- ^^^^^^ keyword.declaration.namespace.haskell -- ^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell @@ -302,19 +304,23 @@ -- ^ punctuation.separator.sequence.haskell -- ^^^^^ entity.name.export.haskell -- ^ storage.modifier.unboxed.haskell --- ^ punctuation.section.sequence.end.haskell --- ^^^^^ keyword.control.context.haskell --- ^ punctuation.section.block.begin.haskell --- ^^^^^^ keyword.declaration.import.haskell --- ^^ variable.namespace.haskell --- ^ punctuation.accessor.dot.haskell --- ^^^^^ variable.namespace.haskell --- ^ punctuation.terminator.statement.haskell --- ^^^^^^ keyword.declaration.import.haskell --- ^^ variable.namespace.haskell --- ^ punctuation.accessor.dot.haskell --- ^^^^^^ variable.namespace.haskell --- ^ punctuation.section.block.end.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^^^ keyword.operator.haskell +-- ^ punctuation.section.group.end.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^^^^ keyword.control.context.haskell +-- ^ punctuation.section.block.begin.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.terminator.statement.haskell +-- ^^^^^^ keyword.declaration.import.haskell +-- ^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ variable.namespace.haskell +-- ^ punctuation.section.block.end.haskell module Name (module Other.Module) where { import Other.Module } -- ^^^^^^^^^^^^ meta.declaration.module.haskell - meta.sequence From 52d4e3bfeca2feca6d65fd7921034a48a8d606c7 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 1 Jan 2021 18:49:13 +0100 Subject: [PATCH 139/178] [Haskell] Add missing builtin unboxed types --- Haskell/Haskell.sublime-syntax | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 2abc38714b..785c51dbd8 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -178,8 +178,10 @@ variables: | zipWith3 ){{break}} + # 6.2.2. The magic hash + # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/magic_hash.html unboxed_types: |- - (?x: Addr | Array | Double | Float | Int )(#+) + (?x: Addr | Array | Char | Double | Float | Int | Word )(#){{break}} ############################################################################### From 9f8db10f27db3133343294a8471844f043a46211 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 1 Jan 2021 19:03:52 +0100 Subject: [PATCH 140/178] [Haskell] Add sql like list comprehension keywords --- Haskell/Haskell.sublime-syntax | 7 +++++ Haskell/syntax_test_haskell.hs | 55 ++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 785c51dbd8..5ca8011f36 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -859,9 +859,16 @@ contexts: - meta_scope: meta.sequence.list.haskell - include: list-end - include: records + - include: list-keywords - include: expressions - include: else-pop + list-keywords: + # 6.2.7. Generalised (SQL-like) List Comprehensions + # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/generalised_list_comprehensions.html + - match: (?:group|by|using){{break}} + scope: keyword.control.list.haskell + quasi-quotes: # https://wiki.haskell.org/Quasiquotation - match: (\[)([\w'']+)(\|) diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 8ecd97428c..28c2994499 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -2436,6 +2436,61 @@ main = do -- ^ punctuation.section.sequence.end.haskell -- + {- Generalised (SQL-like) List Comprehensions -} + a = [ (the dept, sum salary) +-- ^^ meta.sequence.list.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.sequence.list.haskell meta.sequence.tuple.haskell +-- ^ meta.sequence.list.haskell - meta.sequence meta.sequence +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^ variable.other.haskell +-- ^^^^ variable.other.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^ support.function.prelude.haskell +-- ^^^^^^ variable.other.haskell +-- ^ punctuation.section.sequence.end.haskell + | (name, dept, salary) <- employees +-- ^^ meta.sequence.list.haskell +-- ^^^^^^^^^^^^^^^^^^^^ meta.sequence.list.haskell meta.sequence.tuple.haskell +-- ^^^^^^^^^^^^^^ meta.sequence.list.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^^^^ variable.other.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^ variable.other.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^ variable.other.haskell +-- ^ punctuation.section.sequence.end.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^^^^^^^^^ variable.other.haskell + , then group by dept using groupWith +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.sequence.list.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^ keyword.control.conditional.then.haskell +-- ^^^^^ keyword.control.list.haskell +-- ^^ keyword.control.list.haskell +-- ^^^^ variable.other.haskell +-- ^^^^^ keyword.control.list.haskell +-- ^^^^^^^^^ variable.other.haskell + , then sortWith by (sum salary) +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.sequence.list.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^ keyword.control.conditional.then.haskell +-- ^^^^^^^^ variable.other.haskell +-- ^^ keyword.control.list.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^^^ support.function.prelude.haskell +-- ^^^^^^ variable.other.haskell +-- ^ punctuation.section.group.end.haskell + , then take 5 ] +-- ^^^^^^^^^^^^^^^ meta.sequence.list.haskell +-- ^ - meta.sequence +-- ^ punctuation.separator.sequence.haskell +-- ^^^^ keyword.control.conditional.then.haskell +-- ^^^^ support.function.prelude.haskell +-- ^ constant.numeric.value.haskell +-- ^ punctuation.section.sequence.end.haskell + () -- ^ - meta.sequence -- ^^ meta.sequence.tuple.haskell From 7d9bcd55d4c59823306dcbcd97b039e103e7bea3 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 1 Jan 2021 19:24:32 +0100 Subject: [PATCH 141/178] [Haskell] Add binary integer and hexadecimal float literals --- Haskell/Haskell.sublime-syntax | 21 +++++++++- Haskell/syntax_test_haskell.hs | 74 ++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 1 deletion(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 5ca8011f36..ae7059487c 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -1047,7 +1047,7 @@ contexts: ###[ LITERALS ]################################################################ literal-numbers: - # 2.5 Numeric Literals + # 2.5 Decimal floating point literals # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-190002.5 - match: (\d+(?:(\.)\d+(?:[eE][-+]?\d+)?|[eE][-+]?\d+))(#*){{break}} scope: meta.number.float.decimal.haskell @@ -1055,6 +1055,25 @@ contexts: 1: constant.numeric.value.haskell 2: punctuation.separator.decimal.haskell 3: constant.numeric.suffix.haskell + # 6.9.3. Hexadecimal floating point literals + # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/hex_float_literals.html + - match: (0[xX])(\h+(\.)\h+(?:[pP][-+]?\d+)?)(#*){{break}} + scope: meta.number.float.hexadecimal.haskell + captures: + 1: constant.numeric.base.haskell + 2: constant.numeric.value.haskell + 3: punctuation.separator.decimal.haskell + 4: constant.numeric.suffix.haskell + # 6.9.2. Binary integer literals + # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/binary_literals.html + - match: (0[bB])([01]+)(#*){{break}} + scope: meta.number.integer.binary.haskell + captures: + 1: constant.numeric.base.haskell + 2: constant.numeric.value.haskell + 3: constant.numeric.suffix.haskell + # 2.5 Numeric Literals + # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-190002.5 - match: (0[oO])([0-7]+)(#*){{break}} scope: meta.number.integer.octal.haskell captures: diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 28c2994499..0b17774340 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -2709,6 +2709,8 @@ main = do -- [ LITERAL NUMBERS ] -------------------------------------------------------- + {- Decimal integer literals -} + 0 -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell @@ -2725,6 +2727,8 @@ main = do -- ^^^^^^^^^^ constant.numeric.value.haskell -- ^^ constant.numeric.suffix.haskell + {- Octal integer literals -} + 0o1234567 -- ^^^^^^^^^ meta.number.integer.octal.haskell -- ^^ constant.numeric.base.haskell @@ -2736,6 +2740,8 @@ main = do -- ^^^^^^^ constant.numeric.value.haskell -- ^ constant.numeric.suffix.haskell + {- Decimal floating point literals -} + 1. -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell -- ^ keyword.operator.haskell @@ -2780,6 +2786,42 @@ main = do 9e-1 -- ^^^^ meta.number.float.decimal.haskell constant.numeric.value.haskell + {- Binary integer literals -} + + 0b0 +-- ^^^ meta.number.integer.binary.haskell +-- ^^ constant.numeric.base.haskell +-- ^ constant.numeric.value.haskell + 0b1 +-- ^^^ meta.number.integer.binary.haskell +-- ^^ constant.numeric.base.haskell +-- ^ constant.numeric.value.haskell + + 0b01010111101 +-- ^^^^^^^^^^^^^ meta.number.integer.binary.haskell +-- ^^ constant.numeric.base.haskell +-- ^^^^^^^^^^^ constant.numeric.value.haskell + + 0b0# +-- ^^^^ meta.number.integer.binary.haskell +-- ^^ constant.numeric.base.haskell +-- ^ constant.numeric.value.haskell +-- ^ constant.numeric.suffix.haskell + + 0b1# +-- ^^^^ meta.number.integer.binary.haskell +-- ^^ constant.numeric.base.haskell +-- ^ constant.numeric.value.haskell +-- ^ constant.numeric.suffix.haskell + + 0b01010111101# +-- ^^^^^^^^^^^^^^ meta.number.integer.binary.haskell +-- ^^ constant.numeric.base.haskell +-- ^^^^^^^^^^^ constant.numeric.value.haskell +-- ^ constant.numeric.suffix.haskell + + {- Hexadecimal integer literals -} + 0x0 -- ^^^ meta.number.integer.hexadecimal.haskell -- ^^ constant.numeric.base.haskell @@ -2795,6 +2837,38 @@ main = do -- ^^^^^^^^^^ constant.numeric.value.haskell -- ^^ constant.numeric.suffix.haskell + {- Hexadecimal floating point literals -} + + 0x0.1 -- is the same as 1/16 +-- ^^^^^ meta.number.float.hexadecimal.haskell +-- ^^ constant.numeric.base.haskell +-- ^^^ constant.numeric.value.haskell + + 0x0.01 -- is the same as 1/256 +-- ^^^^^^ meta.number.float.hexadecimal.haskell +-- ^^ constant.numeric.base.haskell +-- ^^^^ constant.numeric.value.haskell + + 0xF.FF -- is the same as 15 + 15/16 + 15/256 +-- ^^^^^^ meta.number.float.hexadecimal.haskell +-- ^^ constant.numeric.base.haskell +-- ^^^^ constant.numeric.value.haskell + + 0x0.1p4 -- is the same as 1 +-- ^^^^^^^ meta.number.float.hexadecimal.haskell +-- ^^ constant.numeric.base.haskell +-- ^^^^^ constant.numeric.value.haskell + + 0x0.1p-4 -- is the same as 1/256 +-- ^^^^^^^^ meta.number.float.hexadecimal.haskell +-- ^^ constant.numeric.base.haskell +-- ^^^^^^ constant.numeric.value.haskell + + 0x0.1p12 -- is the same as 256 +-- ^^^^^^^^ meta.number.float.hexadecimal.haskell +-- ^^ constant.numeric.base.haskell +-- ^^^^^^ constant.numeric.value.haskell + -- [ LITERAL CHARACTERS ] ----------------------------------------------------- From d67647d7962ede22b67b34b7c89da6ecd8de88a3 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 1 Jan 2021 19:34:38 +0100 Subject: [PATCH 142/178] [Haskell] Add support for underscore in numeric linterals see: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/numeric_underscores.html --- Haskell/Haskell.sublime-syntax | 20 ++++++++---- Haskell/syntax_test_haskell.hs | 56 ++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 6 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index ae7059487c..a959acbdb1 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -41,6 +41,14 @@ variables: ){{break}} break: (?![\w'#]) + # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/numeric_underscores.html + bin_digit: '[01_]' + dec_digit: '[\d_]' + hex_digit: '[\h_]' + oct_digit: '[0-7_]' + dec_exponent: (?:[eE][-+]?\d+) + hex_exponent: (?:[pP][-+]?\d+) + # In case this regex seems overly general, note that Haskell permits # the definition of new operators which can be nearly any string # of punctuation characters, such as $%^&*. @@ -1049,7 +1057,7 @@ contexts: literal-numbers: # 2.5 Decimal floating point literals # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-190002.5 - - match: (\d+(?:(\.)\d+(?:[eE][-+]?\d+)?|[eE][-+]?\d+))(#*){{break}} + - match: (\d{{dec_digit}}*(?:(\.){{dec_digit}}+{{dec_exponent}}?|{{dec_exponent}}))(#*){{break}} scope: meta.number.float.decimal.haskell captures: 1: constant.numeric.value.haskell @@ -1057,7 +1065,7 @@ contexts: 3: constant.numeric.suffix.haskell # 6.9.3. Hexadecimal floating point literals # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/hex_float_literals.html - - match: (0[xX])(\h+(\.)\h+(?:[pP][-+]?\d+)?)(#*){{break}} + - match: (0[xX])({{hex_digit}}+(\.){{hex_digit}}+{{hex_exponent}}?)(#*){{break}} scope: meta.number.float.hexadecimal.haskell captures: 1: constant.numeric.base.haskell @@ -1066,7 +1074,7 @@ contexts: 4: constant.numeric.suffix.haskell # 6.9.2. Binary integer literals # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/binary_literals.html - - match: (0[bB])([01]+)(#*){{break}} + - match: (0[bB])({{bin_digit}}+)(#*){{break}} scope: meta.number.integer.binary.haskell captures: 1: constant.numeric.base.haskell @@ -1074,19 +1082,19 @@ contexts: 3: constant.numeric.suffix.haskell # 2.5 Numeric Literals # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-190002.5 - - match: (0[oO])([0-7]+)(#*){{break}} + - match: (0[oO])({{oct_digit}}+)(#*){{break}} scope: meta.number.integer.octal.haskell captures: 1: constant.numeric.base.haskell 2: constant.numeric.value.haskell 3: constant.numeric.suffix.haskell - - match: (0[xX])(\h+)(#*){{break}} + - match: (0[xX])({{hex_digit}}+)(#*){{break}} scope: meta.number.integer.hexadecimal.haskell captures: 1: constant.numeric.base.haskell 2: constant.numeric.value.haskell 3: constant.numeric.suffix.haskell - - match: (\d+)(#*){{break}} + - match: (\d{{dec_digit}}*)(#*){{break}} scope: meta.number.integer.decimal.haskell captures: 1: constant.numeric.value.haskell diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 0b17774340..f8004fa449 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -2722,11 +2722,22 @@ main = do 1234567890 -- ^^^^^^^^^^ meta.number.integer.decimal.haskell constant.numeric.value.haskell + 1_2_34__567890_ +-- ^^^^^^^^^^^^^^^ meta.number.integer.decimal.haskell constant.numeric.value.haskell + + _1234 +-- ^^^^^ - constant.numeric + 1234567890## -- ^^^^^^^^^^^^ meta.number.integer.decimal.haskell -- ^^^^^^^^^^ constant.numeric.value.haskell -- ^^ constant.numeric.suffix.haskell + 1_234_567_890_## +-- ^^^^^^^^^^^^^^^^ meta.number.integer.decimal.haskell +-- ^^^^^^^^^^^^^^ constant.numeric.value.haskell +-- ^^ constant.numeric.suffix.haskell + {- Octal integer literals -} 0o1234567 @@ -2734,12 +2745,23 @@ main = do -- ^^ constant.numeric.base.haskell -- ^^^^^^^ constant.numeric.value.haskell + 0o_1234_567_ +-- ^^^^^^^^^^^^ meta.number.integer.octal.haskell +-- ^^ constant.numeric.base.haskell +-- ^^^^^^^^^^ constant.numeric.value.haskell + 0o1234567# -- ^^^^^^^^^^ meta.number.integer.octal.haskell -- ^^ constant.numeric.base.haskell -- ^^^^^^^ constant.numeric.value.haskell -- ^ constant.numeric.suffix.haskell + 0o_1_234__567_# +-- ^^^^^^^^^^^^^^^ meta.number.integer.octal.haskell +-- ^^ constant.numeric.base.haskell +-- ^^^^^^^^^^^^ constant.numeric.value.haskell +-- ^ constant.numeric.suffix.haskell + {- Decimal floating point literals -} 1. @@ -2770,6 +2792,12 @@ main = do -- ^ punctuation.separator.decimal -- ^ constant.numeric.suffix.haskell + 1_2_._34___5_# +-- ^^^^^^^^^^^^^^ meta.number.float.decimal.haskell +-- ^^^^^^^^^^^^^ constant.numeric.value.haskell +-- ^ punctuation.separator.decimal +-- ^ constant.numeric.suffix.haskell + 1e10 -- ^^^^ meta.number.float.decimal.haskell constant.numeric.value.haskell @@ -2800,6 +2828,11 @@ main = do 0b01010111101 -- ^^^^^^^^^^^^^ meta.number.integer.binary.haskell -- ^^ constant.numeric.base.haskell +-- ^^^^^^^^^^^ constant.numeric.value.haskell + + 0b_10___1110_ +-- ^^^^^^^^^^^^^ meta.number.integer.binary.haskell +-- ^^ constant.numeric.base.haskell -- ^^^^^^^^^^^ constant.numeric.value.haskell 0b0# @@ -2818,6 +2851,12 @@ main = do -- ^^^^^^^^^^^^^^ meta.number.integer.binary.haskell -- ^^ constant.numeric.base.haskell -- ^^^^^^^^^^^ constant.numeric.value.haskell +-- ^ constant.numeric.suffix.haskell + + 0b_10___1110_# +-- ^^^^^^^^^^^^^^ meta.number.integer.binary.haskell +-- ^^ constant.numeric.base.haskell +-- ^^^^^^^^^^^ constant.numeric.value.haskell -- ^ constant.numeric.suffix.haskell {- Hexadecimal integer literals -} @@ -2829,12 +2868,23 @@ main = do 0XdeafBEEF42 -- ^^^^^^^^^^^^ meta.number.integer.hexadecimal.haskell -- ^^ constant.numeric.base.haskell +-- ^^^^^^^^^^ constant.numeric.value.haskell + + 0x__af_EEF4_ +-- ^^^^^^^^^^^^ meta.number.integer.hexadecimal.haskell +-- ^^ constant.numeric.base.haskell -- ^^^^^^^^^^ constant.numeric.value.haskell 0XdeafBEEF42## -- ^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.haskell -- ^^ constant.numeric.base.haskell -- ^^^^^^^^^^ constant.numeric.value.haskell +-- ^^ constant.numeric.suffix.haskell + + 0Xd___BEEF4_## +-- ^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.haskell +-- ^^ constant.numeric.base.haskell +-- ^^^^^^^^^^ constant.numeric.value.haskell -- ^^ constant.numeric.suffix.haskell {- Hexadecimal floating point literals -} @@ -2869,6 +2919,12 @@ main = do -- ^^ constant.numeric.base.haskell -- ^^^^^^ constant.numeric.value.haskell + 0xA_0._1_p12# +-- ^^^^^^^^^^^^^ meta.number.float.hexadecimal.haskell +-- ^^ constant.numeric.base.haskell +-- ^^^^^^^^^^ constant.numeric.value.haskell +-- ^ constant.numeric.suffix.haskell + -- [ LITERAL CHARACTERS ] ----------------------------------------------------- From 99f54a706a597f33353c32df1b2d8a1022cae6ee Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 1 Jan 2021 19:40:37 +0100 Subject: [PATCH 143/178] [Haskell] Add "Safe" pragma constant see: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/safe_haskell.html --- Haskell/Haskell.sublime-syntax | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index a959acbdb1..eb52beb49a 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -126,7 +126,7 @@ variables: | PartialTypeSignatures | PatternGuards | PatternSynonyms | PolyKinds | PolymorphicComponents | QuantifiedConstraints | PostfixOperators | QuasiQuotes | Rank2Types | RankNTypes | RebindableSyntax | RecordWildCards - | RecursiveDo | RelaxedLayout | RoleAnnotations | ScopedTypeVariables + | RecursiveDo | RelaxedLayout | RoleAnnotations | Safe | ScopedTypeVariables | StandaloneDeriving | StarIsType | StaticPointers | Strict | StrictData | TemplateHaskell | TemplateHaskellQuotes | StandaloneKindSignatures | TraditionalRecordSyntax | TransformListComp | TupleSections From 35dc26be7633b5a6a790ce1cb87c36fba6d5329b Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 1 Jan 2021 19:43:10 +0100 Subject: [PATCH 144/178] [Haskell] Add safe imports --- Haskell/Haskell.sublime-syntax | 4 +++- Haskell/syntax_test_haskell.hs | 23 ++++++++++++----------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index eb52beb49a..099226a563 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -447,6 +447,8 @@ contexts: imports: # 5.3 Import Declarations # https://www.haskell.org/onlinereport/haskell2010/haskellch5.html#x11-1010005.3 + # 6.18.3. Safe Imports + # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/safe_haskell.html#safe-imports - match: import{{break}} scope: meta.import.haskell keyword.declaration.import.haskell push: @@ -458,7 +460,7 @@ contexts: - match: as{{break}} scope: keyword.declaration.import.as.haskell set: import-alias - - match: (?:qualified|hiding){{break}} + - match: (?:qualified|hiding|safe){{break}} scope: storage.modifier.import.haskell - match: ({{con_id}})(\.)? captures: diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index f8004fa449..753613b371 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -487,19 +487,20 @@ -- ^ punctuation.terminator.statement.haskell -- ^^^^^^ meta.import.haskell keyword.declaration.import.haskell - import qualified Data.Vector.Mutable as MutableVector + import safe qualified Data.Vector.Mutable as MutableVector -- ^^^^^^ meta.import.haskell --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.module.haskell --- ^^^^^^^^^^^^^^^^ meta.import.alias.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.module.haskell +-- ^^^^^^^^^^^^^^^^ meta.import.alias.haskell -- ^^^^^^ keyword.declaration.import.haskell --- ^^^^^^^^^ storage.modifier.import.haskell --- ^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^ variable.namespace.haskell - punctuation --- ^ punctuation.accessor.dot.haskell - variable --- ^^^^^^^ variable.namespace.haskell - punctuation --- ^^ keyword.declaration.import.as.haskell --- ^^^^^^^^^^^^^ entity.name.import.namespace.haskell +-- ^^^^ storage.modifier.import.haskell +-- ^^^^^^^^^ storage.modifier.import.haskell +-- ^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^^ variable.namespace.haskell - punctuation +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^^^^^^ variable.namespace.haskell - punctuation +-- ^^ keyword.declaration.import.as.haskell +-- ^^^^^^^^^^^^^ entity.name.import.namespace.haskell import -- ^^^^^^ meta.import.haskell keyword.declaration.import.haskell From 86ac6c52db4784f32e8c381f4d9ef20ab800bccb Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 1 Jan 2021 19:57:02 +0100 Subject: [PATCH 145/178] [Haskell] Remove obsolete context --- Haskell/Haskell.sublime-syntax | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 099226a563..f1c02ae602 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -1041,13 +1041,6 @@ contexts: 1: storage.modifier.unboxed.haskell pop: 1 - ident-functions: - - include: ident-builtin-functions - - match: '{{var_id}}' - scope: variable.function.haskell - captures: - 1: storage.modifier.unboxed.haskell - ident-variables: - match: '{{var_id}}' scope: variable.other.haskell From 71ab1c5e99507ac9caade562feebafb7f1c3256b Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 1 Jan 2021 20:00:21 +0100 Subject: [PATCH 146/178] [Haskell] Update pragma value highlighting --- Haskell/Haskell.sublime-syntax | 9 +++++---- Haskell/syntax_test_haskell.hs | 25 ++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index f1c02ae602..bd83c8fa19 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -300,11 +300,11 @@ contexts: - match: (?:OPTIONS_GHC|OPTIONS_HADDOCK){{break}} scope: keyword.directive.options.haskell set: preprocessor-pragma-options-value - - match: (?:SPECIALISE|SPECIALIZE){{break}} + - match: (?:INLINE|INLINABLE|MINIMAL|NOINLINE|SPECIALISE|SPECIALIZE){{break}} scope: meta.preprocessor.pragma.directive.haskell keyword.directive.builtin.haskell - embed: preprocessor-pragma-specialize-value + embed: preprocessor-pragma-signature-value pop: 1 escape: '#-\}' escape_captures: @@ -336,10 +336,11 @@ contexts: captures: 1: punctuation.definition.constant.haskell - preprocessor-pragma-specialize-value: + preprocessor-pragma-signature-value: - meta_include_prototype: false - - meta_content_scope: meta.preprocessor.pragma.value.specialize.haskell + - meta_content_scope: meta.preprocessor.pragma.value.signature.haskell - include: comments + - include: sequence-separators - include: functions - include: type-expressions diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 753613b371..65bb96a8e6 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -127,13 +127,13 @@ {-# INLINABLE unless #-} -- ^^^^^^^^^^^^^ meta.preprocessor.pragma.directive.haskell --- ^^^^^^^^ meta.preprocessor.pragma.value.other.haskell +-- ^^^^^^^^ meta.preprocessor.pragma.value.signature.haskell -- ^^^ meta.preprocessor.pragma.value.haskell -- ^ - meta.preprocessor.haskell {-# MINIMAL traverse | sequenceA LANGUAGE #-} -- ^^^^^^^^^^^ meta.preprocessor.pragma.directive.haskell --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.pragma.value.other.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.pragma.value.signature.haskell -- ^^^ meta.preprocessor.pragma.value.haskell -- ^ - meta.preprocessor.haskell -- ^^^ punctuation.section.preprocessor.begin.haskell @@ -175,6 +175,16 @@ #-} -- ^^^ meta.preprocessor.pragma.value.haskell punctuation.section.preprocessor.end.haskell + {-# LINE 42 "Foo.vhs" #-} +-- ^^^^^^^^ meta.preprocessor.pragma.directive.haskell +-- ^^^^^^^^^^^^^^ meta.preprocessor.pragma.value.other.haskell +-- ^^^ meta.preprocessor.pragma.value.haskell +-- ^^^ punctuation.section.preprocessor.begin.haskell +-- ^^^^ keyword.directive.builtin.haskell +-- ^^ constant.numeric.value.haskell +-- ^^^^^^^^^ meta.string.haskell string.quoted.double.haskell +-- ^^^ punctuation.section.preprocessor.end.haskell + {-# OPTIONS_GHC -Drelease #-} -- ^^^^^^^^^^^^^^^ meta.preprocessor.pragma.directive.haskell -- ^^^^^^^^^^^ meta.preprocessor.pragma.value.options.haskell @@ -198,7 +208,7 @@ {-# SPECIALISE unless :: Bool -> IO () -> IO () #-} -- ^^^^^^^^^^^^^^ meta.preprocessor.pragma.directive.haskell --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.pragma.value.specialize.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.pragma.value.signature.haskell -- ^^^ meta.preprocessor.pragma.value.haskell -- ^^^ punctuation.section.preprocessor.begin.haskell -- ^^^^^^^^^^ keyword.directive.builtin.haskell @@ -219,6 +229,15 @@ -- ^^^^^^^^^^^^^^^ meta.string.haskell string.quoted.double.haskell -- ^^^ punctuation.section.preprocessor.end.haskell + module Wibble {-# DEPRECATED "Use Wobble instead" #-} where +-- ^^^^^^^^^^^^^^ meta.declaration.module.haskell meta.preprocessor.pragma.directive.haskell +-- ^^^^^^^^^^^^^^^^^^^^^ meta.declaration.module.haskell meta.preprocessor.pragma.value.other.haskell +-- ^^^ meta.declaration.module.haskell meta.preprocessor.pragma.value.haskell +-- ^^^ punctuation.section.preprocessor.begin.haskell +-- ^^^^^^^^^^ keyword.directive.builtin.haskell +-- ^^^^^^^^^^^^^^^^^^^^ string.quoted.double.haskell +-- ^^^ punctuation.section.preprocessor.end.haskell + #if 0 -- ^^^ meta.preprocessor.c -- ^ punctuation.definition.preprocessor.c From a10d59399ae176ae56a11f5a9fb68e4f76fdbf37 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 1 Jan 2021 21:09:49 +0100 Subject: [PATCH 147/178] [Haskell] Add SPECIALIZE INLINE pragma support --- Haskell/Haskell.sublime-syntax | 17 ++++++++++++++--- Haskell/syntax_test_haskell.hs | 21 +++++++++++---------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index bd83c8fa19..29ea214816 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -283,8 +283,8 @@ contexts: 2: punctuation.definition.preprocessor.c preprocessor-pragmas: - # 12 Compiler Pragmas - # https://www.haskell.org/onlinereport/haskell2010/haskellch12.html#x19-18800012 + # GHC 6.20 Pragmas + # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/pragmas.html - match: \{-# scope: punctuation.section.preprocessor.begin.haskell push: preprocessor-pragma-body @@ -300,7 +300,7 @@ contexts: - match: (?:OPTIONS_GHC|OPTIONS_HADDOCK){{break}} scope: keyword.directive.options.haskell set: preprocessor-pragma-options-value - - match: (?:INLINE|INLINABLE|MINIMAL|NOINLINE|SPECIALISE|SPECIALIZE){{break}} + - match: (?:INLINE|INLINABLE|MINIMAL|NOINLINE){{break}} scope: meta.preprocessor.pragma.directive.haskell keyword.directive.builtin.haskell @@ -310,6 +310,17 @@ contexts: escape_captures: 0: meta.preprocessor.pragma.value.haskell punctuation.section.preprocessor.end.haskell + - match: (SPECIALISE|SPECIALIZE)(?:\s+(INLINE|NOINLINE))?{{break}} + scope: meta.preprocessor.pragma.directive.haskell + captures: + 1: keyword.directive.builtin.haskell + 2: keyword.directive.builtin.haskell + embed: preprocessor-pragma-signature-value + pop: 1 + escape: '#-\}' + escape_captures: + 0: meta.preprocessor.pragma.value.haskell + punctuation.section.preprocessor.end.haskell - match: '{{pragma_keys}}' scope: keyword.directive.builtin.haskell set: preprocessor-pragma-other-value diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 65bb96a8e6..dbcd24f9e5 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -206,18 +206,19 @@ -- ^^^^^^^^ constant.other.pragma.haskell -- ^^^ punctuation.section.preprocessor.end.haskell - {-# SPECIALISE unless :: Bool -> IO () -> IO () #-} --- ^^^^^^^^^^^^^^ meta.preprocessor.pragma.directive.haskell --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.pragma.value.signature.haskell --- ^^^ meta.preprocessor.pragma.value.haskell + {-# SPECIALISE INLINE unless :: Bool -> IO () -> IO () #-} +-- ^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.pragma.directive.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.pragma.value.signature.haskell +-- ^^^ meta.preprocessor.pragma.value.haskell -- ^^^ punctuation.section.preprocessor.begin.haskell -- ^^^^^^^^^^ keyword.directive.builtin.haskell --- ^^^^^^ entity.name.function.haskell --- ^^ keyword.operator.double-colon.haskell --- ^^^^ support.type.prelude.haskell --- ^^ keyword.operator.arrow.haskell --- ^^ support.type.prelude.haskell --- ^^^ punctuation.section.preprocessor.end.haskell +-- ^^^^^^ keyword.directive.builtin.haskell +-- ^^^^^^ entity.name.function.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^^^^ support.type.prelude.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^^ support.type.prelude.haskell +-- ^^^ punctuation.section.preprocessor.end.haskell {-# WARNING "Not supported" #-} -- ^^^^^^^^^^^ meta.preprocessor.pragma.directive.haskell From 3bc753558391b83e4c35fe44d1b0f3c6f47bd757 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 1 Jan 2021 21:14:56 +0100 Subject: [PATCH 148/178] [Haskell] Add SPECIALIZE instance pragma support --- Haskell/Haskell.sublime-syntax | 3 ++- Haskell/syntax_test_haskell.hs | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 29ea214816..d6b83372c6 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -310,11 +310,12 @@ contexts: escape_captures: 0: meta.preprocessor.pragma.value.haskell punctuation.section.preprocessor.end.haskell - - match: (SPECIALISE|SPECIALIZE)(?:\s+(INLINE|NOINLINE))?{{break}} + - match: (SPECIALISE|SPECIALIZE)(?:\s+(?:(INLINE|NOINLINE)|(instance)))?{{break}} scope: meta.preprocessor.pragma.directive.haskell captures: 1: keyword.directive.builtin.haskell 2: keyword.directive.builtin.haskell + 3: keyword.declaration.instance.haskell embed: preprocessor-pragma-signature-value pop: 1 escape: '#-\}' diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index dbcd24f9e5..78a3b218c4 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -220,6 +220,15 @@ -- ^^ support.type.prelude.haskell -- ^^^ punctuation.section.preprocessor.end.haskell + {-# SPECIALIZE instance Eq (Foo [(Int, Bar)]) #-} +-- ^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.pragma.directive.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.pragma.value.signature.haskell +-- ^^^ meta.preprocessor.pragma.value.haskell +-- ^^^ punctuation.section.preprocessor.begin.haskell +-- ^^^^^^^^^^ keyword.directive.builtin.haskell +-- ^^^^^^^^ keyword.declaration.instance.haskell +-- ^^^ punctuation.section.preprocessor.end.haskell + {-# WARNING "Not supported" #-} -- ^^^^^^^^^^^ meta.preprocessor.pragma.directive.haskell -- ^^^^^^^^^^^^^^^^^ meta.preprocessor.pragma.value.other.haskell From 94f4931dcfbe9e5324c6d42d31f0b6b5100fc3e4 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 1 Jan 2021 21:19:56 +0100 Subject: [PATCH 149/178] [Haskell] Add COMPLETE pragma --- Haskell/Haskell.sublime-syntax | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index d6b83372c6..7f734d039a 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -87,7 +87,7 @@ variables: LANGUAGE | OPTIONS_GHC | OPTIONS_HADDOCK | INCLUDE | WARNING | DEPRECATED | MINIMAL | UNPACK | NOUNPACK | SOURCE | OVERLAPPING | OVERLAPPABLE | OVERLAPS | INCOHERENT | INLINE | NOINLINE | INLINABLE | CONLIKE | LINE - | RULES | SPECIALIZE | SPECIALISE + | RULES | SPECIALIZE | SPECIALISE | COMPLETE ){{break}} # https://wiki.haskell.org/Language_extensions @@ -300,7 +300,7 @@ contexts: - match: (?:OPTIONS_GHC|OPTIONS_HADDOCK){{break}} scope: keyword.directive.options.haskell set: preprocessor-pragma-options-value - - match: (?:INLINE|INLINABLE|MINIMAL|NOINLINE){{break}} + - match: (?:COMPLETE|INLINE|INLINABLE|MINIMAL|NOINLINE){{break}} scope: meta.preprocessor.pragma.directive.haskell keyword.directive.builtin.haskell From 06148ba50d6169ed205554a3563305352b2a4497 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 1 Jan 2021 21:28:35 +0100 Subject: [PATCH 150/178] [Haskell] Add COLUMN pragma --- Haskell/Haskell.sublime-syntax | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 7f734d039a..3051c70f3c 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -87,7 +87,7 @@ variables: LANGUAGE | OPTIONS_GHC | OPTIONS_HADDOCK | INCLUDE | WARNING | DEPRECATED | MINIMAL | UNPACK | NOUNPACK | SOURCE | OVERLAPPING | OVERLAPPABLE | OVERLAPS | INCOHERENT | INLINE | NOINLINE | INLINABLE | CONLIKE | LINE - | RULES | SPECIALIZE | SPECIALISE | COMPLETE + | RULES | SPECIALIZE | SPECIALISE | COMPLETE | COLUMN ){{break}} # https://wiki.haskell.org/Language_extensions From 8ea64daf178da4c2245e2c8f74f9254a336c3af3 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sat, 2 Jan 2021 10:54:47 +0100 Subject: [PATCH 151/178] [Haskell] Tweak symbol list and index definitions This commit... 1. moves all index definitions to: a) Indexed Symbol List b) Indexed Reference List 2. uses "Symbol List - ...tmPreferences" for symbol list definitions, only. 3. removes "Symbol List - Modules" as `entity.name.namespace` is already defined as symbol/index by Default.sublime-package. 4. Adds some entries to syntax tests to verify goto definition. --- Haskell/Indexed Reference List.tmPreferences | 15 +++++++++++++++ ...nces => Indexed Symbol List.tmPreferences} | 6 +++--- .../Reference List - Operators.tmPreferences | 12 ------------ Haskell/Symbol List - Exports.tmPreferences | 4 +--- Haskell/Symbol List - Imports.tmPreferences | 4 +--- Haskell/Symbol List - Operators.tmPreferences | 19 +++++++------------ Haskell/syntax_test_haskell.hs | 17 ++++++++++++----- 7 files changed, 39 insertions(+), 38 deletions(-) create mode 100644 Haskell/Indexed Reference List.tmPreferences rename Haskell/{Symbol List - Modules.tmPreferences => Indexed Symbol List.tmPreferences} (60%) delete mode 100644 Haskell/Reference List - Operators.tmPreferences diff --git a/Haskell/Indexed Reference List.tmPreferences b/Haskell/Indexed Reference List.tmPreferences new file mode 100644 index 0000000000..fd8bea0c98 --- /dev/null +++ b/Haskell/Indexed Reference List.tmPreferences @@ -0,0 +1,15 @@ + + + + scope + + source.haskell keyword.operator - meta.function.identifier, + source.haskell variable.other + + settings + + showInIndexedReferenceList + 1 + + + diff --git a/Haskell/Symbol List - Modules.tmPreferences b/Haskell/Indexed Symbol List.tmPreferences similarity index 60% rename from Haskell/Symbol List - Modules.tmPreferences rename to Haskell/Indexed Symbol List.tmPreferences index 83be88b927..0aa0cebf30 100644 --- a/Haskell/Symbol List - Modules.tmPreferences +++ b/Haskell/Indexed Symbol List.tmPreferences @@ -2,11 +2,11 @@ scope - meta.declaration.module.haskell entity.name.namespace.haskell + + source.haskell meta.function.identifier meta.group keyword.operator + settings - showInSymbolList - 1 showInIndexedSymbolList 1 diff --git a/Haskell/Reference List - Operators.tmPreferences b/Haskell/Reference List - Operators.tmPreferences deleted file mode 100644 index 0e25b1d2ff..0000000000 --- a/Haskell/Reference List - Operators.tmPreferences +++ /dev/null @@ -1,12 +0,0 @@ - - - - scope - source.haskell keyword.operator - meta.function.identifier - settings - - showInIndexedReferenceList - 1 - - - diff --git a/Haskell/Symbol List - Exports.tmPreferences b/Haskell/Symbol List - Exports.tmPreferences index ab0061905c..19a6682c8c 100644 --- a/Haskell/Symbol List - Exports.tmPreferences +++ b/Haskell/Symbol List - Exports.tmPreferences @@ -2,13 +2,11 @@ scope - meta.declaration.module.haskell entity.name.export.haskell + source.haskell entity.name.export settings showInSymbolList 1 - showInIndexedSymbolList - 1 diff --git a/Haskell/Symbol List - Imports.tmPreferences b/Haskell/Symbol List - Imports.tmPreferences index 36309a991f..4bc5611385 100644 --- a/Haskell/Symbol List - Imports.tmPreferences +++ b/Haskell/Symbol List - Imports.tmPreferences @@ -2,13 +2,11 @@ scope - source.haskell meta.import entity.name.import + source.haskell entity.name.import settings showInSymbolList 1 - showInIndexedSymbolList - 0 diff --git a/Haskell/Symbol List - Operators.tmPreferences b/Haskell/Symbol List - Operators.tmPreferences index d09a74426a..c92cb95695 100644 --- a/Haskell/Symbol List - Operators.tmPreferences +++ b/Haskell/Symbol List - Operators.tmPreferences @@ -1,17 +1,12 @@ - scope - - meta.declaration.module.haskell meta.sequence keyword.operator - meta.function.identifier.haskell meta.group keyword.operator - - settings - - showInSymbolList - 1 - showInIndexedSymbolList - 1 - + scope + source.haskell meta.function.identifier meta.group keyword.operator + settings + + showInSymbolList + 1 + diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 78a3b218c4..32fe5d77b3 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -2037,9 +2037,12 @@ -- ^^^^ meta.function.identifier.haskell -- ^^^ entity.name.function.haskell -- ^^ keyword.operator.double-colon.haskell + fun = print "Hello" +-- ^^^ variable.other.haskell +-- ^ keyword.operator.haskell {- Module Level Function Declarations with Block Layout -} - module ModId.ModName (fun1, fun2) where { fun1 :: Bool -> Bool ; fun2 :: } + module ModId.ModName (fun1, fun2) where { fun1 :: Bool -> Bool ; fun1 = False ; fun2 :: } -- ^^^^^^^^^^^^ meta.declaration.module.haskell meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^^ entity.name.export.haskell @@ -2047,7 +2050,7 @@ -- ^^^^ entity.name.export.haskell -- ^ punctuation.section.sequence.end.haskell -- ^^^^^ keyword.control.context.haskell --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.haskell -- ^ punctuation.section.block.begin.haskell -- ^^^^^ meta.function.identifier.haskell -- ^^^^ entity.name.function.haskell @@ -2056,9 +2059,13 @@ -- ^^ keyword.operator.arrow.haskell -- ^^^^ support.type.prelude.haskell -- ^ punctuation.terminator.statement.haskell --- ^^^^ entity.name.function.haskell --- ^^ keyword.operator.double-colon.haskell --- ^ punctuation.section.block.end.haskell +-- ^^^^ variable.other.haskell +-- ^ keyword.operator.haskell +-- ^^^^^ support.constant.prelude.haskell +-- ^ punctuation.terminator.statement.haskell +-- ^^^^ entity.name.function.haskell +-- ^^ keyword.operator.double-colon.haskell +-- ^ punctuation.section.block.end.haskell {- Class Method Declarations -} class TyCls a where From 55cdbf48d48d5bef5b32cec61e87b3750366b75f Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sat, 2 Jan 2021 11:15:47 +0100 Subject: [PATCH 152/178] [Haskell] Tweak Pragma Directives 1. Sort directives by definition in GHC 6.20 2. Remove old misspelled SPECIALISE directive 3. rename pragma_keys to pragma_directives --- Haskell/Haskell.sublime-syntax | 15 ++++++++------- Haskell/syntax_test_haskell.hs | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 3051c70f3c..139e1c0ad3 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -81,13 +81,14 @@ variables: | (\^[A-Z@\[\]\\\^_]) # Control Chars ) - # https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#pragmas - pragma_keys: |- + # GHC 6.20. Pragmas + # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/pragmas.html + pragma_directives: |- (?x: LANGUAGE | OPTIONS_GHC | OPTIONS_HADDOCK | INCLUDE | WARNING | DEPRECATED - | MINIMAL | UNPACK | NOUNPACK | SOURCE | OVERLAPPING | OVERLAPPABLE - | OVERLAPS | INCOHERENT | INLINE | NOINLINE | INLINABLE | CONLIKE | LINE - | RULES | SPECIALIZE | SPECIALISE | COMPLETE | COLUMN + | MINIMAL | INLINE | NOINLINE | INLINABLE | CONLIKE | LINE | COLUMN | RULES + | SPECIALIZE | UNPACK | NOUNPACK | SOURCE | COMPLETE | OVERLAPPING + | OVERLAPPABLE | OVERLAPS | INCOHERENT ){{break}} # https://wiki.haskell.org/Language_extensions @@ -310,7 +311,7 @@ contexts: escape_captures: 0: meta.preprocessor.pragma.value.haskell punctuation.section.preprocessor.end.haskell - - match: (SPECIALISE|SPECIALIZE)(?:\s+(?:(INLINE|NOINLINE)|(instance)))?{{break}} + - match: (SPECIALIZE)(?:\s+(?:(INLINE|NOINLINE)|(instance)))?{{break}} scope: meta.preprocessor.pragma.directive.haskell captures: 1: keyword.directive.builtin.haskell @@ -322,7 +323,7 @@ contexts: escape_captures: 0: meta.preprocessor.pragma.value.haskell punctuation.section.preprocessor.end.haskell - - match: '{{pragma_keys}}' + - match: '{{pragma_directives}}' scope: keyword.directive.builtin.haskell set: preprocessor-pragma-other-value # maybe incomplete directive diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 32fe5d77b3..0df886b4b1 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -206,7 +206,7 @@ -- ^^^^^^^^ constant.other.pragma.haskell -- ^^^ punctuation.section.preprocessor.end.haskell - {-# SPECIALISE INLINE unless :: Bool -> IO () -> IO () #-} + {-# SPECIALIZE INLINE unless :: Bool -> IO () -> IO () #-} -- ^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.pragma.directive.haskell -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.pragma.value.signature.haskell -- ^^^ meta.preprocessor.pragma.value.haskell From d7e4862c290bb575675ba7bc63abe0a03d054fd3 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sat, 2 Jan 2021 11:26:38 +0100 Subject: [PATCH 153/178] [Haskell] Improve FFI capabilities --- Haskell/Haskell.sublime-syntax | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 139e1c0ad3..d67de3b6fe 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -88,7 +88,7 @@ variables: LANGUAGE | OPTIONS_GHC | OPTIONS_HADDOCK | INCLUDE | WARNING | DEPRECATED | MINIMAL | INLINE | NOINLINE | INLINABLE | CONLIKE | LINE | COLUMN | RULES | SPECIALIZE | UNPACK | NOUNPACK | SOURCE | COMPLETE | OVERLAPPING - | OVERLAPPABLE | OVERLAPS | INCOHERENT + | OVERLAPPABLE | OVERLAPS | INCOHERENT | CTYPE ){{break}} # https://wiki.haskell.org/Language_extensions @@ -187,10 +187,16 @@ variables: | zipWith3 ){{break}} - # 6.2.2. The magic hash - # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/magic_hash.html unboxed_types: |- - (?x: Addr | Array | Char | Double | Float | Int | Word )(#){{break}} + (?x: + # GHC 6.2.2. The magic hash + # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/magic_hash.html + Addr | Array | Char | Double | Float | Int | Word + # GHC 6.17.2.1. Unlifted FFI Types + # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/ffi.html + | ArrayArray | ByteArray | SmallArray | StablePtr + | Mutable (?: ArrayArray | ByteArray | SmallArray) + )(#){{break}} ############################################################################### @@ -532,6 +538,8 @@ contexts: foreigns: # 8.4 Foreign Declarations # https://www.haskell.org/onlinereport/haskell2010/haskellch8.html#x15-1490008 + # GHC 6.17. Foreign function interface (FFI) + # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/ffi.html - match: foreign{{break}} scope: storage.modifier.foreign.haskell branch_point: foreign @@ -546,7 +554,7 @@ contexts: fail: foreign - match: import{{break}} scope: keyword.declaration.import.haskell - - match: (?:unsafe|safe){{break}} + - match: (?:interruptible|unsafe|safe){{break}} scope: storage.modifier.import.haskell - include: foreign-common @@ -555,14 +563,14 @@ contexts: - meta_scope: meta.declaration.foreign.export.haskell - match: export{{break}} scope: keyword.declaration.export.haskell - - match: (?:unsafe|safe){{break}} + - match: (?:interruptible|unsafe|safe){{break}} scope: invalid.illegal.unexpected-keyword.haskell - include: foreign-common foreign-common: - include: literal-strings - include: infix-parens-operators - - match: (?:ccall|cplusplus|dotnet|jvm|stdcall){{break}} + - match: (?:capi|ccall|cplusplus|dotnet|jvm|stdcall){{break}} scope: constant.language.convention.haskell - match: '{{var_id}}' scope: entity.name.function.haskell From cffa27dc2d7afa8eb84a2fb3fcb477662ac845e9 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sat, 2 Jan 2021 11:32:59 +0100 Subject: [PATCH 154/178] [Haskell] Tweak specification comments Mark all links to Haskell's Gitlab User Guide as `GHC`. --- Haskell/Haskell.sublime-syntax | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index d67de3b6fe..5c78222c7e 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -41,6 +41,7 @@ variables: ){{break}} break: (?![\w'#]) + # GHC 6.9.5 Numeric underscores # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/numeric_underscores.html bin_digit: '[01_]' dec_digit: '[\d_]' @@ -81,7 +82,7 @@ variables: | (\^[A-Z@\[\]\\\^_]) # Control Chars ) - # GHC 6.20. Pragmas + # GHC 6.20 Pragmas # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/pragmas.html pragma_directives: |- (?x: @@ -189,10 +190,10 @@ variables: unboxed_types: |- (?x: - # GHC 6.2.2. The magic hash + # GHC 6.2.2 The magic hash # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/magic_hash.html Addr | Array | Char | Double | Float | Int | Word - # GHC 6.17.2.1. Unlifted FFI Types + # GHC 6.17.2.1 Unlifted FFI Types # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/ffi.html | ArrayArray | ByteArray | SmallArray | StablePtr | Mutable (?: ArrayArray | ByteArray | SmallArray) @@ -467,7 +468,7 @@ contexts: imports: # 5.3 Import Declarations # https://www.haskell.org/onlinereport/haskell2010/haskellch5.html#x11-1010005.3 - # 6.18.3. Safe Imports + # GHC 6.18.3 Safe Imports # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/safe_haskell.html#safe-imports - match: import{{break}} scope: meta.import.haskell keyword.declaration.import.haskell @@ -538,7 +539,7 @@ contexts: foreigns: # 8.4 Foreign Declarations # https://www.haskell.org/onlinereport/haskell2010/haskellch8.html#x15-1490008 - # GHC 6.17. Foreign function interface (FFI) + # GHC 6.17 Foreign function interface (FFI) # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/ffi.html - match: foreign{{break}} scope: storage.modifier.foreign.haskell @@ -976,7 +977,7 @@ contexts: 2: punctuation.section.sequence.end.haskell unboxed-tuples: - # 6.16.3. Unboxed tuples + # GHC 6.16.3 Unboxed tuples # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/primitives.html#unboxed-tuples - match: (\()(#) captures: @@ -1080,7 +1081,7 @@ contexts: 1: constant.numeric.value.haskell 2: punctuation.separator.decimal.haskell 3: constant.numeric.suffix.haskell - # 6.9.3. Hexadecimal floating point literals + # GHC 6.9.3 Hexadecimal floating point literals # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/hex_float_literals.html - match: (0[xX])({{hex_digit}}+(\.){{hex_digit}}+{{hex_exponent}}?)(#*){{break}} scope: meta.number.float.hexadecimal.haskell @@ -1089,7 +1090,7 @@ contexts: 2: constant.numeric.value.haskell 3: punctuation.separator.decimal.haskell 4: constant.numeric.suffix.haskell - # 6.9.2. Binary integer literals + # GHC 6.9.2 Binary integer literals # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/binary_literals.html - match: (0[bB])({{bin_digit}}+)(#*){{break}} scope: meta.number.integer.binary.haskell From cf5cfaa20ddc6cf2c97af1714581bbeed794a6be Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sat, 2 Jan 2021 12:09:36 +0100 Subject: [PATCH 155/178] [Haskell] Tweak prefix operators This commit tries to create parity with backticked infix operators. As those are scoped `meta.infix` this commit turns operators in prefix position into `meta.prefix` rather than scoping them as ordinary group. This enables color schemes to apply special highlighting if desired. --- Haskell/Haskell.sublime-syntax | 35 ++-- Haskell/Indexed Symbol List.tmPreferences | 2 +- Haskell/Symbol List - Operators.tmPreferences | 2 +- Haskell/syntax_test_haskell.hs | 151 +++++++++--------- 4 files changed, 103 insertions(+), 87 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 5c78222c7e..d7e9006ec9 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -417,7 +417,8 @@ contexts: module-export-body: - meta_scope: meta.sequence.tuple.haskell - include: tuple-end - - include: infix-parens-operators + - include: range-tuples + - include: prefix-parens-operators - include: sequence-separators - include: ident-namespaces - match: \( @@ -513,7 +514,8 @@ contexts: import-tuple-body: - meta_scope: meta.sequence.tuple.haskell - include: tuple-end - - include: infix-parens-operators + - include: range-tuples + - include: prefix-parens-operators - include: sequence-separators - match: \( scope: punctuation.section.sequence.begin.haskell @@ -570,7 +572,7 @@ contexts: foreign-common: - include: literal-strings - - include: infix-parens-operators + - include: prefix-parens-operators - match: (?:capi|ccall|cplusplus|dotnet|jvm|stdcall){{break}} scope: constant.language.convention.haskell - match: '{{var_id}}' @@ -714,16 +716,16 @@ contexts: scope: entity.name.function.haskell captures: 1: storage.modifier.unboxed.haskell - - include: infix-parens-operators + - include: prefix-parens-operators - include: sequence-separators variable-name: - match: (\()\s*({{operator_parens}})\s*(\)) - scope: meta.group.haskell + scope: meta.prefix.haskell captures: - 1: punctuation.section.group.begin.haskell + 1: punctuation.definition.prefix.begin.haskell 2: keyword.operator.haskell - 3: punctuation.section.group.end.haskell + 3: punctuation.definition.prefix.end.haskell push: variable-name-end - match: '{{prelude_functions}}' scope: support.function.prelude.haskell @@ -811,6 +813,7 @@ contexts: # 4.1.3 Syntax of Class Assertions and Contexts # https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-630004.1 - include: empty-tuples + - include: prefix-parens-operators - match: (?=\() branch_point: type-parens branch: @@ -925,6 +928,7 @@ contexts: # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-360003.8 - include: empty-tuples - include: unboxed-tuples + - include: prefix-parens-operators - match: (?=\() branch_point: parens branch: @@ -976,6 +980,14 @@ contexts: 1: punctuation.section.sequence.begin.haskell 2: punctuation.section.sequence.end.haskell + range-tuples: + - match: (\()\s*(\.\.)\s*(\)) + scope: meta.sequence.tuple.haskell + captures: + 1: punctuation.section.sequence.begin.haskell + 2: keyword.operator.haskell + 3: punctuation.section.sequence.end.haskell + unboxed-tuples: # GHC 6.16.3 Unboxed tuples # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/primitives.html#unboxed-tuples @@ -1183,6 +1195,7 @@ contexts: - include: big-arrow-operators - include: left-arrow-operators - include: right-arrow-operators + - include: prefix-parens-operators - include: infix-quoted-operators # Match all not otherwise matched single quotes as promoition operator # Note: Found in real world code but not in specs so far. @@ -1205,13 +1218,13 @@ contexts: - match: '{{operator_right_arrow}}' scope: keyword.operator.arrow.haskell - infix-parens-operators: + prefix-parens-operators: - match: (\()\s*({{operator_parens}})\s*(\)) - scope: meta.group.haskell + scope: meta.prefix.haskell captures: - 1: punctuation.section.group.begin.haskell + 1: punctuation.definition.prefix.begin.haskell 2: keyword.operator.haskell - 3: punctuation.section.group.end.haskell + 3: punctuation.definition.prefix.end.haskell infix-quoted-operators: - match: (`)\s*([\w'.]*(#*))\s*(`) diff --git a/Haskell/Indexed Symbol List.tmPreferences b/Haskell/Indexed Symbol List.tmPreferences index 0aa0cebf30..328484c5b2 100644 --- a/Haskell/Indexed Symbol List.tmPreferences +++ b/Haskell/Indexed Symbol List.tmPreferences @@ -3,7 +3,7 @@ scope - source.haskell meta.function.identifier meta.group keyword.operator + source.haskell meta.function.identifier meta.prefix keyword.operator settings diff --git a/Haskell/Symbol List - Operators.tmPreferences b/Haskell/Symbol List - Operators.tmPreferences index c92cb95695..1be1f355a3 100644 --- a/Haskell/Symbol List - Operators.tmPreferences +++ b/Haskell/Symbol List - Operators.tmPreferences @@ -2,7 +2,7 @@ scope - source.haskell meta.function.identifier meta.group keyword.operator + source.haskell meta.function.identifier meta.prefix keyword.operator settings showInSymbolList diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 0df886b4b1..ef01292a47 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -312,9 +312,9 @@ module Ns.Name (sym1, Sym2, sym2#, Sym3#, (<:>)) where { import Ns.Other; import Ns.Other2 } -- ^^^^^^^^^^^^^^^ meta.declaration.module.haskell - meta.sequence --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.module.haskell meta.sequence.tuple.haskell - meta.group --- ^^^^^ meta.declaration.module.haskell meta.sequence.tuple.haskell meta.group.haskell --- ^ meta.declaration.module.haskell meta.sequence.tuple.haskell - meta.group +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.module.haskell meta.sequence.tuple.haskell - meta.prefix +-- ^^^^^ meta.declaration.module.haskell meta.sequence.tuple.haskell meta.prefix.haskell +-- ^ meta.declaration.module.haskell meta.sequence.tuple.haskell - meta.prefix -- ^ meta.declaration.module.haskell - meta.sequence -- ^^^^^ - meta.declaration.module - meta.block - meta.sequence -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.haskell - meta.declaration.module @@ -334,9 +334,9 @@ -- ^^^^^ entity.name.export.haskell -- ^ storage.modifier.unboxed.haskell -- ^ punctuation.separator.sequence.haskell --- ^ punctuation.section.group.begin.haskell +-- ^ punctuation.definition.prefix.begin.haskell -- ^^^ keyword.operator.haskell --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.definition.prefix.end.haskell -- ^ punctuation.section.sequence.end.haskell -- ^^^^^ keyword.control.context.haskell -- ^ punctuation.section.block.begin.haskell @@ -577,7 +577,7 @@ -- ^^^^^^ meta.import.haskell - meta.sequence -- ^^^^^^^^^^^^^^^^^^ meta.import.module.haskell - meta.sequence -- ^^^^^^^^^^ meta.import.filter.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence --- ^^^^ meta.import.filter.haskell meta.sequence.tuple.haskell meta.group.haskell +-- ^^^^ meta.import.filter.haskell meta.sequence.tuple.haskell meta.sequence.tuple.haskell -- ^ meta.import.filter.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence -- ^ - meta.import -- ^^^^^^ keyword.declaration.import.haskell @@ -588,9 +588,9 @@ -- ^^^^^^ variable.namespace.haskell - punctuation -- ^ punctuation.section.sequence.begin.haskell -- ^^^^^^^^^ entity.name.import.haskell --- ^ punctuation.section.group.begin.haskell +-- ^ punctuation.section.sequence.begin.haskell -- ^^ keyword.operator.haskell --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.section.sequence.end.haskell -- ^ punctuation.section.sequence.end.haskell import Mod1.Mod2.Module (ClassName (SubClass), funcName) @@ -666,15 +666,15 @@ -- ^^^^^^^^^^^^^^^^^^ meta.import.module.haskell - meta.sequence -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.filter.haskell meta.sequence.tuple.haskell - meta.sequence meta.sequence -- ^ punctuation.section.sequence.begin.haskell --- ^^^^^ meta.group.haskell --- ^ punctuation.section.group.begin.haskell +-- ^^^^^ meta.prefix.haskell +-- ^ punctuation.definition.prefix.begin.haskell -- ^^^ keyword.operator.haskell --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.definition.prefix.end.haskell -- ^ punctuation.separator.sequence.haskell --- ^^^^^ meta.group.haskell --- ^ punctuation.section.group.begin.haskell +-- ^^^^^ meta.prefix.haskell +-- ^ punctuation.definition.prefix.begin.haskell -- ^^^ keyword.operator.haskell --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.definition.prefix.end.haskell -- ^ punctuation.separator.sequence.haskell -- ^^^^ entity.name.import.haskell -- ^ punctuation.separator.sequence.haskell @@ -855,10 +855,10 @@ -- ^^^^^^ keyword.declaration.export.haskell -- ^^^^^ constant.language.convention.haskell -- ^^^^^^^^ meta.string.haskell string.quoted.double.haskell --- ^^^ meta.group.haskell --- ^ punctuation.section.group.begin.haskell +-- ^^^ meta.prefix.haskell +-- ^ punctuation.definition.prefix.begin.haskell -- ^ keyword.operator.haskell --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.definition.prefix.end.haskell -- ^^ keyword.operator.double-colon.haskell -- ^^^ support.type.prelude.haskell -- ^^ keyword.operator.arrow.haskell @@ -924,10 +924,10 @@ -- ^^^^^^ keyword.declaration.import.haskell -- ^^^^^ constant.language.convention.haskell -- ^^^^^^^^ meta.string.haskell string.quoted.double.haskell --- ^^^ meta.group.haskell --- ^ punctuation.section.group.begin.haskell +-- ^^^ meta.prefix.haskell +-- ^ punctuation.definition.prefix.begin.haskell -- ^ keyword.operator.haskell --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.definition.prefix.end.haskell -- ^^ keyword.operator.double-colon.haskell -- ^^^ support.type.prelude.haskell -- ^^ keyword.operator.arrow.haskell @@ -1307,10 +1307,10 @@ data BuilderType = Builder { (>>=) :: forall m a b. Unrestricted.Monad m => m a -> (a -> m b) -> m b --- ^^^^^ meta.block.haskell meta.group.haskell --- ^ punctuation.section.group.begin.haskell +-- ^^^^^ meta.block.haskell meta.prefix.haskell +-- ^ punctuation.definition.prefix.begin.haskell -- ^^^ keyword.operator.haskell --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.definition.prefix.end.haskell -- ^^ keyword.operator.double-colon.haskell -- ^^^^^^ keyword.control.forall.haskell -- ^ punctuation.separator.sequence.haskell @@ -1319,10 +1319,10 @@ -- ^^^^^ support.class.prelude.haskell , (>>) :: forall m b . Unrestricted.Monad m => m() -> m b -> m b -- ^ punctuation.separator.sequence.haskell --- ^^^^ meta.block.haskell meta.group.haskell --- ^ punctuation.section.group.begin.haskell +-- ^^^^ meta.block.haskell meta.prefix.haskell +-- ^ punctuation.definition.prefix.begin.haskell -- ^^ keyword.operator.haskell --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.definition.prefix.end.haskell -- ^^ keyword.operator.double-colon.haskell -- ^^^^^^ keyword.control.forall.haskell -- ^ punctuation.separator.sequence.haskell @@ -1483,16 +1483,16 @@ -- ^ punctuation.section.sequence.end.haskell instance ModId.QTyCls (->) --- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.group --- ^^^^ meta.declaration.instance.haskell meta.group.haskell --- ^ meta.declaration.instance.haskell - meta.group +-- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.prefix +-- ^^^^ meta.declaration.instance.haskell meta.prefix.haskell +-- ^ meta.declaration.instance.haskell - meta.prefix -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell --- ^ punctuation.section.group.begin.haskell --- ^^ keyword.operator.arrow.haskell --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.definition.prefix.begin.haskell +-- ^^ keyword.operator.haskell +-- ^ punctuation.definition.prefix.end.haskell instance ModId.QTyCls a -- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell @@ -1597,16 +1597,17 @@ instance ModId.QTyCls ((->) a b) -- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.group -- ^ meta.declaration.instance.haskell meta.group.haskell --- ^^^^ meta.declaration.instance.haskell meta.group.haskell meta.group.haskell +-- ^^^^ meta.declaration.instance.haskell meta.group.haskell meta.prefix.haskell -- ^^^^^ meta.declaration.instance.haskell meta.group.haskell -- ^ meta.declaration.instance.haskell - meta.group -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell --- ^^ punctuation.section.group.begin.haskell --- ^^ keyword.operator.arrow.haskell --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^ punctuation.definition.prefix.begin.haskell +-- ^^ keyword.operator.haskell +-- ^ punctuation.definition.prefix.end.haskell -- ^ variable.other.haskell -- ^ variable.other.haskell -- ^ punctuation.section.group.end.haskell @@ -1905,9 +1906,11 @@ {- infix operator declaration -} (<:>) --- ^^^^^ meta.function.identifier.haskell meta.group.haskell --- ^ meta.function.identifier.haskell - meta.group +-- ^^^^^ meta.function.identifier.haskell meta.prefix.haskell +-- ^ meta.function.identifier.haskell - meta.prefix +-- ^ punctuation.definition.prefix.begin.haskell -- ^^^ keyword.operator.haskell +-- ^ punctuation.definition.prefix.end.haskell :: a -> Bool -- ^ meta.function.identifier.haskell -- ^^^^^^^^^^^^^ - meta.function @@ -1917,10 +1920,10 @@ -- ^^^^ support.type.prelude.haskell {- infix operator body -} (<:>) = do a <:> b --- ^^^^^ meta.group.haskell --- ^ punctuation.section.group.begin.haskell +-- ^^^^^ meta.prefix.haskell +-- ^ punctuation.definition.prefix.begin.haskell -- ^^^ keyword.operator.haskell --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.definition.prefix.end.haskell -- ^ keyword.operator.haskell -- ^^ keyword.control.context.haskell -- ^ variable.other.haskell @@ -3751,74 +3754,74 @@ main = do a a = (+) a 2 -- ^ keyword.operator.haskell --- ^^^ meta.group.haskell --- ^ punctuation.section.group.begin.haskell +-- ^^^ meta.prefix.haskell +-- ^ punctuation.definition.prefix.begin.haskell -- ^ keyword.operator.haskell --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.definition.prefix.end.haskell -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell a a = ( + ) a 2 -- ^ keyword.operator.haskell --- ^^^^^ meta.group.haskell --- ^ punctuation.section.group.begin.haskell +-- ^^^^^ meta.prefix.haskell +-- ^ punctuation.definition.prefix.begin.haskell -- ^ - punctuation - keyword -- ^ keyword.operator.haskell -- ^ - punctuation - keyword --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.definition.prefix.end.haskell -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell a a = (-) a 2 -- ^ keyword.operator.haskell --- ^^^ meta.group.haskell --- ^ punctuation.section.group.begin.haskell +-- ^^^ meta.prefix.haskell +-- ^ punctuation.definition.prefix.begin.haskell -- ^ keyword.operator.haskell --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.definition.prefix.end.haskell -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell a a = ( - ) a 2 -- ^ keyword.operator.haskell --- ^^^^^ meta.group.haskell --- ^ punctuation.section.group.begin.haskell +-- ^^^^^ meta.prefix.haskell +-- ^ punctuation.definition.prefix.begin.haskell -- ^ - punctuation - keyword -- ^ keyword.operator.haskell -- ^ - punctuation - keyword --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.definition.prefix.end.haskell -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell a a = (*) a 2 -- ^ keyword.operator.haskell --- ^^^ meta.group.haskell --- ^ punctuation.section.group.begin.haskell +-- ^^^ meta.prefix.haskell +-- ^ punctuation.definition.prefix.begin.haskell -- ^ keyword.operator.haskell --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.definition.prefix.end.haskell -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell a a = ( * ) a 2 -- ^ keyword.operator.haskell --- ^^^^^ meta.group.haskell --- ^ punctuation.section.group.begin.haskell +-- ^^^^^ meta.prefix.haskell +-- ^ punctuation.definition.prefix.begin.haskell -- ^ - punctuation - keyword -- ^ keyword.operator.haskell -- ^ - punctuation - keyword --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.definition.prefix.end.haskell -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell a a = (/) a 2 -- ^ keyword.operator.haskell --- ^^^ meta.group.haskell --- ^ punctuation.section.group.begin.haskell +-- ^^^ meta.prefix.haskell +-- ^ punctuation.definition.prefix.begin.haskell -- ^ keyword.operator.haskell --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.definition.prefix.end.haskell -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell a a = ( / ) a 2 -- ^ keyword.operator.haskell --- ^^^^^ meta.group.haskell --- ^ punctuation.section.group.begin.haskell +-- ^^^^^ meta.prefix.haskell +-- ^ punctuation.definition.prefix.begin.haskell -- ^ - punctuation - keyword -- ^ keyword.operator.haskell -- ^ - punctuation - keyword --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.definition.prefix.end.haskell -- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell a a = (--) a 2 @@ -3933,18 +3936,18 @@ main = do -- ^^^ keyword.operator.haskell , (:!) <$> genInt <*> genInt -- ^ punctuation.separator.sequence.haskell --- ^^^^ meta.sequence.list.haskell meta.group.haskell --- ^ punctuation.section.group.begin.haskell +-- ^^^^ meta.sequence.list.haskell meta.prefix.haskell +-- ^ punctuation.definition.prefix.begin.haskell -- ^^ keyword.operator.haskell --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.definition.prefix.end.haskell -- ^^^ keyword.operator.haskell -- ^^^ keyword.operator.haskell , (:@) <$> genDouble <*> genDouble -- ^ punctuation.separator.sequence.haskell --- ^^^^ meta.sequence.list.haskell meta.group.haskell --- ^ punctuation.section.group.begin.haskell +-- ^^^^ meta.sequence.list.haskell meta.prefix.haskell +-- ^ punctuation.definition.prefix.begin.haskell -- ^^ keyword.operator.haskell --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.definition.prefix.end.haskell -- ^^^ keyword.operator.haskell -- ^^^ keyword.operator.haskell , Quux <$> genInt <*> genDouble @@ -3954,10 +3957,10 @@ main = do -- ^^^ keyword.operator.haskell , (:#) <$> genString <*> genRecord -- ^ punctuation.separator.sequence.haskell --- ^^^^ meta.sequence.list.haskell meta.group.haskell --- ^ punctuation.section.group.begin.haskell +-- ^^^^ meta.sequence.list.haskell meta.prefix.haskell +-- ^ punctuation.definition.prefix.begin.haskell -- ^^ keyword.operator.haskell --- ^ punctuation.section.group.end.haskell +-- ^ punctuation.definition.prefix.end.haskell -- ^^^ keyword.operator.haskell -- ^^^ keyword.operator.haskell , DontDoThis <$> genInt <*> genString From f6c26244078623a6d790e18397898004b3c0ef94 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sat, 2 Jan 2021 12:19:54 +0100 Subject: [PATCH 156/178] [Haskell] Tweak type definition identifier scopes This commit... 1. scopes declared type/newtype identifiers `entity.name.type` 2. adds those to symbol list and indexed symbol list. --- Haskell/Haskell.sublime-syntax | 17 +++++++++++++++-- Haskell/Indexed Symbol List.tmPreferences | 1 + Haskell/Symbol List - Types.tmPreferences | 12 ++++++++++++ Haskell/syntax_test_haskell.hs | 12 ++++++------ 4 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 Haskell/Symbol List - Types.tmPreferences diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index d7e9006ec9..c3d47a094a 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -751,7 +751,9 @@ contexts: newtypes: - match: newtype{{break}} scope: keyword.declaration.newtype.haskell - push: newtype-body + push: + - newtype-body + - type-name newtype-body: - meta_scope: meta.declaration.newtype.haskell @@ -763,8 +765,19 @@ contexts: types: - match: type{{break}} scope: keyword.declaration.type.haskell - push: type-body + push: + - type-body + - type-name + type-name: + - include: ident-namespaces + - match: '{{con_id}}' + scope: entity.name.type.haskell + captures: + 1: storage.modifier.unboxed.haskell + pop: 1 + - include: else-pop + type-body: - meta_scope: meta.declaration.type.haskell - include: type-expressions diff --git a/Haskell/Indexed Symbol List.tmPreferences b/Haskell/Indexed Symbol List.tmPreferences index 328484c5b2..ad8290889f 100644 --- a/Haskell/Indexed Symbol List.tmPreferences +++ b/Haskell/Indexed Symbol List.tmPreferences @@ -3,6 +3,7 @@ scope + source.haskell entity.name.type, source.haskell meta.function.identifier meta.prefix keyword.operator settings diff --git a/Haskell/Symbol List - Types.tmPreferences b/Haskell/Symbol List - Types.tmPreferences new file mode 100644 index 0000000000..826187468c --- /dev/null +++ b/Haskell/Symbol List - Types.tmPreferences @@ -0,0 +1,12 @@ + + + + scope + source.haskell entity.name.type + settings + + showInSymbolList + 1 + + + diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index ef01292a47..d13aea93f4 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -1685,7 +1685,7 @@ newtype TypCls tyVar => -- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.newtype.haskell -- ^^^^^^^ keyword.declaration.newtype.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ entity.name.type.haskell -- ^^^^^ variable.other.haskell -- ^^ keyword.operator.big-arrow.haskell @@ -1728,7 +1728,7 @@ type QTyCls tyVar -- ^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell -- ^^^^ keyword.declaration.type.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ entity.name.type.haskell -- ^^^^^ variable.other.haskell type ModId.QTyCls tyVar1 tyVar2 @@ -1736,7 +1736,7 @@ -- ^^^^ keyword.declaration.type.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ entity.name.type.haskell -- ^^^^^^ variable.other.haskell -- ^^^^^^ variable.other.haskell @@ -1745,7 +1745,7 @@ -- ^^^^ keyword.declaration.type.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ entity.name.type.haskell -- ^^^^^^ variable.other.haskell -- ^^^^^^ variable.other.haskell @@ -1757,7 +1757,7 @@ -- ^^^^ keyword.declaration.type.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ entity.name.type.haskell -- ^^^^^^ variable.other.haskell -- ^^^^^^ variable.other.haskell -- ^^^^^^^^ storage.modifier.haskell @@ -1829,7 +1829,7 @@ type CmdRoute = -- ^^^^^^^^^^^^^^ meta.declaration.type.haskell -- ^^^^ keyword.declaration.type.haskell --- ^^^^^^^^ storage.type.haskell +-- ^^^^^^^^ entity.name.type.haskell -- ^ keyword.operator.haskell ( ReqBody '[JSON] CmdDto :> PostCreated '[JSON] NoContent -- ^^^^^^^^^^^ meta.group.haskell - meta.sequence From 9deb5284913db3ef428fb45d3aacf5f8455b1444 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sat, 2 Jan 2021 12:25:30 +0100 Subject: [PATCH 157/178] [Haskell] Tweak data definition identifier scopes This commit scopes the first constructor identifier after `data` keyword `entity.name.type`. --- Haskell/Haskell.sublime-syntax | 11 ++++++++--- Haskell/syntax_test_haskell.hs | 14 +++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index c3d47a094a..2977129c50 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -634,13 +634,18 @@ contexts: scope: meta.declaration.data.haskell keyword.declaration.data.haskell - push: data-body + push: + - data-body + - data-name - data-body: - - meta_content_scope: meta.declaration.data.haskell + data-name: # https://wiki.haskell.org/GHC/Type_families - match: (?:family|instance){{break}} scope: storage.modifier.family.haskell + - include: type-name + + data-body: + - meta_content_scope: meta.declaration.data.haskell - include: type-expressions - include: else-pop diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index d13aea93f4..f6f67e3294 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -1129,14 +1129,14 @@ data TyCls -- ^^^^^^^^^^^ meta.declaration.data.haskell -- ^^^^ keyword.declaration.data.haskell --- ^^^^^ storage.type.haskell +-- ^^^^^ entity.name.type.haskell data ModId.QTyCls -- ^^^^^^^^^^^^^^^^^^ meta.declaration.data.haskell -- ^^^^ keyword.declaration.data.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ entity.name.type.haskell data = -- ^^^^^ meta.declaration.data.haskell @@ -1148,7 +1148,7 @@ -- ^^^^^^^^^^^^^^^^^^^^ meta.declaration.data.haskell -- ^^^^ keyword.declaration.data.haskell -- ^^^^^^ storage.modifier.family.haskell --- ^^^^^ storage.type.haskell +-- ^^^^^ entity.name.type.haskell -- ^ variable.other.haskell -- Declare a list-like instance for Char @@ -1158,7 +1158,7 @@ -- ^^^^^^^^^^^^ meta.group.haskell -- ^^^^ keyword.declaration.data.haskell -- ^^^^^^^^ storage.modifier.family.haskell --- ^^^^^ storage.type.haskell +-- ^^^^^ entity.name.type.haskell -- ^^^^ support.type.prelude.haskell -- ^ keyword.operator.haskell -- ^^^^^ storage.type.haskell @@ -1178,7 +1178,7 @@ -- ^^^^^^^^^^^^^^^^^ - meta.declaration -- ^^^^ keyword.declaration.data.haskell -- ^^^^^^^^ storage.modifier.family.haskell --- ^^^^^ storage.type.haskell +-- ^^^^^ entity.name.type.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^ punctuation.section.sequence.end.haskell -- ^ keyword.operator.haskell @@ -1189,7 +1189,7 @@ data Record = -- ^^^^^^^^^^^^ meta.declaration.data.haskell -- ^^^^ keyword.declaration.data.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ entity.name.type.haskell -- ^ keyword.operator.haskell Record { -- ^^^^^^^ - meta.block @@ -1253,7 +1253,7 @@ data Outrageous = -- ^^^^^^^^^^^^^^^^ meta.declaration.data.haskell -- ^^^^ keyword.declaration.data.haskell --- ^^^^^^^^^^ storage.type.haskell +-- ^^^^^^^^^^ entity.name.type.haskell -- ^ keyword.operator.haskell Flipper !Record -- ^^^^^^^ storage.type.haskell From 411bed9a0d38d010da402af3db16b10f509e493f Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sat, 2 Jan 2021 14:09:42 +0100 Subject: [PATCH 158/178] [Haskell] Fix data definition identifier context Now that we scope declared data types `entity.name` we need to make sure the `context =>` part is parsed correctly. Otherwise the wrong token may be scoped as `entity.name`. --- Haskell/Haskell.sublime-syntax | 36 +++++++++++++++++++++++----------- Haskell/syntax_test_haskell.hs | 24 +++++++++++++++++++++++ 2 files changed, 49 insertions(+), 11 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 2977129c50..6eacd42a03 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -630,22 +630,36 @@ contexts: datas: # 4.2.1 Algebraic Datatype Declarations # https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-680004.2 - - match: data{{break}} + - match: (data)(?:\s+(family|instance))?{{break}} + scope: meta.declaration.data.haskell + captures: + 1: keyword.declaration.data.haskell + 2: storage.modifier.family.haskell + branch_point: data-declaration + branch: + - data-signature + - data-context + + data-context: + - meta_content_scope: meta.declaration.data.context.haskell + - match: '{{operator_big_arrow}}' scope: meta.declaration.data.haskell - keyword.declaration.data.haskell - push: - - data-body - - data-name + keyword.operator.big-arrow.haskell + set: data-signature + - include: type-expressions - data-name: - # https://wiki.haskell.org/GHC/Type_families - - match: (?:family|instance){{break}} - scope: storage.modifier.family.haskell - - include: type-name + data-signature: + - meta_include_prototype: false + - match: '' + set: + - data-args + - type-name - data-body: + data-args: - meta_content_scope: meta.declaration.data.haskell + - match: (?={{operator_big_arrow}}) + fail: data-declaration - include: type-expressions - include: else-pop diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index f6f67e3294..12aa7d01eb 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -1138,6 +1138,18 @@ -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ entity.name.type.haskell + data CtxCls ctx => ModId.QTyCls +-- ^^^^ meta.declaration.data.haskell +-- ^^^^^^^^^^^^ meta.declaration.data.context.haskell +-- ^^^^^^^^^^^^^^^^ meta.declaration.data.haskell +-- ^^^^ keyword.declaration.data.haskell +-- ^^^^^^ storage.type.haskell +-- ^^^ variable.other.haskell +-- ^^ keyword.operator.big-arrow.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ entity.name.type.haskell + data = -- ^^^^^ meta.declaration.data.haskell -- ^^^^ keyword.declaration.data.haskell @@ -1151,6 +1163,18 @@ -- ^^^^^ entity.name.type.haskell -- ^ variable.other.haskell + data family CtxCls par => XList a +-- ^^^^^^^^^^^ meta.declaration.data.haskell +-- ^^^^^^^^^^^^ meta.declaration.data.context.haskell +-- ^^^^^^^^^^^ meta.declaration.data.haskell +-- ^^^^ keyword.declaration.data.haskell +-- ^^^^^^ storage.modifier.family.haskell +-- ^^^^^^ storage.type.haskell +-- ^^^ variable.other.haskell +-- ^^ keyword.operator.big-arrow.haskell +-- ^^^^^ entity.name.type.haskell +-- ^ variable.other.haskell + -- Declare a list-like instance for Char data instance XList Char = XCons !Char !(XList Char) | XNil -- ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.data.haskell From 7cb9118bbd738fe05dcf435e6f33ae2609f83cb2 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sat, 2 Jan 2021 14:24:23 +0100 Subject: [PATCH 159/178] [Haskell] Fix type definition identifier context Now that we scope declared data types `entity.name` we need to make sure the `context =>` part is parsed correctly. Otherwise the wrong token may be scoped as `entity.name`. --- Haskell/Haskell.sublime-syntax | 64 ++++++++++++++++++++++++++++------ Haskell/syntax_test_haskell.hs | 32 +++++++++++++---- 2 files changed, 79 insertions(+), 17 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 6eacd42a03..abe9caae32 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -769,13 +769,34 @@ contexts: newtypes: - match: newtype{{break}} - scope: keyword.declaration.newtype.haskell - push: - - newtype-body + scope: + meta.declaration.newtype.haskell + keyword.declaration.newtype.haskell + branch_point: newtype-declaration + branch: + - newtype-signature + - newtype-context + + newtype-context: + - meta_content_scope: meta.declaration.newtype.context.haskell + - match: '{{operator_big_arrow}}' + scope: + meta.declaration.newtype.haskell + keyword.operator.big-arrow.haskell + set: newtype-signature + - include: type-expressions + + newtype-signature: + - meta_include_prototype: false + - match: '' + set: + - newtype-args - type-name - newtype-body: - - meta_scope: meta.declaration.newtype.haskell + newtype-args: + - meta_content_scope: meta.declaration.newtype.haskell + - match: (?={{operator_big_arrow}}) + fail: newtype-declaration - include: type-expressions - include: else-pop @@ -783,11 +804,30 @@ contexts: types: - match: type{{break}} - scope: keyword.declaration.type.haskell - push: - - type-body + scope: + meta.declaration.type.haskell + keyword.declaration.type.haskell + branch_point: type-declaration + branch: + - type-signature + - type-context + + type-context: + - meta_content_scope: meta.declaration.type.context.haskell + - match: '{{operator_big_arrow}}' + scope: + meta.declaration.type.haskell + keyword.operator.big-arrow.haskell + set: type-signature + - include: type-expressions + + type-signature: + - meta_include_prototype: false + - match: '' + set: + - type-args - type-name - + type-name: - include: ident-namespaces - match: '{{con_id}}' @@ -797,8 +837,10 @@ contexts: pop: 1 - include: else-pop - type-body: - - meta_scope: meta.declaration.type.haskell + type-args: + - meta_content_scope: meta.declaration.type.haskell + - match: (?={{operator_big_arrow}}) + fail: type-declaration - include: type-expressions - include: else-pop diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index 12aa7d01eb..a783f18d06 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -1702,19 +1702,25 @@ -- ^ keyword.operator.haskell newtype => --- ^^^^^^^^^^^ meta.declaration.newtype.haskell +-- ^^^^^^^ meta.declaration.newtype.haskell +-- ^ meta.declaration.newtype.context.haskell +-- ^^^ meta.declaration.newtype.haskell -- ^^^^^^^ keyword.declaration.newtype.haskell -- ^^ keyword.operator.big-arrow.haskell - newtype TypCls tyVar => --- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.newtype.haskell + newtype CtxCls tyVar => +-- ^^^^^^^ meta.declaration.newtype.haskell +-- ^^^^^^^^^^^^^^ meta.declaration.newtype.context.haskell +-- ^^^ meta.declaration.newtype.haskell -- ^^^^^^^ keyword.declaration.newtype.haskell --- ^^^^^^ entity.name.type.haskell +-- ^^^^^^ storage.type.haskell -- ^^^^^ variable.other.haskell -- ^^ keyword.operator.big-arrow.haskell newtype () => ModId.QTyCls tyVar1 tyVar2 deriving (Class1, QTyCls2) --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.newtype.haskell +-- ^^^^^^^ meta.declaration.newtype.haskell +-- ^^^^ meta.declaration.newtype.context.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.newtype.haskell -- ^^^^^^^^^ meta.declaration.deriving.haskell - meta.sequence -- ^^^^^^^^^^^^^^^^^ meta.declaration.deriving.haskell meta.sequence.tuple.haskell -- ^ - meta.declaration @@ -1725,7 +1731,7 @@ -- ^^ keyword.operator.big-arrow.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ entity.name.type.haskell -- ^^^^^^ variable.other.haskell -- ^^^^^^ variable.other.haskell -- ^^^^^^^^ storage.modifier.haskell @@ -1791,6 +1797,20 @@ -- ^^^^^^^ storage.type.haskell -- ^ punctuation.section.sequence.end.haskell + type ModId.CtxCls tyVar => ModId.QTyCls +-- ^^^^ meta.declaration.type.haskell +-- ^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.context.haskell +-- ^^^^^^^^^^^^^^^^ meta.declaration.type +-- ^^^^ keyword.declaration.type.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ storage.type.haskell +-- ^^^^^ variable.other.haskell +-- ^^ keyword.operator.big-arrow.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell +-- ^^^^^^ entity.name.type.haskell + type Id a = a -- ^^^^^^^^^^ meta.declaration.type.haskell -- ^ keyword.operator.haskell From 126e65b1572d2699ec92326211a727011b32094d Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sat, 2 Jan 2021 14:54:36 +0100 Subject: [PATCH 160/178] [Haskell] Scope class/instance declaration identifiers This commit scopes declared class and instance types `entity.name.class`. --- Haskell/Haskell.sublime-syntax | 80 ++++++++++++++++++++---- Haskell/syntax_test_haskell.hs | 110 ++++++++++++++++++++------------- 2 files changed, 135 insertions(+), 55 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index abe9caae32..9921c8fed5 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -215,6 +215,7 @@ contexts: declarations: - include: classes + - include: instances - include: datas - include: foreigns - include: imports @@ -590,19 +591,40 @@ contexts: scope: meta.declaration.class.haskell keyword.declaration.class.haskell - push: class-body - # 4.3.2 Instance Declarations - # https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-750004.3 - - match: instance{{break}} - scope: keyword.declaration.instance.haskell - push: instance-body + branch_point: class-declaration + branch: + - class-signature + - class-context - class-body: - - meta_content_scope: meta.declaration.class.haskell - - include: class-type + class-context: + - meta_content_scope: meta.declaration.class.context.haskell + - match: '{{operator_big_arrow}}' + scope: + meta.declaration.class.haskell + keyword.operator.big-arrow.haskell + set: class-signature + - include: type-expressions + + class-signature: + - meta_include_prototype: false + - match: '' + set: + - class-args + - class-name + + class-name: + - include: ident-namespaces + - match: '{{con_id}}' + scope: entity.name.class.haskell + captures: + 1: storage.modifier.unboxed.haskell + pop: 1 + - include: else-pop - instance-body: - - meta_scope: meta.declaration.instance.haskell + class-args: + - meta_content_scope: meta.declaration.class.haskell + - match: (?={{operator_big_arrow}}) + fail: class-declaration - include: class-type class-type: @@ -625,6 +647,42 @@ contexts: - include: statements - include: expressions +###[ INSTANCE DECLARATIONS ]################################################### + + instances: + # 4.3.2 Instance Declarations + # https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-750004.3 + - match: instance{{break}} + scope: + meta.declaration.instance.haskell + keyword.declaration.instance.haskell + branch_point: instance-declaration + branch: + - instance-signature + - instance-context + + instance-context: + - meta_content_scope: meta.declaration.instance.context.haskell + - match: '{{operator_big_arrow}}' + scope: + meta.declaration.instance.haskell + keyword.operator.big-arrow.haskell + set: instance-signature + - include: type-expressions + + instance-signature: + - meta_include_prototype: false + - match: '' + set: + - instance-args + - class-name + + instance-args: + - meta_content_scope: meta.declaration.instance.haskell + - match: (?={{operator_big_arrow}}) + fail: instance-declaration + - include: class-type + ###[ DATA DECLARATIONS ]####################################################### datas: diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/syntax_test_haskell.hs index a783f18d06..f66ffe0514 100644 --- a/Haskell/syntax_test_haskell.hs +++ b/Haskell/syntax_test_haskell.hs @@ -950,20 +950,22 @@ -- ^^^^^ keyword.declaration.class.haskell class => --- ^^^^^^^^^ meta.declaration.class.haskell +-- ^^^^^ meta.declaration.class.haskell +-- ^ meta.declaration.class.context.haskell +-- ^^^ meta.declaration.class.haskell -- ^^^^^ keyword.declaration.class.haskell -- ^^ keyword.operator.big-arrow.haskell class QTyCls tyVar -- ^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell -- ^^^^^ keyword.declaration.class.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ entity.name.class.haskell -- ^^^^^ variable.other.haskell class QTyCls# tyVar# -- ^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell -- ^^^^^ keyword.declaration.class.haskell --- ^^^^^^^ storage.type.haskell +-- ^^^^^^^ entity.name.class.haskell -- ^ storage.modifier.unboxed.haskell -- ^^^^^^ variable.other.haskell -- ^ storage.modifier.unboxed.haskell @@ -974,14 +976,16 @@ -- ^^^^^ keyword.declaration.class.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ entity.name.class.haskell -- ^^^^^^ variable.other.haskell -- ^^^^^^ variable.other.haskell -- ^ punctuation.separator.sequence.haskell -- ^^^^^ variable.other.haskell class ModId.QTyCls tyVar1 tyVar2 => --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell +-- ^^^^^ meta.declaration.class.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.context.haskell +-- ^^^ meta.declaration.class.haskell -- ^^^^^ keyword.declaration.class.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell @@ -991,9 +995,11 @@ -- ^^ keyword.operator.big-arrow.haskell class ModId.QTyCls (tyVar1 tyVar2#) => --- ^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell - meta.group --- ^^^^^^^^^^^^^^^^ meta.declaration.class.haskell meta.group.haskell --- ^^^^ meta.declaration.class.haskell - meta.group +-- ^^^^^ meta.declaration.class.haskell +-- ^^^^^^^^^^^^^^ meta.declaration.class.context.haskell - meta.group +-- ^^^^^^^^^^^^^^^^ meta.declaration.class.context.haskell meta.group.haskell +-- ^ meta.declaration.class.context.haskell - meta.group +-- ^^^ meta.declaration.class.haskell - meta.group -- ^^^^^ keyword.declaration.class.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell @@ -1011,7 +1017,7 @@ -- ^^^^^ keyword.declaration.class.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ entity.name.class.haskell -- ^ punctuation.section.group.begin.haskell -- ^^^^^^ variable.other.haskell -- ^^^^^^ variable.other.haskell @@ -1019,7 +1025,9 @@ -- ^ punctuation.section.group.end.haskell class ModId.QTyCls tyVar1 tyVar2 => Traversable t --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell +-- ^^^^^ meta.declaration.class.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.context.haskell +-- ^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell -- ^^^^^ keyword.declaration.class.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell @@ -1027,11 +1035,13 @@ -- ^^^^^^ variable.other.haskell -- ^^^^^^ variable.other.haskell -- ^^ keyword.operator.big-arrow.haskell --- ^^^^^^^^^^^ support.class.prelude.haskell +-- ^^^^^^^^^^^ entity.name.class.haskell -- ^ variable.other.haskell class () => --- ^^^^^^^^^^^^ meta.declaration.class.haskell +-- ^^^^^ meta.declaration.class.haskell +-- ^^^^ meta.declaration.class.context.haskell +-- ^^^ meta.declaration.class.haskell -- ^^^^^ keyword.declaration.class.haskell -- ^^ meta.sequence.tuple.haskell -- ^ punctuation.section.sequence.begin.haskell @@ -1039,9 +1049,11 @@ -- ^^ keyword.operator.big-arrow.haskell class (Functor t, Foldable t) => Traversable t where --- ^^^^^^ meta.declaration.class.haskell - meta.sequence --- ^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell meta.sequence.tuple.haskell --- ^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell - meta.sequence +-- ^^^^^ meta.declaration.class.haskell - meta.sequence +-- ^ meta.declaration.class.context.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.context.haskell meta.sequence.tuple.haskell +-- ^ meta.declaration.class.context.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell - meta.sequence -- ^^^^^ keyword.declaration.class.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^^^^^^^ support.class.prelude.haskell @@ -1051,7 +1063,7 @@ -- ^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell -- ^^ keyword.operator.big-arrow.haskell --- ^^^^^^^^^^^ support.class.prelude.haskell +-- ^^^^^^^^^^^ entity.name.class.haskell -- ^ variable.other.haskell -- ^^^^^ keyword.control.context.haskell @@ -1060,7 +1072,9 @@ -- methods in the original ones. class Eq a => a -> a --- ^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell +-- ^^^^^ meta.declaration.class.haskell +-- ^^^^^^ meta.declaration.class.context.haskell +-- ^^^^^^^^^^ meta.declaration.class.haskell -- ^^^^^ keyword.declaration.class.haskell -- ^^ support.class.prelude.haskell -- ^ variable.other.haskell @@ -1070,9 +1084,11 @@ -- ^ variable.other.haskell class (Eq a, Show a, Eq b) => [a] -> [b] -> String --- ^^^^^^ meta.declaration.class.haskell - meta.sequence --- ^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell meta.sequence.tuple.haskell --- ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell +-- ^^^^^ meta.declaration.class.haskell - meta.sequence +-- ^ meta.declaration.class.context.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.context.haskell meta.sequence.tuple.haskell +-- ^ meta.declaration.class.context.haskell - meta.sequence +-- ^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell -- ^^^^^ keyword.declaration.class.haskell -- ^^ support.class.prelude.haskell -- ^ variable.other.haskell @@ -1084,11 +1100,13 @@ -- ^^^^^^ support.type.prelude.haskell class (Eq (f a), Functor f) => (a -> b) -> f a -> f b -> Bool --- ^^^^^^ meta.declaration.class.haskell - meta.sequence - meta.group --- ^^^^ meta.declaration.class.haskell meta.sequence.tuple.haskell - meta.sequence meta.group --- ^^^^^ meta.declaration.class.haskell meta.sequence.tuple.haskell meta.group.haskell --- ^^^^^^^^^^^^ meta.declaration.class.haskell meta.sequence.tuple.haskell - meta.sequence meta.group --- ^^^^ meta.declaration.class.haskell - meta.sequence - meta.group +-- ^^^^^ meta.declaration.class.haskell - meta.sequence - meta.group +-- ^ meta.declaration.class.context.haskell - meta.sequence +-- ^^^^ meta.declaration.class.context.haskell meta.sequence.tuple.haskell - meta.sequence meta.group +-- ^^^^^ meta.declaration.class.context.haskell meta.sequence.tuple.haskell meta.group.haskell +-- ^^^^^^^^^^^^ meta.declaration.class.context.haskell meta.sequence.tuple.haskell - meta.sequence meta.group +-- ^ meta.declaration.class.context.haskell - meta.sequence +-- ^^^ meta.declaration.class.haskell - meta.sequence - meta.group -- ^^^^^^^^ meta.declaration.class.haskell meta.group.haskell -- ^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell - meta.group -- ^^^^^ keyword.declaration.class.haskell @@ -1470,7 +1488,7 @@ -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ entity.name.class.haskell instance ModId.QTyCls [] -- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence @@ -1479,7 +1497,7 @@ -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ entity.name.class.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^ punctuation.section.sequence.end.haskell @@ -1490,7 +1508,7 @@ -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ entity.name.class.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^ punctuation.section.sequence.end.haskell @@ -1501,7 +1519,7 @@ -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ entity.name.class.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^ punctuation.separator.sequence.haskell -- ^ punctuation.section.sequence.end.haskell @@ -1513,7 +1531,7 @@ -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ entity.name.class.haskell -- ^ punctuation.definition.prefix.begin.haskell -- ^^ keyword.operator.haskell -- ^ punctuation.definition.prefix.end.haskell @@ -1523,7 +1541,7 @@ -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ entity.name.class.haskell -- ^ variable.other.haskell instance ModId.QTyCls [a] @@ -1533,7 +1551,7 @@ -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ entity.name.class.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell @@ -1545,7 +1563,7 @@ -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ entity.name.class.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^ variable.other.haskell -- ^ punctuation.separator.sequence.haskell @@ -1559,7 +1577,7 @@ -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ entity.name.class.haskell -- ^ punctuation.section.group.begin.haskell -- ^ variable.other.haskell -- ^^ keyword.operator.arrow.haskell @@ -1575,7 +1593,7 @@ -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ entity.name.class.haskell -- ^ punctuation.section.group.begin.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^ punctuation.section.sequence.end.haskell @@ -1592,7 +1610,7 @@ -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ entity.name.class.haskell -- ^ punctuation.section.group.begin.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^ punctuation.section.sequence.end.haskell @@ -1609,7 +1627,7 @@ -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ entity.name.class.haskell -- ^ punctuation.section.group.begin.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^ punctuation.separator.sequence.haskell @@ -1627,7 +1645,7 @@ -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell --- ^^^^^^ storage.type.haskell +-- ^^^^^^ entity.name.class.haskell -- ^ punctuation.section.group.begin.haskell -- ^ punctuation.definition.prefix.begin.haskell -- ^^ keyword.operator.haskell @@ -1637,23 +1655,27 @@ -- ^ punctuation.section.group.end.haskell instance Num a => Bar [a] where ... --- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence +-- ^^^^^^^^ meta.declaration.instance.haskell +-- ^^^^^^^ meta.declaration.instance.context.haskell +-- ^^^^^^^ meta.declaration.instance.haskell - meta.sequence -- ^^^ meta.declaration.instance.haskell meta.sequence.list.haskell -- ^ meta.declaration.instance.haskell - meta.sequence -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^ support.class.prelude.haskell -- ^ variable.other.haskell -- ^^ keyword.operator.big-arrow.haskell --- ^^^ storage.type.haskell +-- ^^^ entity.name.class.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell -- ^^^^^ keyword.control.context.haskell instance (Eq a, Show a) => Foo [a] where ... --- ^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence --- ^^^^^^^^^^^^^^ meta.declaration.instance.haskell meta.sequence.tuple.haskell --- ^^^^^^^^ meta.declaration.instance.haskell - meta.sequence +-- ^^^^^^^^ meta.declaration.instance.haskell - meta.sequence +-- ^ meta.declaration.instance.context.haskell - meta.sequence +-- ^^^^^^^^^^^^^^ meta.declaration.instance.context.haskell meta.sequence.tuple.haskell +-- ^ meta.declaration.instance.context.haskell - meta.sequence +-- ^^^^^^^ meta.declaration.instance.haskell - meta.sequence -- ^^^ meta.declaration.instance.haskell meta.sequence.list.haskell -- ^ meta.declaration.instance.haskell - meta.sequence -- ^^^^^^^^ keyword.declaration.instance.haskell @@ -1665,7 +1687,7 @@ -- ^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell -- ^^ keyword.operator.big-arrow.haskell --- ^^^ storage.type.haskell +-- ^^^ entity.name.class.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell From 01624ba13f8fe351184f119a70c49836da2a7130 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Mon, 11 Jan 2021 18:17:36 +0100 Subject: [PATCH 161/178] [Haskell] Move tests to dedicated directory --- Haskell/{ => tests}/syntax_test_haskell.hs | 0 Haskell/{ => tests}/syntax_test_literate.lhs | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename Haskell/{ => tests}/syntax_test_haskell.hs (100%) rename Haskell/{ => tests}/syntax_test_literate.lhs (100%) diff --git a/Haskell/syntax_test_haskell.hs b/Haskell/tests/syntax_test_haskell.hs similarity index 100% rename from Haskell/syntax_test_haskell.hs rename to Haskell/tests/syntax_test_haskell.hs diff --git a/Haskell/syntax_test_literate.lhs b/Haskell/tests/syntax_test_literate.lhs similarity index 100% rename from Haskell/syntax_test_literate.lhs rename to Haskell/tests/syntax_test_literate.lhs From ed87ba617e95f4c3edb4aac4af376015f3f015b1 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 29 Jan 2021 18:21:48 +0100 Subject: [PATCH 162/178] [Haskell] Move `otherwise` to constants https://github.com/sublimehq/Packages/pull/2679#discussion_r566233506 --- Haskell/Haskell.sublime-syntax | 7 +++++-- Haskell/tests/syntax_test_haskell.hs | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 9921c8fed5..b2f1abf227 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -147,7 +147,7 @@ variables: ){{break}} prelude_constants: |- - (?x: Nothing | True | False | LT | EQ | GT ){{break}} + (?x: otherwise | Nothing | True | False | LT | EQ | GT ){{break}} prelude_types: |- (?x: @@ -175,7 +175,7 @@ variables: | last | lcm | length | lex | lines | log | logBase | lookup | map | mapM | mapM_ | mappend | max | maxBound | maximum | maybe | mconcat | mempty | min | minBound | minimum | mod | negate | not | notElem | null | odd | or - | otherwise | pi | pred | print | product | properFraction | pure | putChar + | pi | pred | print | product | properFraction | pure | putChar | putStr | putStrLn | quot | quotRem | read | readFile | readIO | readList | readLn | readParen | reads | readsPrec | realToFrac | recip | rem | repeat | replicate | return | reverse | round | scaleFloat | scanl | scanl1 | scanr @@ -804,6 +804,9 @@ contexts: 2: keyword.operator.haskell 3: punctuation.definition.prefix.end.haskell push: variable-name-end + - match: '{{prelude_constants}}' + scope: support.constant.prelude.haskell + push: variable-name-end - match: '{{prelude_functions}}' scope: support.function.prelude.haskell push: variable-name-end diff --git a/Haskell/tests/syntax_test_haskell.hs b/Haskell/tests/syntax_test_haskell.hs index f66ffe0514..4e21ac3081 100644 --- a/Haskell/tests/syntax_test_haskell.hs +++ b/Haskell/tests/syntax_test_haskell.hs @@ -2076,7 +2076,7 @@ -- ^ variable.other.haskell | otherwise = M.lookup c asciiMap -- ^ punctuation.separator.sequence.haskell --- ^^^^^^^^^ support.function.prelude.haskell +-- ^^^^^^^^^ support.constant.prelude.haskell -- ^ keyword.operator.haskell -- ^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell From a464ec65cba9b1cb2bebd0ee0eac510699ccf687 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 29 Jan 2021 20:39:35 +0100 Subject: [PATCH 163/178] [Haskell] Scope fully qualified infix operators Resolves https://github.com/sublimehq/Packages/pull/2679#discussion_r566247062 --- Haskell/Haskell.sublime-syntax | 29 +++++++++++++++++++++++----- Haskell/tests/syntax_test_haskell.hs | 23 +++++++++++++++++++--- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index b2f1abf227..fa6f2792fe 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -31,6 +31,7 @@ variables: # 2.4 Identifiers and Operators # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-180002.4 + id: (?:(?!{{reserved_id}})[\w']*(#)*) con_id: (?:[[:upper:]][\w']*(#)*) var_id: (?:(?!{{reserved_id}})[[:lower:]_][\w']*(#)*) reserved_id: |- @@ -1362,13 +1363,31 @@ contexts: 3: punctuation.definition.prefix.end.haskell infix-quoted-operators: - - match: (`)\s*([\w'.]*(#*))\s*(`) - scope: meta.infix.haskell + - match: (?=\`) + branch_point: infix-quoted-operators + branch: + - infix-quoded-operators-begin + - immediatelly-pop + + infix-quoded-operators-begin: + - match: (\`)\s* captures: 1: punctuation.definition.infix.begin.haskell - 2: keyword.operator.function.infix.haskell - 3: storage.modifier.unboxed.haskell - 4: punctuation.definition.infix.end.haskell + set: infix-quoded-operators-body + + infix-quoded-operators-body: + - meta_scope: meta.infix.haskell + - match: \s*(\`) + captures: + 1: punctuation.definition.infix.end.haskell + pop: 1 + - include: ident-namespaces + - match: '{{id}}' + scope: keyword.operator.function.infix.haskell + captures: + 1: storage.modifier.unboxed.haskell + - match: '' + fail: infix-quoted-operators statement-terminators: # Depending on layout, semicolon may be needed to terminate statements. diff --git a/Haskell/tests/syntax_test_haskell.hs b/Haskell/tests/syntax_test_haskell.hs index 4e21ac3081..caa7df9b15 100644 --- a/Haskell/tests/syntax_test_haskell.hs +++ b/Haskell/tests/syntax_test_haskell.hs @@ -3917,7 +3917,9 @@ main = do a `P.atan2` x -- ^^^^^^^^^ meta.infix.haskell -- ^ punctuation.definition.infix.begin.haskell - keyword --- ^^^^^^^ keyword.operator.function.infix.haskell +-- ^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell - keyword - variale +-- ^^^^^ keyword.operator.function.infix.haskell -- ^ punctuation.definition.infix.end.haskell - keyword {- unqualified infix constructor operator id -} @@ -3931,7 +3933,9 @@ main = do a `Monad.Quux` x -- ^^^^^^^^^^^^ meta.infix.haskell -- ^ punctuation.definition.infix.begin.haskell - keyword --- ^^^^^^^^^^ keyword.operator.function.infix.haskell +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell - keyword - variale +-- ^^^^ keyword.operator.function.infix.haskell -- ^ punctuation.definition.infix.end.haskell - keyword 5 `f `7`f`"3 'ab'" @@ -3981,10 +3985,23 @@ main = do a `Ns.shiftL#` b -- ^^^^^^^^^^^^ meta.infix.haskell -- ^ punctuation.definition.infix.begin.haskell - keyword --- ^^^^^^^^^^ keyword.operator.function.infix.haskell +-- ^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell - keyword - variale +-- ^^^^^^^ keyword.operator.function.infix.haskell -- ^ storage.modifier.unboxed.haskell -- ^ punctuation.definition.infix.end.haskell - keyword + a `ModId.Ns.shiftL#` b +-- ^^^^^^^^^^^^^^^^^^ meta.infix.haskell +-- ^ punctuation.definition.infix.begin.haskell - keyword +-- ^^^^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell - variable +-- ^^ variable.namespace.haskell +-- ^ punctuation.accessor.dot.haskell - keyword - variale +-- ^^^^^^^ keyword.operator.function.infix.haskell +-- ^ storage.modifier.unboxed.haskell +-- ^ punctuation.definition.infix.end.haskell - keyword + a `Unboxed#` b -- ^^^^^^^^^^ meta.infix.haskell -- ^ punctuation.definition.infix.begin.haskell - keyword From f16e3fc50c812e722e38afa1adeec9df95fb0d89 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sat, 30 Jan 2021 14:38:16 +0100 Subject: [PATCH 164/178] [Haskell] Scope list and tuple constructors as constants This commit scopes `()`, `(,)` and `[]` as language constants. Satisfies https://github.com/sublimehq/Packages/pull/2679#discussion_r566280566 --- Haskell/Haskell.sublime-syntax | 27 +++++++++------ Haskell/tests/syntax_test_haskell.hs | 50 +++++++++++----------------- 2 files changed, 37 insertions(+), 40 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index fa6f2792fe..8bc5b19e35 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -934,6 +934,7 @@ contexts: - include: else-pop type-lists: + - include: list-constructors - match: \[ scope: punctuation.section.sequence.begin.haskell push: type-list-body @@ -948,7 +949,7 @@ contexts: type-parens: # 4.1.3 Syntax of Class Assertions and Contexts # https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-630004.1 - - include: empty-tuples + - include: tuple-constructors - include: prefix-parens-operators - match: (?=\() branch_point: type-parens @@ -1018,6 +1019,7 @@ contexts: lists: # 3.7 Lists # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-340003.7 + - include: list-constructors - match: \[ scope: punctuation.section.sequence.begin.haskell push: list-body @@ -1041,6 +1043,10 @@ contexts: - match: (?:group|by|using){{break}} scope: keyword.control.list.haskell + list-constructors: + - match: \[\] + scope: meta.sequence.list.haskell constant.language.list.haskell + quasi-quotes: # https://wiki.haskell.org/Quasiquotation - match: (\[)([\w'']+)(\|) @@ -1062,7 +1068,7 @@ contexts: parens: # 3.8 Tuples # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-360003.8 - - include: empty-tuples + - include: tuple-constructors - include: unboxed-tuples - include: prefix-parens-operators - match: (?=\() @@ -1107,14 +1113,15 @@ contexts: - include: expressions - include: else-pop - empty-tuples: - # 3.9 Unit Expressions and Parenthesized Expressions - # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-380003.9 - - match: (\()\s*(\)) - scope: meta.sequence.tuple.haskell - captures: - 1: punctuation.section.sequence.begin.haskell - 2: punctuation.section.sequence.end.haskell + tuple-constructors: + # 6.1.4 Tuple Data Type + # https://www.haskell.org/onlinereport/haskell2010/haskellch6.html#x13-1200006.1.4 + - match: \(,+\) + scope: meta.sequence.tuple.haskell constant.language.tuple.haskell + # 6.1.5 Unit Data Type + # https://www.haskell.org/onlinereport/haskell2010/haskellch6.html#x13-1200006.1.5 + - match: \(\) + scope: meta.sequence.tuple.haskell constant.language.unit.haskell range-tuples: - match: (\()\s*(\.\.)\s*(\)) diff --git a/Haskell/tests/syntax_test_haskell.hs b/Haskell/tests/syntax_test_haskell.hs index caa7df9b15..d9064eb3c0 100644 --- a/Haskell/tests/syntax_test_haskell.hs +++ b/Haskell/tests/syntax_test_haskell.hs @@ -1043,9 +1043,7 @@ -- ^^^^ meta.declaration.class.context.haskell -- ^^^ meta.declaration.class.haskell -- ^^^^^ keyword.declaration.class.haskell --- ^^ meta.sequence.tuple.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^^ constant.language.unit.haskell -- ^^ keyword.operator.big-arrow.haskell class (Functor t, Foldable t) => Traversable t where @@ -1221,8 +1219,7 @@ -- ^^^^ keyword.declaration.data.haskell -- ^^^^^^^^ storage.modifier.family.haskell -- ^^^^^ entity.name.type.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^^ constant.language.unit.haskell -- ^ keyword.operator.haskell -- ^^^^^^^^^ storage.type.haskell -- ^ keyword.operator.haskell @@ -1498,8 +1495,7 @@ -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ entity.name.class.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^^ constant.language.list.haskell instance ModId.QTyCls () -- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence @@ -1509,8 +1505,7 @@ -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ entity.name.class.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^^ constant.language.unit.haskell instance ModId.QTyCls (,) -- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence @@ -1520,9 +1515,7 @@ -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ entity.name.class.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^ punctuation.separator.sequence.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^^^ constant.language.tuple.haskell instance ModId.QTyCls (->) -- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.prefix @@ -1595,8 +1588,7 @@ -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ entity.name.class.haskell -- ^ punctuation.section.group.begin.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^^ constant.language.list.haskell -- ^ variable.other.haskell -- ^ variable.other.haskell -- ^ punctuation.section.group.end.haskell @@ -1612,8 +1604,7 @@ -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ entity.name.class.haskell -- ^ punctuation.section.group.begin.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^^ constant.language.unit.haskell -- ^ variable.other.haskell -- ^ variable.other.haskell -- ^ punctuation.section.group.end.haskell @@ -1629,9 +1620,7 @@ -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ entity.name.class.haskell -- ^ punctuation.section.group.begin.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^ punctuation.separator.sequence.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^^^ constant.language.tuple.haskell -- ^ variable.other.haskell -- ^ variable.other.haskell -- ^ punctuation.section.group.end.haskell @@ -1747,9 +1736,7 @@ -- ^^^^^^^^^^^^^^^^^ meta.declaration.deriving.haskell meta.sequence.tuple.haskell -- ^ - meta.declaration -- ^^^^ keyword.declaration.newtype.haskell --- ^^ meta.sequence.tuple.haskell --- ^ punctuation.section.sequence.begin.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^^ meta.sequence.tuple.haskell constant.language.unit.haskell -- ^^ keyword.operator.big-arrow.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell @@ -2428,8 +2415,7 @@ main = do -- ^ - meta.sequence -- ^^ meta.sequence.list.haskell -- ^ - meta.sequence --- ^ punctuation.section.sequence.begin.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^^ constant.language.list.haskell [,] -- ^ - meta.sequence @@ -2601,15 +2587,19 @@ main = do -- ^ - meta.sequence -- ^^ meta.sequence.tuple.haskell -- ^ - meta.sequence --- ^ punctuation.section.sequence.begin.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^^ constant.language.unit.haskell (,) -- ^ - meta.sequence -- ^^^ meta.sequence.tuple.haskell -- ^ - meta.sequence --- ^ punctuation.section.sequence.begin.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^^^ constant.language.tuple.haskell + + (,,) +-- ^ - meta.sequence +-- ^^^^ meta.sequence.tuple.haskell +-- ^ - meta.sequence +-- ^^^^ constant.language.tuple.haskell (#,#) -- ^ - meta.sequence @@ -3805,8 +3795,8 @@ main = do ( ) , ; [ ] ` { } -- special symbols -- ^^^^^^^^^^^^^^^^^ - keyword --- ^ punctuation.section.sequence.begin.haskell --- ^ punctuation.section.sequence.end.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^ punctuation.section.group.end.haskell -- ^ punctuation.separator.sequence.haskell -- ^ punctuation.terminator.statement.haskell -- ^ punctuation.section.sequence.begin.haskell From 71c6f2ed3580a8ac3c50cd51861efd800a4228fc Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sat, 6 Feb 2021 13:17:01 +0100 Subject: [PATCH 165/178] [Haskell] Tweak scopes for empty tuples and lists This commit... 1. partly reverts the former commit 2. scopes all empty * tuples `()` meta.sequence.tuple.empty * lists `[]` meta.sequence.list.empty This way those are scoped as any other sequence including punctuation by default, while also enabling color schemes to highlight those in special ways without stacking too many scopes onto each other which might cause conflicts with regards to `constant` vs. `punctuation`. Such strategies also failed in other situations such as function declarations and may not ease color scheme development. Note: The `empty` sub-scope is used for such tokens in python and PHP too. related discussion: - https://github.com/sublimehq/Packages/pull/2679#discussion_r571402212 --- Haskell/Haskell.sublime-syntax | 30 +++++++------- Haskell/tests/syntax_test_haskell.hs | 58 ++++++++++++++++------------ 2 files changed, 50 insertions(+), 38 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 8bc5b19e35..913b65fd04 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -934,7 +934,7 @@ contexts: - include: else-pop type-lists: - - include: list-constructors + - include: empty-lists - match: \[ scope: punctuation.section.sequence.begin.haskell push: type-list-body @@ -949,7 +949,7 @@ contexts: type-parens: # 4.1.3 Syntax of Class Assertions and Contexts # https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-630004.1 - - include: tuple-constructors + - include: empty-tuples - include: prefix-parens-operators - match: (?=\() branch_point: type-parens @@ -1019,7 +1019,7 @@ contexts: lists: # 3.7 Lists # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-340003.7 - - include: list-constructors + - include: empty-lists - match: \[ scope: punctuation.section.sequence.begin.haskell push: list-body @@ -1043,9 +1043,12 @@ contexts: - match: (?:group|by|using){{break}} scope: keyword.control.list.haskell - list-constructors: - - match: \[\] - scope: meta.sequence.list.haskell constant.language.list.haskell + empty-lists: + - match: (\[)(\]) + scope: meta.sequence.list.empty.haskell + captures: + 1: punctuation.section.sequence.begin.haskell + 2: punctuation.section.sequence.end.haskell quasi-quotes: # https://wiki.haskell.org/Quasiquotation @@ -1068,7 +1071,7 @@ contexts: parens: # 3.8 Tuples # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-360003.8 - - include: tuple-constructors + - include: empty-tuples - include: unboxed-tuples - include: prefix-parens-operators - match: (?=\() @@ -1113,15 +1116,14 @@ contexts: - include: expressions - include: else-pop - tuple-constructors: - # 6.1.4 Tuple Data Type - # https://www.haskell.org/onlinereport/haskell2010/haskellch6.html#x13-1200006.1.4 - - match: \(,+\) - scope: meta.sequence.tuple.haskell constant.language.tuple.haskell + empty-tuples: # 6.1.5 Unit Data Type # https://www.haskell.org/onlinereport/haskell2010/haskellch6.html#x13-1200006.1.5 - - match: \(\) - scope: meta.sequence.tuple.haskell constant.language.unit.haskell + - match: (\()(\)) + scope: meta.sequence.tuple.empty.haskell + captures: + 1: punctuation.section.sequence.begin.haskell + 2: punctuation.section.sequence.end.haskell range-tuples: - match: (\()\s*(\.\.)\s*(\)) diff --git a/Haskell/tests/syntax_test_haskell.hs b/Haskell/tests/syntax_test_haskell.hs index d9064eb3c0..ccd6bfb5e9 100644 --- a/Haskell/tests/syntax_test_haskell.hs +++ b/Haskell/tests/syntax_test_haskell.hs @@ -1043,7 +1043,9 @@ -- ^^^^ meta.declaration.class.context.haskell -- ^^^ meta.declaration.class.haskell -- ^^^^^ keyword.declaration.class.haskell --- ^^ constant.language.unit.haskell +-- ^^ meta.sequence.tuple.empty.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell -- ^^ keyword.operator.big-arrow.haskell class (Functor t, Foldable t) => Traversable t where @@ -1219,7 +1221,8 @@ -- ^^^^ keyword.declaration.data.haskell -- ^^^^^^^^ storage.modifier.family.haskell -- ^^^^^ entity.name.type.haskell --- ^^ constant.language.unit.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell -- ^ keyword.operator.haskell -- ^^^^^^^^^ storage.type.haskell -- ^ keyword.operator.haskell @@ -1489,23 +1492,25 @@ instance ModId.QTyCls [] -- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence --- ^^ meta.declaration.instance.haskell meta.sequence.list.haskell +-- ^^ meta.declaration.instance.haskell meta.sequence.list.empty.haskell -- ^ meta.declaration.instance.haskell - meta.sequence -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ entity.name.class.haskell --- ^^ constant.language.list.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell instance ModId.QTyCls () -- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence --- ^^ meta.declaration.instance.haskell meta.sequence.tuple.haskell +-- ^^ meta.declaration.instance.haskell meta.sequence.tuple.empty.haskell -- ^ meta.declaration.instance.haskell - meta.sequence -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ entity.name.class.haskell --- ^^ constant.language.unit.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell instance ModId.QTyCls (,) -- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.sequence @@ -1515,7 +1520,9 @@ -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ entity.name.class.haskell --- ^^^ constant.language.tuple.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^ punctuation.section.sequence.end.haskell instance ModId.QTyCls (->) -- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.prefix @@ -1580,7 +1587,7 @@ instance ModId.QTyCls ([] a b) -- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.group -- ^ meta.declaration.instance.haskell meta.group.haskell --- ^^ meta.declaration.instance.haskell meta.group.haskell meta.sequence.list.haskell +-- ^^ meta.declaration.instance.haskell meta.group.haskell meta.sequence.list.empty.haskell -- ^^^^^ meta.declaration.instance.haskell meta.group.haskell -- ^ meta.declaration.instance.haskell - meta.group -- ^^^^^^^^ keyword.declaration.instance.haskell @@ -1588,7 +1595,8 @@ -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ entity.name.class.haskell -- ^ punctuation.section.group.begin.haskell --- ^^ constant.language.list.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell -- ^ variable.other.haskell -- ^ variable.other.haskell -- ^ punctuation.section.group.end.haskell @@ -1596,7 +1604,7 @@ instance ModId.QTyCls (() a b) -- ^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell - meta.group -- ^ meta.declaration.instance.haskell meta.group.haskell --- ^^ meta.declaration.instance.haskell meta.group.haskell meta.sequence.tuple.haskell +-- ^^ meta.declaration.instance.haskell meta.group.haskell meta.sequence.tuple.empty.haskell -- ^^^^^ meta.declaration.instance.haskell meta.group.haskell -- ^ meta.declaration.instance.haskell - meta.group -- ^^^^^^^^ keyword.declaration.instance.haskell @@ -1604,7 +1612,8 @@ -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ entity.name.class.haskell -- ^ punctuation.section.group.begin.haskell --- ^^ constant.language.unit.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell -- ^ variable.other.haskell -- ^ variable.other.haskell -- ^ punctuation.section.group.end.haskell @@ -1620,7 +1629,9 @@ -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ entity.name.class.haskell -- ^ punctuation.section.group.begin.haskell --- ^^^ constant.language.tuple.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^ punctuation.section.sequence.end.haskell -- ^ variable.other.haskell -- ^ variable.other.haskell -- ^ punctuation.section.group.end.haskell @@ -1736,7 +1747,9 @@ -- ^^^^^^^^^^^^^^^^^ meta.declaration.deriving.haskell meta.sequence.tuple.haskell -- ^ - meta.declaration -- ^^^^ keyword.declaration.newtype.haskell --- ^^ meta.sequence.tuple.haskell constant.language.unit.haskell +-- ^^ meta.sequence.tuple.empty.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell -- ^^ keyword.operator.big-arrow.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell @@ -2413,9 +2426,10 @@ main = do [] -- ^ - meta.sequence --- ^^ meta.sequence.list.haskell +-- ^^ meta.sequence.list.empty.haskell -- ^ - meta.sequence --- ^^ constant.language.list.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell [,] -- ^ - meta.sequence @@ -2585,21 +2599,17 @@ main = do () -- ^ - meta.sequence --- ^^ meta.sequence.tuple.haskell +-- ^^ meta.sequence.tuple.empty.haskell -- ^ - meta.sequence --- ^^ constant.language.unit.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell (,) -- ^ - meta.sequence -- ^^^ meta.sequence.tuple.haskell -- ^ - meta.sequence --- ^^^ constant.language.tuple.haskell - - (,,) --- ^ - meta.sequence --- ^^^^ meta.sequence.tuple.haskell --- ^ - meta.sequence --- ^^^^ constant.language.tuple.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ punctuation.section.sequence.end.haskell (#,#) -- ^ - meta.sequence From a1af7c2c2809503adc189783b684ead498397c44 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sat, 6 Feb 2021 13:41:46 +0100 Subject: [PATCH 166/178] [Haskell] Scope :: as punctuation.separator.type The new scope is also used by C#, TypeScript, PHP and Rust for tokens of comparable meaning. Related discussion: https://github.com/sublimehq/Packages/pull/2679#discussion_r567822701 --- Haskell/Haskell.sublime-syntax | 4 +- Haskell/tests/syntax_test_haskell.hs | 68 ++++++++++++++-------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 913b65fd04..6763d87c79 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -788,7 +788,7 @@ contexts: function-name: - meta_content_scope: meta.function.identifier.haskell - match: '{{operator_double_colon}}' - scope: keyword.operator.double-colon.haskell + scope: punctuation.separator.type.haskell pop: 1 - match: '{{var_id}}' scope: entity.name.function.haskell @@ -1347,7 +1347,7 @@ contexts: - match: \' scope: keyword.operator.haskell - match: '{{operator_double_colon}}' - scope: keyword.operator.double-colon.haskell + scope: punctuation.separator.type.haskell - match: '{{operator_symbol}}' scope: keyword.operator.haskell diff --git a/Haskell/tests/syntax_test_haskell.hs b/Haskell/tests/syntax_test_haskell.hs index ccd6bfb5e9..1e7bfea4d8 100644 --- a/Haskell/tests/syntax_test_haskell.hs +++ b/Haskell/tests/syntax_test_haskell.hs @@ -214,7 +214,7 @@ -- ^^^^^^^^^^ keyword.directive.builtin.haskell -- ^^^^^^ keyword.directive.builtin.haskell -- ^^^^^^ entity.name.function.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^^^^ support.type.prelude.haskell -- ^^ keyword.operator.arrow.haskell -- ^^ support.type.prelude.haskell @@ -810,7 +810,7 @@ -- ^^^^^^ keyword.declaration.export.haskell -- ^^^^^ constant.language.convention.haskell -- ^^^^^^ entity.name.function.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^^^ support.type.prelude.haskell -- ^^ keyword.operator.arrow.haskell -- ^^^ support.type.prelude.haskell @@ -832,7 +832,7 @@ -- ^^^^^^ entity.name.function.haskell :: Int -> Int -- ^ meta.declaration.foreign.export.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^^^ support.type.prelude.haskell -- ^^ keyword.operator.arrow.haskell -- ^^^ support.type.prelude.haskell @@ -844,7 +844,7 @@ -- ^^^^^ constant.language.convention.haskell -- ^^^^^^^ entity.name.function.haskell -- ^ storage.modifier.unboxed.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^^^ support.type.prelude.haskell -- ^^ keyword.operator.arrow.haskell -- ^^^ support.type.prelude.haskell @@ -859,7 +859,7 @@ -- ^ punctuation.definition.prefix.begin.haskell -- ^ keyword.operator.haskell -- ^ punctuation.definition.prefix.end.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^^^ support.type.prelude.haskell -- ^^ keyword.operator.arrow.haskell -- ^^^ support.type.prelude.haskell @@ -899,7 +899,7 @@ -- ^^^^^ constant.language.convention.haskell -- ^^^^^ meta.string.haskell string.quoted.double.haskell -- ^^^^^ entity.name.function.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^^^^^^ support.type.prelude.haskell -- ^^ keyword.operator.arrow.haskell -- ^^^^^^ support.type.prelude.haskell @@ -913,7 +913,7 @@ -- ^^^^^^ meta.string.haskell string.quoted.double.haskell -- ^^^^^ entity.name.function.haskell -- ^ storage.modifier.unboxed.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^^^^^^ support.type.prelude.haskell -- ^^ keyword.operator.arrow.haskell -- ^^^^ support.type.prelude.haskell @@ -928,7 +928,7 @@ -- ^ punctuation.definition.prefix.begin.haskell -- ^ keyword.operator.haskell -- ^ punctuation.definition.prefix.end.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^^^ support.type.prelude.haskell -- ^^ keyword.operator.arrow.haskell -- ^^^ support.type.prelude.haskell @@ -1240,23 +1240,23 @@ -- ^ punctuation.section.block.begin.haskell recordInt :: Int -- ^^^^^^^^^ variable.other.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^^^ support.type.prelude.haskell , recordString :: String -- ^ punctuation.separator.sequence.haskell -- ^^^^^^^^^^^^ variable.other.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^^^^^^ support.type.prelude.haskell , recordDouble :: Double# -- ^ punctuation.separator.sequence.haskell -- ^^^^^^^^^^^^ variable.other.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^^^^^^^ support.type.unboxed.haskell -- ^ storage.modifier.unboxed.haskell , recordRational :: Rational -- ^ punctuation.separator.sequence.haskell -- ^^^^^^^^^^^^^^ variable.other.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^^^^^^^^ support.class.prelude.haskell } deriving (Eq, Ord, Generic) -- ^^ meta.block.haskell @@ -1334,11 +1334,11 @@ -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.haskell -- ^ punctuation.section.block.begin.haskell -- ^^^^^^^^^^^^^ meta.block.haskell variable.other.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^^^ support.type.prelude.haskell -- ^ punctuation.separator.sequence.haskell -- ^^^^^^^^^^^^^^^^ meta.block.haskell variable.other.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^^^^^^ support.type.prelude.haskell -- ^ punctuation.section.block.end.haskell deriving (Eq, Ord, Generic) @@ -1353,7 +1353,7 @@ -- ^ punctuation.definition.prefix.begin.haskell -- ^^^ keyword.operator.haskell -- ^ punctuation.definition.prefix.end.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^^^^^^ keyword.control.forall.haskell -- ^ punctuation.separator.sequence.haskell -- ^^^^^^^^^^^^ variable.namespace.haskell @@ -1365,7 +1365,7 @@ -- ^ punctuation.definition.prefix.begin.haskell -- ^^ keyword.operator.haskell -- ^ punctuation.definition.prefix.end.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^^^^^^ keyword.control.forall.haskell -- ^ punctuation.separator.sequence.haskell -- ^^^^^^^^^^^^ variable.namespace.haskell @@ -1374,7 +1374,7 @@ , fail :: ∀ m a . Unrestricted.MonadFail m => String -> m a -- ^ punctuation.separator.sequence.haskell -- ^^^^ support.function.prelude.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^ keyword.control.forall.haskell -- ^ punctuation.separator.sequence.haskell -- ^^^^^^^^^^^^ variable.namespace.haskell @@ -1383,7 +1383,7 @@ , return :: forall m a . Unrestricted.Monad m => a -> m a -- ^ punctuation.separator.sequence.haskell -- ^^^^^^ support.function.prelude.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^^^^^^ keyword.control.forall.haskell -- ^ punctuation.separator.sequence.haskell -- ^^^^^^^^^^^^ variable.namespace.haskell @@ -1980,7 +1980,7 @@ :: a -> Bool -- ^ meta.function.identifier.haskell -- ^^^^^^^^^^^^^ - meta.function --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^ variable.other.haskell -- ^^ keyword.operator.arrow.haskell -- ^^^^ support.type.prelude.haskell @@ -2006,7 +2006,7 @@ :: a -> Bool -- ^ meta.function.identifier.haskell -- ^^^^^^^^^^^^^ - meta.function --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^ variable.other..haskell -- ^^ keyword.operator.arrow.haskell -- ^^^^ support.type.prelude.haskell @@ -2015,7 +2015,7 @@ sequenceA ∷ Applicative f ⇒ t (f a) → f (t a) -- ^^^^^^^^^^ meta.function.identifier.haskell -- ^^^^^^^^^ entity.name.function.haskell --- ^ keyword.operator.double-colon.haskell +-- ^ punctuation.separator.type.haskell -- ^^^^^^^^^^^ support.class.prelude.haskell -- ^ variable.other.haskell -- ^ keyword.operator.big-arrow.haskell @@ -2042,7 +2042,7 @@ -- ^^^^^^^^^ meta.function.identifier.haskell -- ^^^^^^^^^^^^^^^^^^^^ - meta.function -- ^^^^^^^^ entity.name.function.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^^^^^^^^^^^ support.class.prelude.haskell -- ^ variable.other.haskell -- ^^ keyword.operator.big-arrow.haskell @@ -2105,7 +2105,7 @@ fun :: Bool -> Bool -- ^^^^ meta.function.identifier.haskell -- ^^^ entity.name.function.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell fun = print "Hello" -- ^^^ variable.other.haskell -- ^ keyword.operator.haskell @@ -2123,7 +2123,7 @@ -- ^ punctuation.section.block.begin.haskell -- ^^^^^ meta.function.identifier.haskell -- ^^^^ entity.name.function.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^^^^ support.type.prelude.haskell -- ^^ keyword.operator.arrow.haskell -- ^^^^ support.type.prelude.haskell @@ -2133,7 +2133,7 @@ -- ^^^^^ support.constant.prelude.haskell -- ^ punctuation.terminator.statement.haskell -- ^^^^ entity.name.function.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^ punctuation.section.block.end.haskell {- Class Method Declarations -} @@ -2141,7 +2141,7 @@ nethod1 :: a -> Bool -- ^^^^^^^^ meta.function.identifier.haskell -- ^^^^^^^ entity.name.function.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^ variable.other.haskell -- ^^ keyword.operator.arrow.haskell -- ^^^^ support.type.prelude.haskell @@ -2166,7 +2166,7 @@ -- ^^^^^^^ meta.block.haskell meta.function.identifier.haskell -- ^^^^^^^^^^^^^^^^^ meta.block.haskell - meta.function -- ^^^^^^ entity.name.function.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^^^^ support.type.prelude.haskell -- ^^ keyword.operator.arrow.haskell -- ^^^^ support.type.prelude.haskell @@ -2187,7 +2187,7 @@ -- ^^^^^^^^^^^^^^^^^ meta.block.haskell - meta.function -- ^ punctuation.terminator.statement.haskell -- ^^^^^^ entity.name.function.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^^^^ support.type.prelude.haskell -- ^^ keyword.operator.arrow.haskell -- ^^^^ support.type.prelude.haskell @@ -2199,7 +2199,7 @@ nethod1 :: a -> Bool -- ^^^^^^^^ meta.function.identifier.haskell -- ^^^^^^^ entity.name.function.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^ variable.other.haskell -- ^^ keyword.operator.arrow.haskell -- ^^^^ support.type.prelude.haskell @@ -2224,7 +2224,7 @@ -- ^^^^^^^ meta.block.haskell meta.function.identifier.haskell -- ^^^^^^^^^^^^^^^^^ meta.block.haskell - meta.function -- ^^^^^^ entity.name.function.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^^^^ support.type.prelude.haskell -- ^^ keyword.operator.arrow.haskell -- ^^^^ support.type.prelude.haskell @@ -2245,7 +2245,7 @@ -- ^^^^^^^^^^^^^^^^^ meta.block.haskell - meta.function -- ^ punctuation.terminator.statement.haskell -- ^^^^^^ entity.name.function.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^^^^ support.type.prelude.haskell -- ^^ keyword.operator.arrow.haskell -- ^^^^ support.type.prelude.haskell @@ -2372,7 +2372,7 @@ test = --^^^ keyword.declaration.variable.haskell -- ^^^^^^^ meta.function.identifier.haskell -- ^^^^^^ entity.name.function.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell runIO' f = do let isWarning msg = messageVerbosity msg == WARNING -- ^^^ keyword.declaration.variable.haskell @@ -2468,7 +2468,7 @@ main = do -- ^^^^^^^^^ meta.sequence.list.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^ variable.other.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^ variable.other.haskell B c ] -- ^^^^^^ meta.sequence.list.haskell @@ -3793,7 +3793,7 @@ main = do .. : :: = \ <- | -> @ ~ => -- reserved operators -- ^^ keyword.operator.haskell -- ^ keyword.operator.haskell --- ^^ keyword.operator.double-colon.haskell +-- ^^ punctuation.separator.type.haskell -- ^ keyword.operator.haskell -- ^ keyword.operator.haskell -- ^^ keyword.operator.arrow.haskell From c8c8a67436185aa705b898c67be2ac7b94d3e251 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sat, 6 Feb 2021 13:48:00 +0100 Subject: [PATCH 167/178] [Haskell] Scope => punctuation.separator.type.context The "big arrow" `=>` is used to terminate a type's context expression. This commit interprets it as separator between the context and the rest of the type expression. Related discussion: https://github.com/sublimehq/Packages/pull/2679#discussion_r567005361 --- Haskell/Haskell.sublime-syntax | 12 ++++---- Haskell/tests/syntax_test_haskell.hs | 46 ++++++++++++++-------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 6763d87c79..52b0b13ab4 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -602,7 +602,7 @@ contexts: - match: '{{operator_big_arrow}}' scope: meta.declaration.class.haskell - keyword.operator.big-arrow.haskell + punctuation.separator.type.context.haskell set: class-signature - include: type-expressions @@ -667,7 +667,7 @@ contexts: - match: '{{operator_big_arrow}}' scope: meta.declaration.instance.haskell - keyword.operator.big-arrow.haskell + punctuation.separator.type.context.haskell set: instance-signature - include: type-expressions @@ -704,7 +704,7 @@ contexts: - match: '{{operator_big_arrow}}' scope: meta.declaration.data.haskell - keyword.operator.big-arrow.haskell + punctuation.separator.type.context.haskell set: data-signature - include: type-expressions @@ -844,7 +844,7 @@ contexts: - match: '{{operator_big_arrow}}' scope: meta.declaration.newtype.haskell - keyword.operator.big-arrow.haskell + punctuation.separator.type.context.haskell set: newtype-signature - include: type-expressions @@ -879,7 +879,7 @@ contexts: - match: '{{operator_big_arrow}}' scope: meta.declaration.type.haskell - keyword.operator.big-arrow.haskell + punctuation.separator.type.context.haskell set: type-signature - include: type-expressions @@ -1353,7 +1353,7 @@ contexts: big-arrow-operators: - match: '{{operator_big_arrow}}' - scope: keyword.operator.big-arrow.haskell + scope: punctuation.separator.type.context.haskell left-arrow-operators: - match: '{{operator_left_arrow}}' diff --git a/Haskell/tests/syntax_test_haskell.hs b/Haskell/tests/syntax_test_haskell.hs index 1e7bfea4d8..93f38c1029 100644 --- a/Haskell/tests/syntax_test_haskell.hs +++ b/Haskell/tests/syntax_test_haskell.hs @@ -954,7 +954,7 @@ -- ^ meta.declaration.class.context.haskell -- ^^^ meta.declaration.class.haskell -- ^^^^^ keyword.declaration.class.haskell --- ^^ keyword.operator.big-arrow.haskell +-- ^^ punctuation.separator.type.context.haskell class QTyCls tyVar -- ^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell @@ -992,7 +992,7 @@ -- ^^^^^^ storage.type.haskell -- ^^^^^^ variable.other.haskell -- ^^^^^^ variable.other.haskell --- ^^ keyword.operator.big-arrow.haskell +-- ^^ punctuation.separator.type.context.haskell class ModId.QTyCls (tyVar1 tyVar2#) => -- ^^^^^ meta.declaration.class.haskell @@ -1009,7 +1009,7 @@ -- ^^^^^^^ variable.other.haskell -- ^ storage.modifier.unboxed.haskell -- ^ punctuation.section.group.end.haskell --- ^^ keyword.operator.big-arrow.haskell +-- ^^ punctuation.separator.type.context.haskell class ModId.QTyCls (tyVar1 tyVar2 => ) -- ^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell - meta.group @@ -1021,7 +1021,7 @@ -- ^ punctuation.section.group.begin.haskell -- ^^^^^^ variable.other.haskell -- ^^^^^^ variable.other.haskell --- ^^ keyword.operator.big-arrow.haskell +-- ^^ punctuation.separator.type.context.haskell -- ^ punctuation.section.group.end.haskell class ModId.QTyCls tyVar1 tyVar2 => Traversable t @@ -1034,7 +1034,7 @@ -- ^^^^^^ storage.type.haskell -- ^^^^^^ variable.other.haskell -- ^^^^^^ variable.other.haskell --- ^^ keyword.operator.big-arrow.haskell +-- ^^ punctuation.separator.type.context.haskell -- ^^^^^^^^^^^ entity.name.class.haskell -- ^ variable.other.haskell @@ -1046,7 +1046,7 @@ -- ^^ meta.sequence.tuple.empty.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^ punctuation.section.sequence.end.haskell --- ^^ keyword.operator.big-arrow.haskell +-- ^^ punctuation.separator.type.context.haskell class (Functor t, Foldable t) => Traversable t where -- ^^^^^ meta.declaration.class.haskell - meta.sequence @@ -1062,7 +1062,7 @@ -- ^^^^^^^^ storage.type.haskell -- ^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell --- ^^ keyword.operator.big-arrow.haskell +-- ^^ punctuation.separator.type.context.haskell -- ^^^^^^^^^^^ entity.name.class.haskell -- ^ variable.other.haskell -- ^^^^^ keyword.control.context.haskell @@ -1078,7 +1078,7 @@ -- ^^^^^ keyword.declaration.class.haskell -- ^^ support.class.prelude.haskell -- ^ variable.other.haskell --- ^^ keyword.operator.big-arrow.haskell +-- ^^ punctuation.separator.type.context.haskell -- ^ variable.other.haskell -- ^^ keyword.operator.arrow.haskell -- ^ variable.other.haskell @@ -1092,7 +1092,7 @@ -- ^^^^^ keyword.declaration.class.haskell -- ^^ support.class.prelude.haskell -- ^ variable.other.haskell --- ^^ keyword.operator.big-arrow.haskell +-- ^^ punctuation.separator.type.context.haskell -- ^ variable.other.haskell -- ^^ keyword.operator.arrow.haskell -- ^ variable.other.haskell @@ -1119,7 +1119,7 @@ -- ^^^^^^^ support.class.prelude.haskell -- ^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell --- ^^ keyword.operator.big-arrow.haskell +-- ^^ punctuation.separator.type.context.haskell -- ^ punctuation.section.group.begin.haskell -- ^ variable.other.haskell -- ^^ keyword.operator.arrow.haskell @@ -1163,7 +1163,7 @@ -- ^^^^ keyword.declaration.data.haskell -- ^^^^^^ storage.type.haskell -- ^^^ variable.other.haskell --- ^^ keyword.operator.big-arrow.haskell +-- ^^ punctuation.separator.type.context.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ entity.name.type.haskell @@ -1189,7 +1189,7 @@ -- ^^^^^^ storage.modifier.family.haskell -- ^^^^^^ storage.type.haskell -- ^^^ variable.other.haskell --- ^^ keyword.operator.big-arrow.haskell +-- ^^ punctuation.separator.type.context.haskell -- ^^^^^ entity.name.type.haskell -- ^ variable.other.haskell @@ -1663,7 +1663,7 @@ -- ^^^^^^^^ keyword.declaration.instance.haskell -- ^^^ support.class.prelude.haskell -- ^ variable.other.haskell --- ^^ keyword.operator.big-arrow.haskell +-- ^^ punctuation.separator.type.context.haskell -- ^^^ entity.name.class.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^ variable.other.haskell @@ -1686,7 +1686,7 @@ -- ^^^^ support.class.prelude.haskell -- ^ variable.other.haskell -- ^ punctuation.section.sequence.end.haskell --- ^^ keyword.operator.big-arrow.haskell +-- ^^ punctuation.separator.type.context.haskell -- ^^^ entity.name.class.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^ variable.other.haskell @@ -1728,7 +1728,7 @@ -- ^ meta.declaration.newtype.context.haskell -- ^^^ meta.declaration.newtype.haskell -- ^^^^^^^ keyword.declaration.newtype.haskell --- ^^ keyword.operator.big-arrow.haskell +-- ^^ punctuation.separator.type.context.haskell newtype CtxCls tyVar => -- ^^^^^^^ meta.declaration.newtype.haskell @@ -1737,7 +1737,7 @@ -- ^^^^^^^ keyword.declaration.newtype.haskell -- ^^^^^^ storage.type.haskell -- ^^^^^ variable.other.haskell --- ^^ keyword.operator.big-arrow.haskell +-- ^^ punctuation.separator.type.context.haskell newtype () => ModId.QTyCls tyVar1 tyVar2 deriving (Class1, QTyCls2) -- ^^^^^^^ meta.declaration.newtype.haskell @@ -1750,7 +1750,7 @@ -- ^^ meta.sequence.tuple.empty.haskell -- ^ punctuation.section.sequence.begin.haskell -- ^ punctuation.section.sequence.end.haskell --- ^^ keyword.operator.big-arrow.haskell +-- ^^ punctuation.separator.type.context.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ entity.name.type.haskell @@ -1828,7 +1828,7 @@ -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ storage.type.haskell -- ^^^^^ variable.other.haskell --- ^^ keyword.operator.big-arrow.haskell +-- ^^ punctuation.separator.type.context.haskell -- ^^^^^ variable.namespace.haskell -- ^ punctuation.accessor.dot.haskell -- ^^^^^^ entity.name.type.haskell @@ -1873,7 +1873,7 @@ -- ^^^^ support.class.prelude.haskell -- ^ variable.other.haskell -- ^ punctuation.section.group.end.haskell --- ^^ keyword.operator.big-arrow.haskell +-- ^^ punctuation.separator.type.context.haskell -- ^ variable.other.haskell -- ^ variable.other.haskell -- ^^ keyword.operator.arrow.haskell @@ -1888,7 +1888,7 @@ -- ^^^^ support.class.prelude.haskell -- ^ variable.other.haskell -- ^ punctuation.section.group.end.haskell --- ^^ keyword.operator.big-arrow.haskell +-- ^^ punctuation.separator.type.context.haskell -- ^ variable.other.haskell -- ^ variable.other.haskell @@ -2018,7 +2018,7 @@ -- ^ punctuation.separator.type.haskell -- ^^^^^^^^^^^ support.class.prelude.haskell -- ^ variable.other.haskell --- ^ keyword.operator.big-arrow.haskell +-- ^ punctuation.separator.type.context.haskell -- ^ variable.other.haskell -- ^ punctuation.section.group.begin.haskell -- ^ variable.other.haskell @@ -2045,7 +2045,7 @@ -- ^^ punctuation.separator.type.haskell -- ^^^^^^^^^^^ support.class.prelude.haskell -- ^ variable.other.haskell --- ^^ keyword.operator.big-arrow.haskell +-- ^^ punctuation.separator.type.context.haskell (a -> f b) -- ^^ keyword.operator.arrow.haskell -> t a @@ -3801,7 +3801,7 @@ main = do -- ^^ keyword.operator.arrow.haskell -- ^ keyword.operator.haskell -- ^ keyword.operator.haskell --- ^^ keyword.operator.big-arrow.haskell +-- ^^ punctuation.separator.type.context.haskell ( ) , ; [ ] ` { } -- special symbols -- ^^^^^^^^^^^^^^^^^ - keyword From 84e468d799c78d523a5e620de3c66ce5821ce8f7 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 11 Jun 2021 17:38:57 +0200 Subject: [PATCH 168/178] [Haskell] Fix anonymous variables Underscore has special meaning and may not be suffixed by unboxed modifier. fixes: https://github.com/sublimehq/Packages/pull/2679#issuecomment-859469954 --- Haskell/Haskell.sublime-syntax | 13 ++++++++++--- Haskell/tests/syntax_test_haskell.hs | 14 ++++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 52b0b13ab4..07976a056b 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -89,7 +89,7 @@ variables: (?x: LANGUAGE | OPTIONS_GHC | OPTIONS_HADDOCK | INCLUDE | WARNING | DEPRECATED | MINIMAL | INLINE | NOINLINE | INLINABLE | CONLIKE | LINE | COLUMN | RULES - | SPECIALIZE | UNPACK | NOUNPACK | SOURCE | COMPLETE | OVERLAPPING + | SPECIALIZE | UNPACK | NOUNPACK | SOURCE | COMPLETE | OVERLAPPING | OVERLAPPABLE | OVERLAPS | INCOHERENT | CTYPE ){{break}} @@ -193,7 +193,7 @@ variables: (?x: # GHC 6.2.2 The magic hash # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/magic_hash.html - Addr | Array | Char | Double | Float | Int | Word + Addr | Array | Char | Double | Float | Int | Word # GHC 6.17.2.1 Unlifted FFI Types # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/ffi.html | ArrayArray | ByteArray | SmallArray | StablePtr @@ -811,6 +811,11 @@ contexts: - match: '{{prelude_functions}}' scope: support.function.prelude.haskell push: variable-name-end + - match: _\b + scope: variable.language.anonymous.haskell + captures: + 1: storage.modifier.unboxed.haskell + push: variable-name-end - match: '{{var_id}}' scope: variable.other.haskell captures: @@ -1156,8 +1161,10 @@ contexts: ###[ IDENTIFIERS ]############################################################# ident-anonymous: - - match: _{{break}} + - match: _\b scope: variable.language.anonymous.haskell + captures: + 1: storage.modifier.unboxed.haskell ident-builtin-classes: # Prelude Class Types diff --git a/Haskell/tests/syntax_test_haskell.hs b/Haskell/tests/syntax_test_haskell.hs index 93f38c1029..46e07a6742 100644 --- a/Haskell/tests/syntax_test_haskell.hs +++ b/Haskell/tests/syntax_test_haskell.hs @@ -2156,7 +2156,7 @@ -- ^^^^^^^^ meta.function.identifier.haskell -- ^^^^^^^ entity.name.function.haskell a -> Bool --- ^ variable.other.haskell +-- ^ variable.other.haskell -- ^^ keyword.operator.arrow.haskell -- ^^^^ support.type.prelude.haskell @@ -2733,6 +2733,15 @@ main = do _ -- ^ variable.language.anonymous.haskell + _# +-- ^ variable.language.anonymous.haskell +-- ^ keyword.operator.haskell + + _#_ +-- ^ variable.language.anonymous.haskell +-- ^ keyword.operator.haskell +-- ^ variable.language.anonymous.haskell + a -- ^ variable.other.haskell @@ -2740,7 +2749,8 @@ main = do -- ^^ variable.other.haskell _' --- ^^ variable.other.haskell +-- ^ variable.language.anonymous.haskell +-- ^ keyword.operator.haskell a' -- ^^ variable.other.haskell From 5a24244ef8a97e4f72bcb48fdcc5e91511106ffa Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 11 Jun 2021 18:45:12 +0200 Subject: [PATCH 169/178] [Haskell] Fix lists vs. quasi-quotations Fixes https://github.com/sublimehq/Packages/pull/2679#issuecomment-857651916 --- Haskell/Haskell.sublime-syntax | 63 ++++++++++++++++++---------- Haskell/tests/syntax_test_haskell.hs | 24 +++++++++++ 2 files changed, 65 insertions(+), 22 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 07976a056b..660d9d5a9a 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -236,9 +236,8 @@ contexts: - include: literal-numbers - include: type-forall - include: operators - - include: quasi-quotes + - include: brackets - include: parens - - include: lists - include: keywords - include: ident-anonymous - include: ident-namespaces @@ -1021,27 +1020,39 @@ contexts: ###[ BRACKETS ]################################################################ - lists: + brackets: # 3.7 Lists # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-340003.7 - include: empty-lists + - match: (?=\[) + branch_point: list-or-quasiquote + branch: + - list + - quasi-quote + + list: - match: \[ scope: punctuation.section.sequence.begin.haskell - push: list-body - - list-end: - - match: \] - scope: punctuation.section.sequence.end.haskell - pop: 1 + set: list-body list-body: - meta_scope: meta.sequence.list.haskell + - include: list-fail - include: list-end - - include: records - include: list-keywords + - include: records - include: expressions - include: else-pop + list-end: + - match: \] + scope: punctuation.section.sequence.end.haskell + pop: 1 + + list-fail: + - match: \|\] + fail: list-or-quasiquote + list-keywords: # 6.2.7. Generalised (SQL-like) List Comprehensions # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/generalised_list_comprehensions.html @@ -1055,20 +1066,28 @@ contexts: 1: punctuation.section.sequence.begin.haskell 2: punctuation.section.sequence.end.haskell - quasi-quotes: + quasi-quote: # https://wiki.haskell.org/Quasiquotation - - match: (\[)([\w'']+)(\|) - captures: - 1: punctuation.section.quasi-quotes.begin.haskell - 2: variable.function.quasi-quoter.haskell - 3: punctuation.section.quasi-quotes.haskell - push: quasi-quotes-body - - quasi-quotes-body: - - meta_scope: meta.quasi-quotes.haskell - - meta_content_scope: meta.string.haskell string.unquoted.haskell + - match: \[ + scope: meta.quasi-quotes.haskell punctuation.section.quasi-quotes.begin.haskell + set: quasi-quote-name + + quasi-quote-name: + - meta_content_scope: meta.quasi-quotes.haskell + - match: \| + scope: meta.quasi-quotes.haskell punctuation.section.quasi-quotes.haskell + set: quasi-quote-body + - match: '[\w'']+' + scope: variable.function.quasi-quoter.haskell + - include: quasi-quote-end + + quasi-quote-body: + - meta_content_scope: meta.quasi-quotes.haskell meta.string.haskell string.unquoted.haskell + - include: quasi-quote-end + + quasi-quote-end: - match: \|\] - scope: punctuation.section.quasi-quotes.end.haskell + scope: meta.quasi-quotes.haskell punctuation.section.quasi-quotes.end.haskell pop: 1 ###[ PARENTHESES ]############################################################# diff --git a/Haskell/tests/syntax_test_haskell.hs b/Haskell/tests/syntax_test_haskell.hs index 46e07a6742..344ec46234 100644 --- a/Haskell/tests/syntax_test_haskell.hs +++ b/Haskell/tests/syntax_test_haskell.hs @@ -2727,6 +2727,30 @@ main = do -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.unquoted.haskell -- ^^ punctuation.section.quasi-quotes.end.haskell + {- Custom QuasiQuoter -} + [1|True|] +-- ^^^^^^^^^ meta.quasi-quotes.haskell - meta.quasi-quotes meta.quasi-quotes +-- ^ punctuation.section.quasi-quotes.begin.haskell +-- ^ variable.function.quasi-quoter.haskell +-- ^ punctuation.section.quasi-quotes.haskell +-- ^^^^ meta.string.haskell string.unquoted.haskell +-- ^^ punctuation.section.quasi-quotes.end.haskell + + {- List Comprehension -} + [1|True] +-- ^^^^^^^^ meta.sequence.list.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^ support.constant.prelude.haskell +-- ^ punctuation.section.sequence.end.haskell + + [1||] +-- ^^^^^ meta.sequence.list.haskell +-- ^ punctuation.section.sequence.begin.haskell +-- ^ meta.number.integer.decimal.haskell constant.numeric.value.haskell +-- ^^ keyword.operator.haskell +-- ^ punctuation.section.sequence.end.haskell -- [ IDENTS ] ----------------------------------------------------------------- From 044d27a8897f52e6b5b737105244db735f013d73 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 11 Jun 2021 21:18:11 +0200 Subject: [PATCH 170/178] [Haskell] Add "type family" support Fixes https://github.com/sublimehq/Packages/pull/2679#issuecomment-859748199 --- Haskell/Haskell.sublime-syntax | 10 ++++++---- Haskell/tests/syntax_test_haskell.hs | 27 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 660d9d5a9a..b13806fe72 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -869,10 +869,12 @@ contexts: ###[ TYPE DECLARATIONS ]####################################################### types: - - match: type{{break}} - scope: - meta.declaration.type.haskell - keyword.declaration.type.haskell + # https://wiki.haskell.org/GHC/Type_families + - match: (type)(?:\s+(family))?{{break}} + scope: meta.declaration.type.haskell + captures: + 1: keyword.declaration.type.haskell + 2: storage.modifier.family.haskell branch_point: type-declaration branch: - type-signature diff --git a/Haskell/tests/syntax_test_haskell.hs b/Haskell/tests/syntax_test_haskell.hs index 344ec46234..bacb8fc2e8 100644 --- a/Haskell/tests/syntax_test_haskell.hs +++ b/Haskell/tests/syntax_test_haskell.hs @@ -1929,6 +1929,33 @@ ) -- ^ meta.group.haskell punctuation.section.group.end.haskell + type family TypeFamily +-- ^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^ keyword.declaration.type.haskell +-- ^^^^^^ storage.modifier.family.haskell +-- ^^^^^^^^^^ entity.name.type.haskell + + type family Elem c :: * +-- ^^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^ keyword.declaration.type.haskell +-- ^^^^^^ storage.modifier.family.haskell +-- ^^^^ entity.name.type.haskell +-- ^ variable.other.haskell +-- ^^ punctuation.separator.type.haskell +-- ^ keyword.operator.haskell + + type family F a b :: * -> * +-- ^^^^^^^^^^^^^^^^^^ meta.declaration.type.haskell +-- ^^^^ keyword.declaration.type.haskell +-- ^^^^^^ storage.modifier.family.haskell +-- ^ entity.name.type.haskell +-- ^ variable.other.haskell +-- ^ variable.other.haskell +-- ^^ punctuation.separator.type.haskell +-- ^ keyword.operator.haskell +-- ^^ keyword.operator.arrow.haskell +-- ^ keyword.operator.haskell + -- [ FIXITY DECLARATIONS ] ---------------------------------------------------- From c1749cbb5058db588cb2d082a3281530fef6ea62 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sat, 12 Jun 2021 17:16:40 +0200 Subject: [PATCH 171/178] [Haskell] Fix identifiers directly after numbers Resolves https://github.com/sublimehq/Packages/pull/2679#issuecomment-859941326 --- Haskell/Haskell.sublime-syntax | 12 ++++++------ Haskell/tests/syntax_test_haskell.hs | 3 +++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index b13806fe72..48e099a7ee 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -1260,7 +1260,7 @@ contexts: literal-numbers: # 2.5 Decimal floating point literals # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-190002.5 - - match: (\d{{dec_digit}}*(?:(\.){{dec_digit}}+{{dec_exponent}}?|{{dec_exponent}}))(#*){{break}} + - match: (\d{{dec_digit}}*(?:(\.){{dec_digit}}+{{dec_exponent}}?|{{dec_exponent}}))(#*) scope: meta.number.float.decimal.haskell captures: 1: constant.numeric.value.haskell @@ -1268,7 +1268,7 @@ contexts: 3: constant.numeric.suffix.haskell # GHC 6.9.3 Hexadecimal floating point literals # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/hex_float_literals.html - - match: (0[xX])({{hex_digit}}+(\.){{hex_digit}}+{{hex_exponent}}?)(#*){{break}} + - match: (0[xX])({{hex_digit}}+(\.){{hex_digit}}+{{hex_exponent}}?)(#*) scope: meta.number.float.hexadecimal.haskell captures: 1: constant.numeric.base.haskell @@ -1277,7 +1277,7 @@ contexts: 4: constant.numeric.suffix.haskell # GHC 6.9.2 Binary integer literals # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/binary_literals.html - - match: (0[bB])({{bin_digit}}+)(#*){{break}} + - match: (0[bB])({{bin_digit}}+)(#*) scope: meta.number.integer.binary.haskell captures: 1: constant.numeric.base.haskell @@ -1285,19 +1285,19 @@ contexts: 3: constant.numeric.suffix.haskell # 2.5 Numeric Literals # https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-190002.5 - - match: (0[oO])({{oct_digit}}+)(#*){{break}} + - match: (0[oO])({{oct_digit}}+)(#*) scope: meta.number.integer.octal.haskell captures: 1: constant.numeric.base.haskell 2: constant.numeric.value.haskell 3: constant.numeric.suffix.haskell - - match: (0[xX])({{hex_digit}}+)(#*){{break}} + - match: (0[xX])({{hex_digit}}+)(#*) scope: meta.number.integer.hexadecimal.haskell captures: 1: constant.numeric.base.haskell 2: constant.numeric.value.haskell 3: constant.numeric.suffix.haskell - - match: (\d{{dec_digit}}*)(#*){{break}} + - match: (\d{{dec_digit}}*)(#*) scope: meta.number.integer.decimal.haskell captures: 1: constant.numeric.value.haskell diff --git a/Haskell/tests/syntax_test_haskell.hs b/Haskell/tests/syntax_test_haskell.hs index bacb8fc2e8..fdb6006dc9 100644 --- a/Haskell/tests/syntax_test_haskell.hs +++ b/Haskell/tests/syntax_test_haskell.hs @@ -3092,6 +3092,9 @@ main = do -- ^^^^^^^^^^ constant.numeric.value.haskell -- ^ constant.numeric.suffix.haskell + 123identifier +-- ^^^ meta.number.integer.decimal.haskell constant.numeric.value.haskell +-- ^^^^^^^^^^ variable.other.haskell -- [ LITERAL CHARACTERS ] ----------------------------------------------------- From f33ae5239ebdd58883af3bafe480315cdb93ca11 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sat, 12 Jun 2021 18:28:15 +0200 Subject: [PATCH 172/178] [Haskell] Add GHC 9 LANGUAGE pragma values Resolves https://github.com/sublimehq/Packages/pull/2679#issuecomment-860074123 --- Haskell/Haskell.sublime-syntax | 6 +++--- Haskell/tests/syntax_test_haskell.hs | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 48e099a7ee..3d046604d1 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -120,14 +120,14 @@ variables: | GHCForeignImportPrim | Generali(?:s | z)edNewtypeDeriving | ImplicitParams | ImplicitPrelude | ImportQualifiedPost | ImpredicativeTypes | TypeFamilyDependencies | InstanceSigs | ApplicativeDo | InterruptibleFFI - | JavaScriptFFI | KindSignatures | LambdaCase | LiberalTypeSynonyms | MagicHash - | MonadComprehensions | MonoLocalBinds | MonomorphismRestriction + | JavaScriptFFI | KindSignatures | LambdaCase | LiberalTypeSynonyms | LinearTypes + | MagicHash | MonadComprehensions | MonoLocalBinds | MonomorphismRestriction | MultiParamTypeClasses | MultiWayIf | NumericUnderscores | NPlusKPatterns | NamedFieldPuns | NamedWildCards | NegativeLiterals | HexFloatLiterals | NondecreasingIndentation | NumDecimals | OverloadedLabels | OverloadedLists | OverloadedStrings | PackageImports | ParallelArrays | ParallelListComp | PartialTypeSignatures | PatternGuards | PatternSynonyms | PolyKinds - | PolymorphicComponents | QuantifiedConstraints | PostfixOperators + | PolymorphicComponents | QuantifiedConstraints | PostfixOperators | QualifiedDo | QuasiQuotes | Rank2Types | RankNTypes | RebindableSyntax | RecordWildCards | RecursiveDo | RelaxedLayout | RoleAnnotations | Safe | ScopedTypeVariables | StandaloneDeriving | StarIsType | StaticPointers | Strict | StrictData diff --git a/Haskell/tests/syntax_test_haskell.hs b/Haskell/tests/syntax_test_haskell.hs index fdb6006dc9..83a48b086f 100644 --- a/Haskell/tests/syntax_test_haskell.hs +++ b/Haskell/tests/syntax_test_haskell.hs @@ -172,6 +172,13 @@ -- ^^^^^^^^^^^^^^^^ constant.language.extension.haskell -- ^ punctuation.separator.sequence.haskell -- ^^^^^^^^^^^^^^^^^^^ constant.language.extension.haskell + {- New in GHC 9 -} + , QualifiedDo, LinearTypes +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.pragma.value.language.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^^^^^ constant.language.extension.haskell +-- ^ punctuation.separator.sequence.haskell +-- ^^^^^^^^^^^ constant.language.extension.haskell #-} -- ^^^ meta.preprocessor.pragma.value.haskell punctuation.section.preprocessor.end.haskell From 7cd099fa0cd3f0111c0615f9a56d9d46ad5caf44 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sun, 13 Jun 2021 11:12:13 +0200 Subject: [PATCH 173/178] [Haskell] Add profiling inline directives --- Haskell/Haskell.sublime-syntax | 6 ++++-- Haskell/tests/syntax_test_haskell.hs | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 3d046604d1..cf5928bb7f 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -1,6 +1,6 @@ %YAML 1.2 --- -# https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts.html +# https://ghc.gitlab.haskell.org/ghc/doc/users_guide # https://www.haskell.org/onlinereport/haskell2010 # https://www.sublimetext.com/docs/syntax.html name: Haskell @@ -84,13 +84,15 @@ variables: ) # GHC 6.20 Pragmas - # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/pragmas.html pragma_directives: |- (?x: + # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/pragmas.html LANGUAGE | OPTIONS_GHC | OPTIONS_HADDOCK | INCLUDE | WARNING | DEPRECATED | MINIMAL | INLINE | NOINLINE | INLINABLE | CONLIKE | LINE | COLUMN | RULES | SPECIALIZE | UNPACK | NOUNPACK | SOURCE | COMPLETE | OVERLAPPING | OVERLAPPABLE | OVERLAPS | INCOHERENT | CTYPE + # https://ghc.gitlab.haskell.org/ghc/doc/users_guide/profiling.html + | CORE | GENERATED | SCC ){{break}} # https://wiki.haskell.org/Language_extensions diff --git a/Haskell/tests/syntax_test_haskell.hs b/Haskell/tests/syntax_test_haskell.hs index 83a48b086f..5a3b3ac06d 100644 --- a/Haskell/tests/syntax_test_haskell.hs +++ b/Haskell/tests/syntax_test_haskell.hs @@ -255,6 +255,22 @@ -- ^^^^^^^^^^^^^^^^^^^^ string.quoted.double.haskell -- ^^^ punctuation.section.preprocessor.end.haskell + (res, ts) <- withRaw $ + {-# SCC attrParser #-} (AddAttributes <$> attrParser) +-- ^^^^^^^ meta.preprocessor.pragma.directive.haskell +-- ^^^^^^^^^^^ meta.preprocessor.pragma.value.other.haskell +-- ^^^ meta.preprocessor.pragma.value.haskell +-- ^^^ punctuation.section.preprocessor.begin.haskell +-- ^^^ keyword.directive.builtin.haskell +-- ^^^ punctuation.section.preprocessor.end.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.haskell +-- ^ punctuation.section.group.begin.haskell +-- ^^^^^^^^^^^^^ storage.type.haskell +-- ^^^ keyword.operator.haskell +-- ^^^^^^^^^^ variable.other.haskell +-- ^ punctuation.section.group.end.haskell + + #if 0 -- ^^^ meta.preprocessor.c -- ^ punctuation.definition.preprocessor.c From 1d64bacd88cc63cb790c2f7b5472478e8a8248b6 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sun, 13 Jun 2021 11:23:00 +0200 Subject: [PATCH 174/178] [Haskell] Add more LANGUAGE flags --- Haskell/Haskell.sublime-syntax | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index cf5928bb7f..4d288d8bd4 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -122,23 +122,25 @@ variables: | GHCForeignImportPrim | Generali(?:s | z)edNewtypeDeriving | ImplicitParams | ImplicitPrelude | ImportQualifiedPost | ImpredicativeTypes | TypeFamilyDependencies | InstanceSigs | ApplicativeDo | InterruptibleFFI - | JavaScriptFFI | KindSignatures | LambdaCase | LiberalTypeSynonyms | LinearTypes - | MagicHash | MonadComprehensions | MonoLocalBinds | MonomorphismRestriction - | MultiParamTypeClasses | MultiWayIf | NumericUnderscores | NPlusKPatterns - | NamedFieldPuns | NamedWildCards | NegativeLiterals | HexFloatLiterals + | JavaScriptFFI | KindSignatures | LambdaCase | LexicalNegation + | LiberalTypeSynonyms | LinearTypes | MagicHash | MonadComprehensions + | MonoLocalBinds | MonomorphismRestriction | MultiParamTypeClasses + | MultiWayIf | NumericUnderscores | NPlusKPatterns | NamedFieldPuns + | NamedWildCards | NegativeLiterals | HexFloatLiterals | NondecreasingIndentation | NumDecimals | OverloadedLabels | OverloadedLists | OverloadedStrings | PackageImports | ParallelArrays | ParallelListComp | PartialTypeSignatures | PatternGuards | PatternSynonyms | PolyKinds - | PolymorphicComponents | QuantifiedConstraints | PostfixOperators | QualifiedDo - | QuasiQuotes | Rank2Types | RankNTypes | RebindableSyntax | RecordWildCards - | RecursiveDo | RelaxedLayout | RoleAnnotations | Safe | ScopedTypeVariables - | StandaloneDeriving | StarIsType | StaticPointers | Strict | StrictData - | TemplateHaskell | TemplateHaskellQuotes | StandaloneKindSignatures - | TraditionalRecordSyntax | TransformListComp | TupleSections - | TypeApplications | TypeInType | TypeFamilies | TypeOperators - | TypeSynonymInstances | UnboxedTuples | UnboxedSums + | PolymorphicComponents | QuantifiedConstraints | PostfixOperators + | QualifiedDo | QuasiQuotes | Rank2Types | RankNTypes | RebindableSyntax + | RecordWildCards | RecursiveDo | RelaxedLayout | RoleAnnotations | Safe + | ScopedTypeVariables | StandaloneDeriving | StarIsType | StaticPointers + | Strict | StrictData | TemplateHaskell | TemplateHaskellQuotes + | StandaloneKindSignatures | TraditionalRecordSyntax | TransformListComp + | Trustworthy | TupleSections | TypeApplications | TypeInType | TypeFamilies + | TypeOperators | TypeSynonymInstances | UnboxedTuples | UnboxedSums | UndecidableInstances | UndecidableSuperClasses | UnicodeSyntax - | UnliftedFFITypes | UnliftedNewtypes | ViewPatterns + | UnliftedFFITypes | UnliftedNewtypes | Unsafe | ViewPatterns + | Haskell98 | Haskell2010 ){{break}} prelude_classes: |- From ea2fce61d27b6dc48fd46aff93e1b25660c835c6 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sun, 13 Jun 2021 12:05:37 +0200 Subject: [PATCH 175/178] [Haskell] Add overloaded and typed quotations Added language feature of GHC 9 see: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0246-overloaded-bracket.rst --- Haskell/Haskell.sublime-syntax | 56 +++++++++++++++++++------- Haskell/tests/syntax_test_haskell.hs | 60 ++++++++++++++++++++-------- 2 files changed, 86 insertions(+), 30 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 4d288d8bd4..fc34c00282 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -1027,8 +1027,8 @@ contexts: ###[ BRACKETS ]################################################################ brackets: - # 3.7 Lists - # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-340003.7 + - include: typed-quotes + - include: overloaded-quotes - include: empty-lists - match: (?=\[) branch_point: list-or-quasiquote @@ -1036,7 +1036,16 @@ contexts: - list - quasi-quote + empty-lists: + - match: (\[)(\]) + captures: + 0: meta.sequence.list.empty.haskell + 1: punctuation.section.sequence.begin.haskell + 2: punctuation.section.sequence.end.haskell + list: + # 3.7 Lists + # https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-340003.7 - match: \[ scope: punctuation.section.sequence.begin.haskell set: list-body @@ -1065,36 +1074,55 @@ contexts: - match: (?:group|by|using){{break}} scope: keyword.control.list.haskell - empty-lists: - - match: (\[)(\]) - scope: meta.sequence.list.empty.haskell - captures: - 1: punctuation.section.sequence.begin.haskell - 2: punctuation.section.sequence.end.haskell - quasi-quote: # https://wiki.haskell.org/Quasiquotation - match: \[ - scope: meta.quasi-quotes.haskell punctuation.section.quasi-quotes.begin.haskell + scope: meta.quoted.quasi.haskell punctuation.section.quoted.begin.haskell set: quasi-quote-name quasi-quote-name: - - meta_content_scope: meta.quasi-quotes.haskell + - meta_content_scope: meta.quoted.quasi.haskell - match: \| - scope: meta.quasi-quotes.haskell punctuation.section.quasi-quotes.haskell + scope: meta.quoted.quasi.haskell punctuation.section.quoted.haskell set: quasi-quote-body - match: '[\w'']+' scope: variable.function.quasi-quoter.haskell - include: quasi-quote-end quasi-quote-body: - - meta_content_scope: meta.quasi-quotes.haskell meta.string.haskell string.unquoted.haskell + - meta_content_scope: meta.quoted.quasi.haskell meta.string.haskell string.unquoted.haskell - include: quasi-quote-end quasi-quote-end: - match: \|\] - scope: meta.quasi-quotes.haskell punctuation.section.quasi-quotes.end.haskell + scope: meta.quoted.quasi.haskell punctuation.section.quoted.end.haskell + pop: 1 + + overloaded-quotes: + # https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0246-overloaded-bracket.rst + - match: \[\| + scope: punctuation.section.quoted.begin.haskell + push: overloaded-quote-body + + overloaded-quote-body: + - meta_scope: meta.quoted.overloaded.haskell + - match: \|\] + scope: punctuation.section.quoted.end.haskell + pop: 1 + - include: expressions + + typed-quotes: + # https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0246-overloaded-bracket.rst + - match: \[\|\|(?!\]) + scope: punctuation.section.quoted.begin.haskell + push: typed-quote-body + + typed-quote-body: + - meta_scope: meta.quoted.typed.haskell + - match: \|\|\] + scope: punctuation.section.quoted.end.haskell pop: 1 + - include: expressions ###[ PARENTHESES ]############################################################# diff --git a/Haskell/tests/syntax_test_haskell.hs b/Haskell/tests/syntax_test_haskell.hs index 5a3b3ac06d..21aa4de4c6 100644 --- a/Haskell/tests/syntax_test_haskell.hs +++ b/Haskell/tests/syntax_test_haskell.hs @@ -2757,34 +2757,34 @@ main = do {- Custom Syntax -} [expr|$x + $y|] --- ^^^^^^ meta.quasi-quotes.haskell - meta.string --- ^^^^^^^ meta.quasi-quotes.haskell meta.string.haskell --- ^^ meta.quasi-quotes.haskell - meta.string --- ^ punctuation.section.quasi-quotes.begin.haskell +-- ^^^^^^ meta.quoted.quasi.haskell - meta.string +-- ^^^^^^^ meta.quoted.quasi.haskell meta.string.haskell +-- ^^ meta.quoted.quasi.haskell - meta.string +-- ^ punctuation.section.quoted.begin.haskell -- ^^^^ variable.function.quasi-quoter --- ^ punctuation.section.quasi-quotes.haskell +-- ^ punctuation.section.quoted.haskell -- ^^^^^^^ string.unquoted.haskell --- ^^ punctuation.section.quasi-quotes.end.haskell +-- ^^ punctuation.section.quoted.end.haskell {- Raw Strings -} [r|\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}|] --- ^^^ meta.quasi-quotes.haskell - meta.string --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.quasi-quotes.haskell meta.string.haskell --- ^^ meta.quasi-quotes.haskell - meta.string --- ^ punctuation.section.quasi-quotes.begin.haskell +-- ^^^ meta.quoted.quasi.haskell - meta.string +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.quoted.quasi.haskell meta.string.haskell +-- ^^ meta.quoted.quasi.haskell - meta.string +-- ^ punctuation.section.quoted.begin.haskell -- ^ variable.function.quasi-quoter --- ^ punctuation.section.quasi-quotes.haskell +-- ^ punctuation.section.quoted.haskell -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.unquoted.haskell --- ^^ punctuation.section.quasi-quotes.end.haskell +-- ^^ punctuation.section.quoted.end.haskell {- Custom QuasiQuoter -} [1|True|] --- ^^^^^^^^^ meta.quasi-quotes.haskell - meta.quasi-quotes meta.quasi-quotes --- ^ punctuation.section.quasi-quotes.begin.haskell +-- ^^^^^^^^^ meta.quoted.quasi.haskell - meta.quoted.quasi meta.quoted.quasi +-- ^ punctuation.section.quoted.begin.haskell -- ^ variable.function.quasi-quoter.haskell --- ^ punctuation.section.quasi-quotes.haskell +-- ^ punctuation.section.quoted.haskell -- ^^^^ meta.string.haskell string.unquoted.haskell --- ^^ punctuation.section.quasi-quotes.end.haskell +-- ^^ punctuation.section.quoted.end.haskell {- List Comprehension -} [1|True] @@ -2802,6 +2802,34 @@ main = do -- ^^ keyword.operator.haskell -- ^ punctuation.section.sequence.end.haskell + {- Overloaded Quotation -} + [| putStrLn $(f) >> putStrLn $(g) |] :: (Quote m, Quasi m, MonadIO m) => m Exp +-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.quoted.overloaded.haskell +-- ^^ punctuation.section.quoted.begin.haskell +-- ^^^^^^^^ support.function.prelude.haskell +-- ^^ punctuation.section.quoted.end.haskell + + generateLoop :: (MonadReader CodeMap m, Quote m) => String -> m Exp + generateLoop name = [| +-- ^^^ meta.quoted.overloaded.haskell +-- ^^ punctuation.section.quoted.begin.haskell + let loopyCode x = +-- ^^^^^^^^^^^^^^^^^^ meta.quoted.overloaded.haskell +-- ^^^ keyword.declaration.variable.haskell + $(local (Map.insert name [|loopyCode|]) loopBody) + in loopyCode ... + |] +-- ^^^ meta.quoted.overloaded.haskell +-- ^ - meta.brackets +-- ^^ punctuation.section.quoted.end.haskell + + {- Typed Quotation -} + i :: Quote m => Code m (Int -> Int) + i = [|| \x -> x + 1 ||] +-- ^^^^^^^^^^^^^^^^^^^ meta.quoted.typed.haskell +-- ^^^ punctuation.section.quoted.begin.haskell +-- ^^^ punctuation.section.quoted.end.haskell + -- [ IDENTS ] ----------------------------------------------------------------- _ From a5e05e9f34b4da1c817f89f6c595ad5c6ff89bc5 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Tue, 15 Jun 2021 21:29:24 +0200 Subject: [PATCH 176/178] [Haskell] Add first_line_match --- Haskell/Haskell.sublime-syntax | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index fc34c00282..632abf0c77 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -12,6 +12,12 @@ file_extensions: - hs-boot - hsig +first_line_match: |- + (?xi: + ^ \#! .* \brunhaskell\b # shebang + | ^ \s* -- .*? -\*- .*? \bhaskell\b .*? -\*- # editorconfig + ) + ############################################################################### variables: From d0c5d3102d3ea90cd5c307f3da34c68e9015801f Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 28 Jul 2021 18:36:26 +0200 Subject: [PATCH 177/178] [Haskell] Fix multi-line strings Fixes #2918 --- Haskell/Haskell.sublime-syntax | 12 ++++++++++++ Haskell/tests/syntax_test_haskell.hs | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index 632abf0c77..eb26434f86 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -1379,6 +1379,18 @@ contexts: 3: constant.character.escape.octal.haskell 4: constant.character.escape.hexadecimal.haskell 5: constant.character.escape.control.haskell + - match: (\\)\s*$ + captures: + 1: punctuation.separator.continuation.haskell + push: linteral-string-continuation + + linteral-string-continuation: + - meta_include_prototype: false + - match: \\ + scope: punctuation.separator.continuation.haskell + pop: 1 + - match: (?=") + pop: 1 ###[ KEYWORDS AND OPERATORS ]################################################## diff --git a/Haskell/tests/syntax_test_haskell.hs b/Haskell/tests/syntax_test_haskell.hs index 21aa4de4c6..d4831588af 100644 --- a/Haskell/tests/syntax_test_haskell.hs +++ b/Haskell/tests/syntax_test_haskell.hs @@ -3859,6 +3859,14 @@ main = do -- ^ punctuation.definition.string.end.haskell -- ^ keyword.operator.haskell + "This is a\ +-- ^^^^^^^^^^^^ meta.string.haskell string.quoted.double.haskell +-- ^ punctuation.separator.continuation.haskell + \multi-line string literal\ + \example" +-- ^^^^^^^^^ meta.string.haskell string.quoted.double.haskell +-- ^ punctuation.separator.continuation.haskell +-- ^ punctuation.definition.string.end.haskell -- [ INFIX OPERATORS ] -------------------------------------------------------- From c6f01cab1cb054081a6a1102ed5ed986b515f81a Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 30 Jul 2021 17:33:26 +0200 Subject: [PATCH 178/178] [Haskell] Improve multi-line strings fix --- Haskell/Haskell.sublime-syntax | 12 +++++++++--- Haskell/tests/syntax_test_haskell.hs | 29 +++++++++++++++++++++++----- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/Haskell/Haskell.sublime-syntax b/Haskell/Haskell.sublime-syntax index eb26434f86..b06b26ba94 100644 --- a/Haskell/Haskell.sublime-syntax +++ b/Haskell/Haskell.sublime-syntax @@ -1381,15 +1381,21 @@ contexts: 5: constant.character.escape.control.haskell - match: (\\)\s*$ captures: - 1: punctuation.separator.continuation.haskell + 1: punctuation.definition.continuation.begin.haskell push: linteral-string-continuation linteral-string-continuation: + - clear_scopes: 2 + - meta_scope: meta.string.continuation.haskell - meta_include_prototype: false - match: \\ - scope: punctuation.separator.continuation.haskell + scope: punctuation.definition.continuation.end.haskell pop: 1 - - match: (?=") + - match: \" + scope: invalid.illegal.expect-continuation-end.haskell + pop: 2 + - match: \S + scope: invalid.illegal.expect-continuation-end.haskell pop: 1 ###[ KEYWORDS AND OPERATORS ]################################################## diff --git a/Haskell/tests/syntax_test_haskell.hs b/Haskell/tests/syntax_test_haskell.hs index d4831588af..cb5859ccc4 100644 --- a/Haskell/tests/syntax_test_haskell.hs +++ b/Haskell/tests/syntax_test_haskell.hs @@ -3860,14 +3860,33 @@ main = do -- ^ keyword.operator.haskell "This is a\ --- ^^^^^^^^^^^^ meta.string.haskell string.quoted.double.haskell --- ^ punctuation.separator.continuation.haskell +-- ^^^^^^^^^^ meta.string.haskell string.quoted.double.haskell +-- ^^ meta.string.continuation.haskell - string +-- ^ punctuation.definition.continuation.begin.haskell + "This is a\ \multi-line string literal\ - \example" --- ^^^^^^^^^ meta.string.haskell string.quoted.double.haskell --- ^ punctuation.separator.continuation.haskell +-- <- meta.string.continuation.haskell - string +-- ^^ meta.string.continuation.haskell - string +-- ^ punctuation.definition.continuation.end.haskell +-- ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.haskell string.quoted.double.haskell +-- ^^ meta.string.continuation.haskell - string +-- ^ punctuation.definition.continuation.begin.haskell + "This is a\ + \multi-line string literal\ + /example" +-- <- meta.string.continuation.haskell - string +-- ^^ meta.string.continuation.haskell - string +-- ^ invalid.illegal.expect-continuation-end.haskell +-- ^^^^^^^^ meta.string.haskell string.quoted.double.haskell -- ^ punctuation.definition.string.end.haskell + "This is a\ + " +-- <- meta.string.continuation.haskell - string +-- ^^ meta.string.continuation.haskell - string +-- ^ invalid.illegal.expect-continuation-end.haskell +-- ^ - meta.string - string - invalid + -- [ INFIX OPERATORS ] -------------------------------------------------------- ! # $ % & ⋆ + . / < = > ? @ \ ^ | - ~ : -- ascii symbols