From 83d188103fa2544fe037e3634c26ab6bbeb85b3e Mon Sep 17 00:00:00 2001 From: Nicholas Wolverson Date: Sat, 2 Apr 2016 15:28:54 +0100 Subject: [PATCH 01/82] Prepare 0.7.0 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0bf7d19..42475b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-purescript", - "version": "0.6.1", + "version": "0.7.0", "description": "PureScript language support for the Atom editor", "license": "MIT", "repository": "https://github.com/darinmorrison/atom-language-purescript", From b455faae1e2030af1158d95fb68fb546aaebb533 Mon Sep 17 00:00:00 2001 From: "Ian D. Bollinger" Date: Mon, 18 Jul 2016 10:49:20 -0400 Subject: [PATCH 02/82] Remove \b from patterns that end with apostrophes This fixes #17 and seems not to have any deleterious effects. --- grammars/purescript.cson | 6 +++--- src/purescript.coffee | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 6b8a6df..aacc4e0 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -644,21 +644,21 @@ 'patterns': [ { 'name': 'entity.name.type.purescript' - 'match': '\\b[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\b' + 'match': '\\b[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*' } ] 'data_ctor': 'patterns': [ { 'name': 'entity.name.tag.purescript' - 'match': '\\b[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\b' + 'match': '\\b[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*' } ] 'generic_type': 'patterns': [ { 'name': 'variable.other.generic-type.purescript' - 'match': '\\b(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*\\b' + 'match': '\\b(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*' } ] 'class_constraint': diff --git a/src/purescript.coffee b/src/purescript.coffee index b0736a0..8ed6d82 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -489,20 +489,20 @@ purescriptGrammar = ] type_name: name: 'entity.name.type' - match: /\b{className}\b/ + match: /\b{className}/ data_ctor: name: 'entity.name.tag' - match: /\b{className}\b/ + match: /\b{className}/ generic_type: name: 'variable.other.generic-type' - match: /\b{functionName}\b/ + match: /\b{functionName}/ class_constraint: name: 'meta.class-constraint' match: /{classConstraint}/ captures: 1: patterns: [ name: 'entity.name.type' - match: /\b{className}\b/ + match: /\b{className}/ ] 2: patterns: [ include: '#type_name' From 30c04bdfd3094ff9df77eb900b0ad232ace0da5f Mon Sep 17 00:00:00 2001 From: "Ian D. Bollinger" Date: Mon, 18 Jul 2016 11:07:55 -0400 Subject: [PATCH 03/82] Remove quasiquotes from grammar PureScript doesn't have them, yet. :( --- grammars/purescript.cson | 19 +------------------ src/purescript.coffee | 11 ----------- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index aacc4e0..4725110 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -30,23 +30,6 @@ '2': 'name': 'punctuation.definition.entity.purescript' } - { - 'begin': '(\\[)([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)(\\|)' - 'end': '(\\|)(\\])' - 'beginCaptures': - '1': - 'name': 'punctuation.definition.quasiquotes.begin.purescript' - '2': - 'name': 'entity.name.tag.purescript' - '3': - 'name': 'string.quoted.quasiquotes.purescript' - 'endCaptures': - '1': - 'name': 'string.quoted.quasiquotes.purescript' - '2': - 'name': 'punctuation.definition.quasiquotes.end.purescript' - 'contentName': 'string.quoted.quasiquotes.purescript' - } { 'name': 'meta.declaration.module.purescript' 'begin': '\\b(module)\\b' @@ -671,7 +654,7 @@ 'patterns': [ { 'name': 'entity.name.type.purescript' - 'match': '\\b[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\b' + 'match': '\\b[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*' } ] '2': diff --git a/src/purescript.coffee b/src/purescript.coffee index 8ed6d82..861e122 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -87,17 +87,6 @@ purescriptGrammar = that Haskell allows any ordinary function application (elem 4 [1..10]) to be rewritten as an infix expression (4 `elem` [1..10]). ### - , - begin: /(\[)({functionNameOne})(\|)/ - end: /(\|)(\])/ - beginCaptures: - 1: name: 'punctuation.definition.quasiquotes.begin' - 2: name: 'entity.name.tag' - 3: name: 'string.quoted.quasiquotes' - endCaptures: - 1: name: 'string.quoted.quasiquotes' - 2: name: 'punctuation.definition.quasiquotes.end' - contentName: 'string.quoted.quasiquotes' , name: 'meta.declaration.module' begin: /\b(module)\b/ From f4eadb40b0ce0eac30701bec5a460de00860ba39 Mon Sep 17 00:00:00 2001 From: "Ian D. Bollinger" Date: Mon, 18 Jul 2016 11:12:01 -0400 Subject: [PATCH 04/82] Imports can't end in semicolons --- grammars/purescript.cson | 2 +- src/purescript.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 4725110..d941156 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -117,7 +117,7 @@ { 'name': 'meta.import.purescript' 'begin': '\\b(import)\\b' - 'end': '($|;|(?=--))' + 'end': '($|(?=--))' 'beginCaptures': '1': 'name': 'keyword.other.purescript' diff --git a/src/purescript.coffee b/src/purescript.coffee index 861e122..abb669b 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -149,7 +149,7 @@ purescriptGrammar = , name: 'meta.import' begin: /\b(import)\b/ - end: /($|;|(?=--))/ + end: /($|(?=--))/ beginCaptures: 1: name: 'keyword.other' patterns: [ From d61680639dcecaf299369e79794f4a77a9af6c76 Mon Sep 17 00:00:00 2001 From: "Ian D. Bollinger" Date: Mon, 18 Jul 2016 11:13:59 -0400 Subject: [PATCH 05/82] Qualified is no longer a keyword Remove qualified as a keyword. --- grammars/purescript.cson | 2 +- src/purescript.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index d941156..cc47f67 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -129,7 +129,7 @@ 'include': '#module_exports' } { - 'match': '\\b(qualified|as|hiding)\\b' + 'match': '\\b(as|hiding)\\b' 'captures': '1': 'name': 'keyword.other.purescript' diff --git a/src/purescript.coffee b/src/purescript.coffee index abb669b..ce7a6e4 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -157,7 +157,7 @@ purescriptGrammar = , include: '#module_exports' , - match: /\b(qualified|as|hiding)\b/ + match: /\b(as|hiding)\b/ captures: 1: name: 'keyword.other' ] From 1915ea9a0f6d39d432a9faf4cf564ba6eea390c7 Mon Sep 17 00:00:00 2001 From: "Ian D. Bollinger" Date: Mon, 18 Jul 2016 11:16:57 -0400 Subject: [PATCH 06/82] Move infix[lr]? to keyword.other --- grammars/purescript.cson | 6 +----- src/purescript.coffee | 5 +---- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index cc47f67..0f4a693 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -237,16 +237,12 @@ } { 'name': 'keyword.other.purescript' - 'match': '\\b(derive|where|data|type|newtype)\\b' + 'match': '\\b(derive|where|data|type|newtype|infix[lr]?)\\b' } { 'name': 'storage.type.purescript' 'match': '\\b(data|type|newtype)\\b' } - { - 'name': 'keyword.operator.purescript' - 'match': '\\binfix[lr]?\\b' - } { 'name': 'keyword.control.purescript' 'match': '\\b(do|if|then|else|case|of|let|in)\\b' diff --git a/src/purescript.coffee b/src/purescript.coffee index ce7a6e4..1c28233 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -223,13 +223,10 @@ purescriptGrammar = ] , name: 'keyword.other' - match: /\b(derive|where|data|type|newtype)\b/ + match: /\b(derive|where|data|type|newtype|infix[lr]?)\b/ , name: 'storage.type' match: /\b(data|type|newtype)\b/ - , - name: 'keyword.operator' - match: /\binfix[lr]?\b/ , name: 'keyword.control' match: /\b(do|if|then|else|case|of|let|in)\b/ From 481ea7779cbe3261f6cd734fdd832e8d74cd0881 Mon Sep 17 00:00:00 2001 From: "Ian D. Bollinger" Date: Mon, 18 Jul 2016 11:20:55 -0400 Subject: [PATCH 07/82] Remove syntax for pragmas They're just regular comments, at least for now. --- grammars/purescript.cson | 2 +- src/purescript.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 0f4a693..91e836b 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -396,7 +396,7 @@ } { 'name': 'comment.block.purescript' - 'begin': '\\{-(?!#)' + 'begin': '\\{-' 'end': '-\\}' 'applyEndPatternLast': 1 'beginCaptures': diff --git a/src/purescript.coffee b/src/purescript.coffee index 1c28233..6af28af 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -327,7 +327,7 @@ purescriptGrammar = ] , name: 'comment.block' - begin: /\{-(?!#)/ + begin: /\{-/ end: /-\}/ applyEndPatternLast: 1 beginCaptures: From f8199c37fc364e7bd755da84b01fd8ce4c225804 Mon Sep 17 00:00:00 2001 From: "Ian D. Bollinger" Date: Mon, 18 Jul 2016 11:26:51 -0400 Subject: [PATCH 08/82] Don't highlight keywords if followed by an apostrophe where', let', etc. are all valid non-keyword symbols. --- grammars/purescript.cson | 6 +++--- src/purescript.coffee | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 91e836b..c0c6ec8 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -237,15 +237,15 @@ } { 'name': 'keyword.other.purescript' - 'match': '\\b(derive|where|data|type|newtype|infix[lr]?)\\b' + 'match': '\\b(derive|where|data|type|newtype|infix[lr]?)(?!\')\\b' } { 'name': 'storage.type.purescript' - 'match': '\\b(data|type|newtype)\\b' + 'match': '\\b(data|type|newtype)(?!\')\\b' } { 'name': 'keyword.control.purescript' - 'match': '\\b(do|if|then|else|case|of|let|in)\\b' + 'match': '\\b(do|if|then|else|case|of|let|in)(?!\')\\b' } { 'name': 'constant.numeric.float.purescript' diff --git a/src/purescript.coffee b/src/purescript.coffee index 6af28af..8d794dd 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -223,13 +223,13 @@ purescriptGrammar = ] , name: 'keyword.other' - match: /\b(derive|where|data|type|newtype|infix[lr]?)\b/ + match: /\b(derive|where|data|type|newtype|infix[lr]?)(?!')\b/ , name: 'storage.type' - match: /\b(data|type|newtype)\b/ + match: /\b(data|type|newtype)(?!')\b/ , name: 'keyword.control' - match: /\b(do|if|then|else|case|of|let|in)\b/ + match: /\b(do|if|then|else|case|of|let|in)(?!')\b/ , name: 'constant.numeric.float' match: /\b([0-9]+\.[0-9]+([eE][+-]?[0-9]+)?|[0-9]+[eE][+-]?[0-9]+)\b/ From 130f446f2c9cb2c70e0d95b5b30f0928ba238982 Mon Sep 17 00:00:00 2001 From: Nicholas Wolverson Date: Tue, 19 Jul 2016 10:12:39 +0100 Subject: [PATCH 09/82] Add few more apostrophe exclusions to keywords #17 --- grammars/purescript.cson | 8 ++++---- src/purescript.coffee | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index c0c6ec8..a0663f5 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -32,7 +32,7 @@ } { 'name': 'meta.declaration.module.purescript' - 'begin': '\\b(module)\\b' + 'begin': '\\b(module)(?!\')\\b' 'end': '(where)' 'beginCaptures': '1': @@ -58,7 +58,7 @@ } { 'name': 'meta.declaration.typeclass.purescript' - 'begin': '\\b(class)\\b' + 'begin': '\\b(class)(?!\')\\b' 'end': '\\b(where)\\b|$' 'beginCaptures': '1': @@ -74,7 +74,7 @@ } { 'name': 'meta.declaration.instance.purescript' - 'begin': '\\b(instance)\\b' + 'begin': '\\b(instance)(?!\')\\b' 'end': '\\b(where)\\b|$' 'contentName': 'meta.type-signature.purescript' 'beginCaptures': @@ -116,7 +116,7 @@ } { 'name': 'meta.import.purescript' - 'begin': '\\b(import)\\b' + 'begin': '\\b(import)(?!\')\\b' 'end': '($|(?=--))' 'beginCaptures': '1': diff --git a/src/purescript.coffee b/src/purescript.coffee index 8d794dd..985abed 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -89,7 +89,7 @@ purescriptGrammar = ### , name: 'meta.declaration.module' - begin: /\b(module)\b/ + begin: /\b(module)(?!')\b/ end: /(where)/ beginCaptures: 1: name: 'keyword.other' @@ -107,7 +107,7 @@ purescriptGrammar = ] , name: 'meta.declaration.typeclass' - begin: /\b(class)\b/ + begin: /\b(class)(?!')\b/ end: /\b(where)\b|$/ beginCaptures: 1: name: 'storage.type.class' @@ -118,7 +118,7 @@ purescriptGrammar = ] , name: 'meta.declaration.instance' - begin: /\b(instance)\b/ + begin: /\b(instance)(?!')\b/ end: /\b(where)\b|$/ contentName: 'meta.type-signature' beginCaptures: @@ -148,7 +148,7 @@ purescriptGrammar = ] , name: 'meta.import' - begin: /\b(import)\b/ + begin: /\b(import)(?!')\b/ end: /($|(?=--))/ beginCaptures: 1: name: 'keyword.other' From 47dcfb4a4e78415d051faf1713e878b2ce646477 Mon Sep 17 00:00:00 2001 From: Nicholas Wolverson Date: Tue, 19 Jul 2016 16:16:27 +0100 Subject: [PATCH 10/82] Prepare 0.7.1 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 42475b1..0b3a595 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-purescript", - "version": "0.7.0", + "version": "0.7.1", "description": "PureScript language support for the Atom editor", "license": "MIT", "repository": "https://github.com/darinmorrison/atom-language-purescript", From 372e4856f7f8548ca3f6f16c05a53fc5896f74b9 Mon Sep 17 00:00:00 2001 From: "Ian D. Bollinger" Date: Sat, 23 Jul 2016 16:07:23 -0400 Subject: [PATCH 11/82] Add forall symbol and fat left arrow as keywords Fixes #20 --- grammars/purescript.cson | 8 ++++---- src/purescript.coffee | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index a0663f5..4e3789d 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -569,7 +569,7 @@ 'patterns': [ { 'name': 'meta.class-constraints.purescript' - 'match': '(?:(?:\\()(?:(?(?:(?:(?:([\\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@@ } { 'name': 'keyword.other.big-arrow-left.purescript' - 'match': '<=' + 'match': '<=|⇐' } { 'name': 'keyword.other.forall.purescript' - 'match': 'forall' + 'match': 'forall|∀' } { 'include': '#generic_type' diff --git a/src/purescript.coffee b/src/purescript.coffee index 985abed..7e5004e 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -442,14 +442,14 @@ purescriptGrammar = name: 'meta.class-constraints' match: concat /\(/, list('classConstraints',/{classConstraint}/,/,/), - /\)/, /\s*(=>|<=|⇒)/ + /\)/, /\s*(=>|<=|⇐|⇒)/ captures: 1: patterns: [{include: '#class_constraint'}] #2,3 are from classConstraint 4: name: 'keyword.other.big-arrow' , name: 'meta.class-constraints' - match: /({classConstraint})\s*(=>|<=|⇒)/ + match: /({classConstraint})\s*(=>|<=|⇐|⇒)/ captures: 1: patterns: [{include: '#class_constraint'}] #2,3 are from classConstraint @@ -462,10 +462,10 @@ purescriptGrammar = match: /=>|⇒/ , name: 'keyword.other.big-arrow-left' - match: /<=/ + match: /<=|⇐/ , name: 'keyword.other.forall' - match: /forall/ + match: /forall|∀/ , include: '#generic_type' , From 354d00d29084cfea9073e3108101c0bfa3c94c4a Mon Sep 17 00:00:00 2001 From: "Ian D. Bollinger" Date: Sat, 23 Jul 2016 16:39:35 -0400 Subject: [PATCH 12/82] Add foreign to keywords.other This ensures foreign is always highlighted as it is a fully reserved word. --- grammars/purescript.cson | 2 +- src/purescript.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 4e3789d..64fa449 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -237,7 +237,7 @@ } { 'name': 'keyword.other.purescript' - 'match': '\\b(derive|where|data|type|newtype|infix[lr]?)(?!\')\\b' + 'match': '\\b(derive|where|data|type|newtype|infix[lr]?|foreign)(?!\')\\b' } { 'name': 'storage.type.purescript' diff --git a/src/purescript.coffee b/src/purescript.coffee index 7e5004e..e46c8b5 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -223,7 +223,7 @@ purescriptGrammar = ] , name: 'keyword.other' - match: /\b(derive|where|data|type|newtype|infix[lr]?)(?!')\b/ + match: /\b(derive|where|data|type|newtype|infix[lr]?|foreign)(?!')\b/ , name: 'storage.type' match: /\b(data|type|newtype)(?!')\b/ From 281147a7eab9bfe3038ac0522bea409d0c62a2bf Mon Sep 17 00:00:00 2001 From: Nicholas Wolverson Date: Sat, 23 Jul 2016 22:31:24 +0100 Subject: [PATCH 13/82] Highlight boolean constants. Fix #14. --- grammars/purescript.cson | 4 ++++ src/purescript.coffee | 3 +++ 2 files changed, 7 insertions(+) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 64fa449..d1e7a2a 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -251,6 +251,10 @@ 'name': 'constant.numeric.float.purescript' 'match': '\\b([0-9]+\\.[0-9]+([eE][+-]?[0-9]+)?|[0-9]+[eE][+-]?[0-9]+)\\b' } + { + 'name': 'constant.language.boolean.purescript' + 'match': '\\b(true|false)\\b' + } { 'name': 'constant.numeric.purescript' 'match': '\\b([0-9]+|0([xX][0-9a-fA-F]+|[oO][0-7]+))\\b' diff --git a/src/purescript.coffee b/src/purescript.coffee index e46c8b5..0761e9b 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -234,6 +234,9 @@ purescriptGrammar = name: 'constant.numeric.float' match: /\b([0-9]+\.[0-9]+([eE][+-]?[0-9]+)?|[0-9]+[eE][+-]?[0-9]+)\b/ # Floats are always decimal + , + name: 'constant.language.boolean' + match: /\b(true|false)\b/ , name: 'constant.numeric' match: /\b([0-9]+|0([xX][0-9a-fA-F]+|[oO][0-7]+))\b/ From 5b33cae504f3a5e087d411e7f9e2b81d3e190fde Mon Sep 17 00:00:00 2001 From: "Ian D. Bollinger" Date: Thu, 28 Jul 2016 03:34:04 -0400 Subject: [PATCH 14/82] Add snippets (#27) This commit adds snippets for most keywords. --- snippets/language-purescript.cson | 43 +++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 snippets/language-purescript.cson diff --git a/snippets/language-purescript.cson b/snippets/language-purescript.cson new file mode 100644 index 0000000..c49531e --- /dev/null +++ b/snippets/language-purescript.cson @@ -0,0 +1,43 @@ +'.source.purescript': + 'Case': + 'prefix': 'case' + 'body': 'case ${1:expression} of\n ${2:pattern} -> ${3:expression}' + 'Class': + 'prefix': 'class' + 'body': 'class ${1:Class} ${2:a} where\n ' + 'Data': + 'prefix': 'data' + 'body': 'data ${1:Name} = ${2:$1}' + 'Derive': + 'prefix': 'derive' + 'body': 'derive instance ${1:name} :: ${2:Class} ${3:Type}' + 'Forall': + 'prefix': 'forall' + 'body': 'forall ${1:a}.' + 'Foreign': + 'prefix': 'foreign' + 'body': 'foreign import' + 'If': + 'prefix': 'if' + 'body': 'if ${1:condition} then ${2:branch} else ${3:branch}' + 'Import': + 'prefix': 'import' + 'body': 'import ${1:Prelude}' + 'Instance': + 'prefix': 'instance' + 'body': 'instance ${1:name} :: ${2:Class} ${3:Type}' + 'Let': + 'prefix': 'let' + 'body': 'let ${1:binding} = ${2:expression}' + 'Module': + 'prefix': 'module' + 'body': 'module ${1:Main} where' + 'Newtype': + 'prefix': 'newtype' + 'body': 'newtype ${1:Name} = ${2:Type}' + 'Type': + 'prefix': 'type' + 'body': 'type ${1:Name} = ${2:Type}' + 'Where': + 'prefix': 'where' + 'body': 'where\n ' From 7ae577233992dc9b1d0e50b5235e3a9bc6cdd8f8 Mon Sep 17 00:00:00 2001 From: "Ian D. Bollinger" Date: Fri, 29 Jul 2016 16:02:17 -0400 Subject: [PATCH 15/82] Set autoIndentOnPaste to false Auto-indent on paste seems to get indentation wrong most of the time. It seems to be set to false in several whitespace-significant language plugins, including language-python, language-coffee-script and language-elm. (Though I added it to the last one.) Here's an example of when it gets in the way: ```purescript module MyModule ( myExport ) where ``` Let's say now I want to paste a list of imports from another module, they'll all be indented two spaces. Another example (not very imaginitive, granted): ```purescript myFirstFunction = doSomething mySecondFunction = do something somethingElse ``` If I re-order the functions by cutting an pasting, `myFirstFunction` will be indented two spaces. --- settings/language-purescript.cson | 1 + 1 file changed, 1 insertion(+) diff --git a/settings/language-purescript.cson b/settings/language-purescript.cson index 36359bd..96bf077 100644 --- a/settings/language-purescript.cson +++ b/settings/language-purescript.cson @@ -1,3 +1,4 @@ '.source.purescript': 'editor': + 'autoIndentOnPaste': false 'commentStart': '-- ' From 5b14f69d29e78d32c8894a15485e088a8035a88f Mon Sep 17 00:00:00 2001 From: "Ian D. Bollinger" Date: Fri, 29 Jul 2016 16:59:34 -0400 Subject: [PATCH 16/82] Remove operatorFun from functionTypeDeclaration Symbolic operators can no longer be declared like in Haskell. --- grammars/purescript.cson | 10 +++++----- src/purescript.coffee | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index d1e7a2a..362a62b 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -13,7 +13,7 @@ 'operatorFun': '(?:\\((?!--+\\))[\\p{S}\\p{P}&&[^(),;\\[\\]`{}_"\']]+\\))' 'character': '(?:[ -\\[\\]-~]|(\\\\(?: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\\\\\\"\'\\&]))|(\\\\o[0-7]+)|(\\\\x[0-9A-Fa-f]+)|(\\^[A-Z@\\[\\]\\\\\\^_]))' 'classConstraint': '(?:(?:([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*)\\s+)(?:(?(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[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\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)(?:\\s*(?:,)\\s*\\g)?))(?:\\s*(::|∷ )))?' 'end': '^(?!\\1[ \\t]|[ \\t]*$)' 'contentName': 'meta.type-signature.purescript' 'beginCaptures': @@ -519,7 +519,7 @@ 'patterns': [ { 'name': 'meta.function.type-declaration.purescript' - 'begin': '(?:(?:^(\\s*))(?:(?:(?:(?(?:(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|(?:\\((?!--+\\))[\\p{S}\\p{P}&&[^(),;\\[\\]`{}_"\']]+\\)))(?:\\s*(?:,)\\s*\\g)?))(?:\\s*(::|∷ ))))(?:(?!.*<-)))' + 'begin': '(?:(?:^(\\s*))(?:(?:(?:(?(?:(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)(?:\\s*(?:,)\\s*\\g)?))(?:\\s*(::|∷ ))))(?:(?!.*<-)))' 'end': '^(?!\\1[ \\t]|[ \\t]*$)' 'contentName': 'meta.type-signature.purescript' 'beginCaptures': @@ -546,8 +546,8 @@ 'patterns': [ { 'name': 'meta.record-field.type-declaration.purescript' - 'begin': '(?:(?:(?(?:(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{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2f03a 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -60,7 +60,7 @@ purescriptGrammar = classConstraint: concat /({className})\s+/, list('classConstraint',/{className}|{functionName}/,/\s+/) functionTypeDeclaration: - concat list('functionTypeDeclaration',/{functionName}|{operatorFun}/,/,/), + concat list('functionTypeDeclaration',/{functionName}/,/,/), /\s*(::|∷ )/ ctorArgs: /// (?: From 65f53d6d265a45cd82ca47bd66a2651fa69b1775 Mon Sep 17 00:00:00 2001 From: "Ian D. Bollinger" Date: Fri, 29 Jul 2016 17:00:48 -0400 Subject: [PATCH 17/82] Replace references to Haskell Comments now refer to PureScript rather than Haskell. --- src/purescript.coffee | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/purescript.coffee b/src/purescript.coffee index ef2f03a..08f813e 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -33,7 +33,7 @@ purescriptGrammar = className: /{classNameOne}(?:\.{classNameOne})*/ operatorChar: /[\p{S}\p{P}&&[^(),;\[\]`{}_"']]/ ### - In case this regex seems overly general, note that Haskell + In case this regex seems overly general, note that PureScript permits the definition of new operators which can be nearly any string of punctuation characters, such as $%^&*. ### @@ -84,8 +84,8 @@ purescriptGrammar = 2: name: 'punctuation.definition.entity' ### In case this regex seems unusual for an infix operator, note - that Haskell allows any ordinary function application (elem 4 [1..10]) - to be rewritten as an infix expression (4 `elem` [1..10]). + that PureScript allows any ordinary function application (elem 4 (1..10)) + to be rewritten as an infix expression (4 `elem` (1..10)). ### , name: 'meta.declaration.module' From bbb0edf3dd5b09d02e79a1e36784560ad583fa33 Mon Sep 17 00:00:00 2001 From: "Ian D. Bollinger" Date: Fri, 29 Jul 2016 17:05:01 -0400 Subject: [PATCH 18/82] Remove #infix_op from where inappropriate This commit removes the inclusion of `#infix_op` from the `record_field_declaration` and `function_type_declaration` definitions. Operators can only be defined using the `infix[lr]` keywords. --- grammars/purescript.cson | 6 ------ src/purescript.coffee | 4 ---- 2 files changed, 10 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 362a62b..5cc708a 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -529,9 +529,6 @@ 'name': 'entity.name.function.purescript' 'match': '(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*' } - { - 'include': '#infix_op' - } ] '3': 'name': 'keyword.other.double-colon.purescript' @@ -556,9 +553,6 @@ 'name': 'entity.other.attribute-name.purescript' 'match': '(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*' } - { - 'include': '#infix_op' - } ] '2': 'name': 'keyword.other.double-colon.purescript' diff --git a/src/purescript.coffee b/src/purescript.coffee index 08f813e..853a377 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -416,8 +416,6 @@ purescriptGrammar = patterns: [ name: 'entity.name.function' match: /{functionName}/ - , - include: '#infix_op' ] 3: name: 'keyword.other.double-colon' patterns: [ @@ -433,8 +431,6 @@ purescriptGrammar = patterns: [ name: 'entity.other.attribute-name' match: /{functionName}/ - , - include: '#infix_op' ] 2: name: 'keyword.other.double-colon' patterns: [ From f3f2652632c6435bcef9bd081ce70949feca0941 Mon Sep 17 00:00:00 2001 From: "Ian D. Bollinger" Date: Fri, 29 Jul 2016 17:09:46 -0400 Subject: [PATCH 19/82] Remove Haddock comment syntax `psc-docs` doesn't seem to support Haddock's `-- ^` comment syntax. --- grammars/purescript.cson | 6 +++--- src/purescript.coffee | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 5cc708a..f08bb2e 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -383,7 +383,7 @@ 'patterns': [ { 'name': 'comment.block.haddock.purescript' - 'begin': '\\{-\\s*[|^]' + 'begin': '\\{-\\s*\\|' 'end': '-\\}' 'applyEndPatternLast': 1 'beginCaptures': @@ -416,7 +416,7 @@ 'comments': 'patterns': [ { - 'begin': '(^[ \\t]+)?(?=--+\\s+[|^])' + 'begin': '(^[ \\t]+)?(?=--+\\s+\\|)' 'end': '(?!\\G)' 'beginCaptures': '1': @@ -424,7 +424,7 @@ 'patterns': [ { 'name': 'comment.line.double-dash.haddock.purescript' - 'begin': '(--+)\\s+([|^])' + 'begin': '(--+)\\s+(\\|)' 'end': '\\n' 'beginCaptures': '1': diff --git a/src/purescript.coffee b/src/purescript.coffee index 853a377..126eb52 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -318,7 +318,7 @@ purescriptGrammar = block_comment: patterns: [ name: 'comment.block.haddock' - begin: /\{-\s*[|^]/ + begin: /\{-\s*\|/ end: /-\}/ applyEndPatternLast: 1 beginCaptures: @@ -341,13 +341,13 @@ purescriptGrammar = ] comments: patterns: [ - begin: /({maybeBirdTrack}[ \t]+)?(?=--+\s+[|^])/ + begin: /({maybeBirdTrack}[ \t]+)?(?=--+\s+\|)/ end: /(?!\G)/ beginCaptures: 1: name: 'punctuation.whitespace.comment.leading' patterns: [ name: 'comment.line.double-dash.haddock' - begin: /(--+)\s+([|^])/ + begin: /(--+)\s+(\|)/ end: /\n/ beginCaptures: 1: name: 'punctuation.definition.comment' From 28bb59d1679591ad60d55e4a93c1e6135a92a3dc Mon Sep 17 00:00:00 2001 From: "Ian D. Bollinger" Date: Fri, 29 Jul 2016 17:11:02 -0400 Subject: [PATCH 20/82] Rename haddock to documentation Haddock comments have been renamed to documentation comments. --- grammars/purescript.cson | 10 +++++----- src/purescript.coffee | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index f08bb2e..0cac2a4 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -382,16 +382,16 @@ 'block_comment': 'patterns': [ { - 'name': 'comment.block.haddock.purescript' + 'name': 'comment.block.documentation.purescript' 'begin': '\\{-\\s*\\|' 'end': '-\\}' 'applyEndPatternLast': 1 'beginCaptures': '0': - 'name': 'punctuation.definition.comment.haddock.purescript' + 'name': 'punctuation.definition.comment.documentation.purescript' 'endCaptures': '0': - 'name': 'punctuation.definition.comment.haddock.purescript' + 'name': 'punctuation.definition.comment.documentation.purescript' 'patterns': [ { 'include': '#block_comment' @@ -423,14 +423,14 @@ 'name': 'punctuation.whitespace.comment.leading.purescript' 'patterns': [ { - 'name': 'comment.line.double-dash.haddock.purescript' + 'name': 'comment.line.double-dash.documentation.purescript' 'begin': '(--+)\\s+(\\|)' 'end': '\\n' 'beginCaptures': '1': 'name': 'punctuation.definition.comment.purescript' '2': - 'name': 'punctuation.definition.comment.haddock.purescript' + 'name': 'punctuation.definition.comment.documentation.purescript' } ] } diff --git a/src/purescript.coffee b/src/purescript.coffee index 126eb52..39ce544 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -317,14 +317,14 @@ purescriptGrammar = repository: block_comment: patterns: [ - name: 'comment.block.haddock' + name: 'comment.block.documentation' begin: /\{-\s*\|/ end: /-\}/ applyEndPatternLast: 1 beginCaptures: - 0: name: 'punctuation.definition.comment.haddock' + 0: name: 'punctuation.definition.comment.documentation' endCaptures: - 0: name: 'punctuation.definition.comment.haddock' + 0: name: 'punctuation.definition.comment.documentation' patterns: [ include: '#block_comment' ] @@ -346,12 +346,12 @@ purescriptGrammar = beginCaptures: 1: name: 'punctuation.whitespace.comment.leading' patterns: [ - name: 'comment.line.double-dash.haddock' + name: 'comment.line.double-dash.documentation' begin: /(--+)\s+(\|)/ end: /\n/ beginCaptures: 1: name: 'punctuation.definition.comment' - 2: name: 'punctuation.definition.comment.haddock' + 2: name: 'punctuation.definition.comment.documentation' ] , ### From 284a57c22605c3d92ce26292c6bd5f89ddffa261 Mon Sep 17 00:00:00 2001 From: "Ian D. Bollinger" Date: Fri, 29 Jul 2016 23:21:25 -0400 Subject: [PATCH 21/82] Highlight "foreign import data" declarations correctly This fixes #23. --- grammars/purescript.cson | 41 ++++++++++++++++++++++++++++++++++++++++ src/purescript.coffee | 30 ++++++++++++++++++++++++++++- 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 0cac2a4..08b7763 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -89,6 +89,28 @@ } ] } + { + 'name': 'meta.foreign.data.purescript' + 'begin': '^(\\s*)(foreign)\\s+(import)\\s+(data)\\s+([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*(::|∷)' + 'end': '^(?!\\1[ \\t]|[ \\t]*$)' + 'contentName': 'meta.kind-signature.purescript' + 'beginCaptures': + '2': + 'name': 'keyword.other.purescript' + '3': + 'name': 'keyword.other.purescript' + '4': + 'name': 'keyword.other.purescript' + '5': + 'name': 'entity.name.type.purescript' + '6': + 'name': 'keyword.other.double-colon.purescript' + 'patterns': [ + { + 'include': '#kind_signature' + } + ] + } { 'name': 'meta.foreign.purescript' 'begin': '^(\\s*)(foreign)\\s+(import)\\s+(?:(?:(?(?:(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)(?:\\s*(?:,)\\s*\\g)?))(?:\\s*(::|∷ )))?' @@ -563,6 +585,25 @@ ] } ] + 'kind_signature': + 'patterns': [ + { + 'name': 'keyword.other.star.purescript' + 'match': '\\*' + } + { + 'name': 'keyword.other.exclaimation-point.purescript' + 'match': '!' + } + { + 'name': 'keyword.other.pound-sign.purescript' + 'match': '#' + } + { + 'name': 'keyword.other.arrow.purescript' + 'match': '->|→' + } + ] 'type_signature': 'patterns': [ { diff --git a/src/purescript.coffee b/src/purescript.coffee index 39ce544..116129a 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -128,10 +128,24 @@ purescriptGrammar = patterns: [ include: '#type_signature' ] + , + name: 'meta.foreign.data' + begin: /^(\s*)(foreign)\s+(import)\s+(data)\s+({classNameOne})\s*(::|∷)/ + end: /{indentBlockEnd}/ + contentName: 'meta.kind-signature' + beginCaptures: + 2: name: 'keyword.other' + 3: name: 'keyword.other' + 4: name: 'keyword.other' + 5: name: 'entity.name.type' + 6: name: 'keyword.other.double-colon' + patterns:[ + include: '#kind_signature' + ] , name: 'meta.foreign' # functionTypeDeclaration so it can be wrapped to the next line without losing most highlighting - begin: /{maybeBirdTrack}(\s*)(foreign)\s+(import)\s+{functionTypeDeclaration}?/ + begin: /^(\s*)(foreign)\s+(import)\s+{functionTypeDeclaration}?/ end: /{indentBlockEnd}/ contentName: 'meta.type-signature' beginCaptures: @@ -436,6 +450,20 @@ purescriptGrammar = patterns: [ include: '#type_signature' ] + kind_signature: + patterns: [ + name: 'keyword.other.star' + match: /\*/ + , + name: 'keyword.other.exclaimation-point' + match: /!/ + , + name: 'keyword.other.pound-sign' + match: /#/ + , + name: 'keyword.other.arrow' + match: /->|→/ + ] type_signature: patterns: [ name: 'meta.class-constraints' From 6333abae036f31b496021703fbde72b256d57273 Mon Sep 17 00:00:00 2001 From: Nicholas Wolverson Date: Sun, 31 Jul 2016 21:53:07 +0100 Subject: [PATCH 22/82] Prepare 0.8.0 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0b3a595..170965a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-purescript", - "version": "0.7.1", + "version": "0.8.0", "description": "PureScript language support for the Atom editor", "license": "MIT", "repository": "https://github.com/darinmorrison/atom-language-purescript", From 140d3600c18988ea3474004dfd6d0ed257b8d222 Mon Sep 17 00:00:00 2001 From: "Ian D. Bollinger" Date: Wed, 27 Jul 2016 02:40:31 -0400 Subject: [PATCH 23/82] Add rule for type holes Type holes will be highlighted using the ".invalid .illegal" style. --- grammars/purescript.cson | 4 ++++ src/purescript.coffee | 3 +++ 2 files changed, 7 insertions(+) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 08b7763..807f216 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -261,6 +261,10 @@ 'name': 'keyword.other.purescript' 'match': '\\b(derive|where|data|type|newtype|infix[lr]?|foreign)(?!\')\\b' } + { + 'name': 'invalid.illegal.type-hole.purescript' + 'match': '\\?(?:[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)' + } { 'name': 'storage.type.purescript' 'match': '\\b(data|type|newtype)(?!\')\\b' diff --git a/src/purescript.coffee b/src/purescript.coffee index 116129a..b53442a 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -238,6 +238,9 @@ purescriptGrammar = , name: 'keyword.other' match: /\b(derive|where|data|type|newtype|infix[lr]?|foreign)(?!')\b/ + , + name: 'invalid.illegal.type-hole' + match: /\?(?:{functionNameOne}|{classNameOne})/ , name: 'storage.type' match: /\b(data|type|newtype)(?!')\b/ From 76eb82e652e0928acd504dd9a1d09bc5801f72dd Mon Sep 17 00:00:00 2001 From: "Ian D. Bollinger" Date: Wed, 27 Jul 2016 19:55:29 -0400 Subject: [PATCH 24/82] Rename type-hole class to typed-hole --- grammars/purescript.cson | 2 +- src/purescript.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 807f216..25546ef 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -262,7 +262,7 @@ 'match': '\\b(derive|where|data|type|newtype|infix[lr]?|foreign)(?!\')\\b' } { - 'name': 'invalid.illegal.type-hole.purescript' + 'name': 'invalid.illegal.typed-hole.purescript' 'match': '\\?(?:[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)' } { diff --git a/src/purescript.coffee b/src/purescript.coffee index b53442a..f166881 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -239,7 +239,7 @@ purescriptGrammar = name: 'keyword.other' match: /\b(derive|where|data|type|newtype|infix[lr]?|foreign)(?!')\b/ , - name: 'invalid.illegal.type-hole' + name: 'invalid.illegal.typed-hole' match: /\?(?:{functionNameOne}|{classNameOne})/ , name: 'storage.type' From 9ddb7c84e8fc83e55c60cd1e99308a82601ee8c9 Mon Sep 17 00:00:00 2001 From: "Ian D. Bollinger" Date: Sun, 31 Jul 2016 22:36:24 -0400 Subject: [PATCH 25/82] Change invalid.illegal to entity.name.function This changes the scope for typed holes from `invalid.illegal.typed-hole` to `entity.name.function.typed-hole`. --- grammars/purescript.cson | 2 +- src/purescript.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 25546ef..00614e7 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -262,7 +262,7 @@ 'match': '\\b(derive|where|data|type|newtype|infix[lr]?|foreign)(?!\')\\b' } { - 'name': 'invalid.illegal.typed-hole.purescript' + 'name': 'entity.name.function.typed-hole.purescript' 'match': '\\?(?:[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)' } { diff --git a/src/purescript.coffee b/src/purescript.coffee index f166881..e4d292f 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -239,7 +239,7 @@ purescriptGrammar = name: 'keyword.other' match: /\b(derive|where|data|type|newtype|infix[lr]?|foreign)(?!')\b/ , - name: 'invalid.illegal.typed-hole' + name: 'entity.name.function.typed-hole' match: /\?(?:{functionNameOne}|{classNameOne})/ , name: 'storage.type' From 9481b018b46c0df5326c4708d7d2cb2f4a2b07ec Mon Sep 17 00:00:00 2001 From: "Ian D. Bollinger" Date: Tue, 2 Aug 2016 10:56:57 -0400 Subject: [PATCH 26/82] Highlight function types when split across lines This fixes #22. Additionally, this removes the unsupported Haskell syntax: ```haskell foo, bar :: Baz ``` --- grammars/purescript.cson | 57 +++++++++++++++++----------------------- src/purescript.coffee | 41 ++++++++++++----------------- 2 files changed, 41 insertions(+), 57 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 08b7763..0fa2078 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -13,7 +13,7 @@ 'operatorFun': '(?:\\((?!--+\\))[\\p{S}\\p{P}&&[^(),;\\[\\]`{}_"\']]+\\))' 'character': '(?:[ -\\[\\]-~]|(\\\\(?: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\\\\\\"\'\\&]))|(\\\\o[0-7]+)|(\\\\x[0-9A-Fa-f]+)|(\\^[A-Z@\\[\\]\\\\\\^_]))' 'classConstraint': '(?:(?:([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*)\\s+)(?:(?(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{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*)\\s+)(?:(?(?:(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*|(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|(?:(?:[\\w()\'→⇒\\[\\],]|->|=>)+\\s*)+))(?:\\s*(?:\\s+)\\s*\\g)?)?))' 'typeDecl': '.+?' @@ -91,7 +91,7 @@ } { 'name': 'meta.foreign.data.purescript' - 'begin': '^(\\s*)(foreign)\\s+(import)\\s+(data)\\s+([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*(::|∷)' + 'begin': '^(\\s*)(foreign)\\s+(import)\\s+(data)\\s+([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)' 'end': '^(?!\\1[ \\t]|[ \\t]*$)' 'contentName': 'meta.kind-signature.purescript' 'beginCaptures': @@ -106,6 +106,9 @@ '6': 'name': 'keyword.other.double-colon.purescript' 'patterns': [ + { + 'include': '#double_colon' + } { 'include': '#kind_signature' } @@ -113,7 +116,7 @@ } { 'name': 'meta.foreign.purescript' - 'begin': '^(\\s*)(foreign)\\s+(import)\\s+(?:(?:(?(?:(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)(?:\\s*(?:,)\\s*\\g)?))(?:\\s*(::|∷ )))?' + 'begin': '^(\\s*)(foreign)\\s+(import)\\s+([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)' 'end': '^(?!\\1[ \\t]|[ \\t]*$)' 'contentName': 'meta.type-signature.purescript' 'beginCaptures': @@ -122,15 +125,11 @@ '3': 'name': 'keyword.other.purescript' '4': - 'patterns': [ - { - 'name': 'entity.name.function.purescript' - 'match': '(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*' - } - ] - '5': - 'name': 'keyword.other.double-colon.purescript' + 'name': 'entity.name.function.purescript' 'patterns': [ + { + 'include': '#double_colon' + } { 'include': '#type_signature' } @@ -365,19 +364,6 @@ } ] } - { - 'match': '(::|∷)((?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*|(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|\\->|=>|[→⇒()\\[\\]]|\\s)*)' - 'captures': - '1': - 'name': 'keyword.other.double-colon.purescript' - '2': - 'name': 'meta.type-signature.purescript' - 'patterns': [ - { - 'include': '#type_signature' - } - ] - } { 'include': '#data_ctor' } @@ -541,20 +527,18 @@ 'patterns': [ { 'name': 'meta.function.type-declaration.purescript' - 'begin': '(?:(?:^(\\s*))(?:(?:(?:(?(?:(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)(?:\\s*(?:,)\\s*\\g)?))(?:\\s*(::|∷ ))))(?:(?!.*<-)))' + 'begin': '^(\\s*)([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*(?:(::|∷)(?!.*<-)|$)' 'end': '^(?!\\1[ \\t]|[ \\t]*$)' 'contentName': 'meta.type-signature.purescript' 'beginCaptures': '2': - 'patterns': [ - { - 'name': 'entity.name.function.purescript' - 'match': '(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*' - } - ] + 'name': 'entity.name.function.purescript' '3': 'name': 'keyword.other.double-colon.purescript' 'patterns': [ + { + 'include': '#double_colon' + } { 'include': '#type_signature' } @@ -565,8 +549,8 @@ 'patterns': [ { 'name': 'meta.record-field.type-declaration.purescript' - 'begin': '(?:(?:(?(?:(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)(?:\\s*(?:,)\\s*\\g)?))(?:\\s*(::|∷ )))' - 'end': '(?=(?:(?:(?(?:(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)(?:\\s*(?:,)\\s*\\g)?))(?:\\s*(::|∷ )))|})' + 'begin': '([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*(::|∷)' + 'end': '(?=([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*(::|∷)|})' 'contentName': 'meta.type-signature.purescript' 'beginCaptures': '1': @@ -679,6 +663,13 @@ 'match': '\\b(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*' } ] + 'double_colon': + 'patterns': [ + { + 'name': 'keyword.other.double-colon.purescript' + 'match': '(?:::|∷)' + } + ] 'class_constraint': 'patterns': [ { diff --git a/src/purescript.coffee b/src/purescript.coffee index 116129a..471c78e 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -60,8 +60,7 @@ purescriptGrammar = classConstraint: concat /({className})\s+/, list('classConstraint',/{className}|{functionName}/,/\s+/) functionTypeDeclaration: - concat list('functionTypeDeclaration',/{functionName}/,/,/), - /\s*(::|∷ )/ + /({functionNameOne})\s*(::|∷)/ ctorArgs: /// (?: {className} #proper type @@ -130,7 +129,7 @@ purescriptGrammar = ] , name: 'meta.foreign.data' - begin: /^(\s*)(foreign)\s+(import)\s+(data)\s+({classNameOne})\s*(::|∷)/ + begin: /^(\s*)(foreign)\s+(import)\s+(data)\s+({classNameOne})/ end: /{indentBlockEnd}/ contentName: 'meta.kind-signature' beginCaptures: @@ -139,25 +138,23 @@ purescriptGrammar = 4: name: 'keyword.other' 5: name: 'entity.name.type' 6: name: 'keyword.other.double-colon' - patterns:[ + patterns: [ + include: '#double_colon' + , include: '#kind_signature' ] , name: 'meta.foreign' - # functionTypeDeclaration so it can be wrapped to the next line without losing most highlighting - begin: /^(\s*)(foreign)\s+(import)\s+{functionTypeDeclaration}?/ + begin: /^(\s*)(foreign)\s+(import)\s+({functionNameOne})/ end: /{indentBlockEnd}/ contentName: 'meta.type-signature' beginCaptures: 2: name: 'keyword.other' 3: name: 'keyword.other' - 4: - patterns: [ - name: 'entity.name.function' - match: /{functionName}/ - ] - 5: name: 'keyword.other.double-colon' - patterns:[ + 4: name: 'entity.name.function' + patterns: [ + include: '#double_colon' + , include: '#type_signature' ] , @@ -307,11 +304,6 @@ purescriptGrammar = 1: patterns: [include: '$self'] 2: name: 'keyword.other.double-colon' 3: {name: 'meta.type-signature', patterns: [include: '#type_signature']} - , - match: '(::|∷)((?:{className}|{functionName}|\\->|=>|[→⇒()\\[\\]]|\\s)*)' - captures: - 1: name: 'keyword.other.double-colon' - 2: {name: 'meta.type-signature', patterns: [include: '#type_signature']} , include: '#data_ctor' , @@ -422,17 +414,15 @@ purescriptGrammar = match: /(?:{className}\.)*{className}\.?/ function_type_declaration: name: 'meta.function.type-declaration' - begin: concat /{maybeBirdTrack}(\s*)/,/{functionTypeDeclaration}/,/(?!.*<-)/ + begin: /^(\s*)({functionNameOne})\s*(?:(::|∷)(?!.*<-)|$)/ end: /{indentBlockEnd}/ contentName: 'meta.type-signature' beginCaptures: - 2: - patterns: [ - name: 'entity.name.function' - match: /{functionName}/ - ] + 2: name: 'entity.name.function' 3: name: 'keyword.other.double-colon' patterns: [ + include: '#double_colon' + , include: '#type_signature' ] record_field_declaration: @@ -509,6 +499,9 @@ purescriptGrammar = generic_type: name: 'variable.other.generic-type' match: /\b{functionName}/ + double_colon: + name: 'keyword.other.double-colon' + match: ///(?: :: | ∷ )/// class_constraint: name: 'meta.class-constraint' match: /{classConstraint}/ From 70b22a23bd83830fa192a94e6fb60e1b2c09de6a Mon Sep 17 00:00:00 2001 From: "Ian D. Bollinger" Date: Tue, 2 Aug 2016 14:32:15 -0400 Subject: [PATCH 27/82] Only highlight type signatures split across lines This will properly highlight type signatures that are split across lines. The function name will not be highlighted, however, if the double-colon (`::`) is not on the same line. There doesn't seem to be a way to fix this that I can think of. Foreign imports can still, however, be split over multiple lines. --- grammars/purescript.cson | 14 +++++++++++++- src/purescript.coffee | 23 ++++++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 0fa2078..f647a54 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -364,6 +364,18 @@ } ] } + { + 'begin': '^(\\s*)(?:(::|∷))' + 'beginCaptures': + '2': + 'name': 'keyword.other.double-colon.purescript' + 'end': '^(?!\\1[ \\t]*|[ \\t]*$)' + 'patterns': [ + { + 'include': '#type_signature' + } + ] + } { 'include': '#data_ctor' } @@ -527,7 +539,7 @@ 'patterns': [ { 'name': 'meta.function.type-declaration.purescript' - 'begin': '^(\\s*)([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*(?:(::|∷)(?!.*<-)|$)' + 'begin': '^(\\s*)([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*(?:(::|∷)(?!.*<-))' 'end': '^(?!\\1[ \\t]|[ \\t]*$)' 'contentName': 'meta.type-signature.purescript' 'beginCaptures': diff --git a/src/purescript.coffee b/src/purescript.coffee index 471c78e..4e4e638 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -304,6 +304,21 @@ purescriptGrammar = 1: patterns: [include: '$self'] 2: name: 'keyword.other.double-colon' 3: {name: 'meta.type-signature', patterns: [include: '#type_signature']} + , + begin: /// + ^ + ( \s* ) + (?: ( :: | ∷ ) ) + /// + beginCaptures: + 2: name: 'keyword.other.double-colon' + end: /// + ^ + (?! \1 {indentChar}* | {indentChar}* $ ) + /// + patterns: [ + include: '#type_signature' + ] , include: '#data_ctor' , @@ -414,7 +429,13 @@ purescriptGrammar = match: /(?:{className}\.)*{className}\.?/ function_type_declaration: name: 'meta.function.type-declaration' - begin: /^(\s*)({functionNameOne})\s*(?:(::|∷)(?!.*<-)|$)/ + begin: /// + ^ + ( \s* ) + ( {functionNameOne} ) + \s* + (?: ( :: | ∷ ) (?! .* <- ) ) + /// end: /{indentBlockEnd}/ contentName: 'meta.type-signature' beginCaptures: From fc8b0bf9da61886c6e3973c2d37e6aef88fabfb2 Mon Sep 17 00:00:00 2001 From: Nicholas Wolverson Date: Mon, 8 Aug 2016 22:39:31 +0100 Subject: [PATCH 28/82] Prepare 0.8.1 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 170965a..4687912 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-purescript", - "version": "0.8.0", + "version": "0.8.1", "description": "PureScript language support for the Atom editor", "license": "MIT", "repository": "https://github.com/darinmorrison/atom-language-purescript", From 7bcb3d2fb42256b79b97ef241a97110313a03357 Mon Sep 17 00:00:00 2001 From: Nicholas Wolverson Date: Mon, 17 Oct 2016 21:54:47 +0100 Subject: [PATCH 29/82] Add do snippet. Fix #36. --- snippets/language-purescript.cson | 3 +++ 1 file changed, 3 insertions(+) diff --git a/snippets/language-purescript.cson b/snippets/language-purescript.cson index c49531e..52979ce 100644 --- a/snippets/language-purescript.cson +++ b/snippets/language-purescript.cson @@ -11,6 +11,9 @@ 'Derive': 'prefix': 'derive' 'body': 'derive instance ${1:name} :: ${2:Class} ${3:Type}' + 'Do': + 'prefix': 'do' + 'body': 'do\n ' 'Forall': 'prefix': 'forall' 'body': 'forall ${1:a}.' From c590de5bcb7c5e13d227840074d295e5d7fb0dd4 Mon Sep 17 00:00:00 2001 From: Nicholas Wolverson Date: Mon, 17 Oct 2016 21:55:09 +0100 Subject: [PATCH 30/82] Prepare 0.8.2 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4687912..b4de90a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-purescript", - "version": "0.8.1", + "version": "0.8.2", "description": "PureScript language support for the Atom editor", "license": "MIT", "repository": "https://github.com/darinmorrison/atom-language-purescript", From 955b632dcbc6f647b29f717242775f48ff1ef829 Mon Sep 17 00:00:00 2001 From: MiracleBlue Date: Sun, 24 Sep 2017 23:09:28 +1000 Subject: [PATCH 31/82] Fixed nested record type definitions in data types, as well as record types in type aliases. Fixes #39 --- grammars/purescript.cson | 57 +++++++++++++++++++++++++--------------- src/purescript.coffee | 42 ++++++++++++++++++----------- 2 files changed, 63 insertions(+), 36 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index eb76044..64def67 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -205,24 +205,7 @@ 'name': 'punctuation.separator.pipe.purescript' } { - 'name': 'meta.declaratyion.type.data.record.block.purescript' - 'begin': '\\{' - 'beginCaptures': - '0': - 'name': 'keyword.operator.record.begin.purescript' - 'end': '\\}' - 'endCaptures': - '0': - 'name': 'keyword.operator.record.end.purescript' - 'patterns': [ - { - 'name': 'punctuation.separator.comma.purescript' - 'match': ',' - } - { - 'include': '#record_field_declaration' - } - ] + 'include': '#record_types' } ] } @@ -242,9 +225,6 @@ } ] 'patterns': [ - { - 'include': '#comments' - } { 'match': '=' 'captures': @@ -254,6 +234,12 @@ { 'include': '#type_signature' } + { + 'include': '#record_types' + } + { + 'include': '#comments' + } ] } { @@ -437,6 +423,32 @@ ] } ] + 'record_types': + 'patterns': [ + { + 'name': 'meta.type.record.purescript' + 'begin': '\\{' + 'beginCaptures': + '0': + 'name': 'keyword.operator.type.record.begin.purescript' + 'end': '\\}' + 'endCaptures': + '0': + 'name': 'keyword.operator.type.record.end.purescript' + 'patterns': [ + { + 'name': 'punctuation.separator.comma.purescript' + 'match': ',' + } + { + 'include': '#record_field_declaration' + } + { + 'include': '#comments' + } + ] + } + ] 'comments': 'patterns': [ { @@ -582,6 +594,9 @@ { 'include': '#type_signature' } + { + 'include': '#record_types' + } ] } ] diff --git a/src/purescript.coffee b/src/purescript.coffee index 8755b84..44638eb 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -199,19 +199,7 @@ purescriptGrammar = captures: 0: name: 'punctuation.separator.pipe' , - name: 'meta.declaratyion.type.data.record.block' - begin: /\{/ - beginCaptures: - 0: name: 'keyword.operator.record.begin' - end: /\}/ - endCaptures: - 0: name: 'keyword.operator.record.end' - patterns: [ - name: 'punctuation.separator.comma' - match: /,/ - , - include: '#record_field_declaration' - ] + include: '#record_types' ] , name: 'meta.declaration.type.type' @@ -224,13 +212,15 @@ purescriptGrammar = name: 'meta.type-signature' patterns: [include: '#type_signature'] patterns: [ - include: '#comments' - , match: /=/ captures: 0: name: 'keyword.operator.assignment' , include: '#type_signature' + , + include: '#record_types' + , + include: '#comments' ] , name: 'keyword.other' @@ -363,6 +353,26 @@ purescriptGrammar = include: '#block_comment' ] ] + record_types: + patterns: [ + name: 'meta.type.record' + begin: '\\{' + beginCaptures: + 0: + name: 'keyword.operator.type.record.begin.purescript' + end: '\\}' + endCaptures: + 0: + name: 'keyword.operator.type.record.end.purescript' + patterns: [ + name: 'punctuation.separator.comma.purescript' + match: ',' + , + include: '#record_field_declaration' + , + include: '#comments' + ] + ] comments: patterns: [ begin: /({maybeBirdTrack}[ \t]+)?(?=--+\s+\|)/ @@ -463,6 +473,8 @@ purescriptGrammar = 2: name: 'keyword.other.double-colon' patterns: [ include: '#type_signature' + , + include: '#record_types' ] kind_signature: patterns: [ From a2c84f5cf2a79b6253da8632ef8e9982295079d7 Mon Sep 17 00:00:00 2001 From: Nicholas Wolverson Date: Sun, 24 Sep 2017 15:40:22 +0100 Subject: [PATCH 32/82] Update README --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6e68da5..3715e01 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,17 @@ # PureScript language support in Atom -Adds syntax highlighting to [PureScript](http://www.purescript.org) files in Atom. +Adds syntax highlighting to [PureScript](http://www.purescript.org) files in Atom. This grammar is also used indirectly by +GitHub highlighting via [linguist](https://github.com/github/linguist), and [VS Code](https://github.com/nwolverson/vscode-language-purescript). Contributions are greatly appreciated. Please fork this repository and open a pull request to add snippets, make grammar tweaks, etc. + +## Development + +The language-purescript grammar derives originally from the language-haskell grammar, with changes to accommodate the +PureScript language and the subsequent language changes. + +The grammar used by Atom is [grammars/purescript.cson](grammars/purescript.cson), but this is **generated** from +[src/purescript.coffee](src/purescript.coffee), this can be regenerated via `npm run build`. + +The grammar is picked up by [regular linguist updates](https://github.com/github/linguist#theres-a-problem-with-the-syntax-highlighting-of-a-file), and via a `build` script in +[vscode-language-purescript](https://github.com/nwolverson/vscode-language-purescript). \ No newline at end of file From 9d7e24f2f1ddeae9aa953c7d34ca567c0b1622af Mon Sep 17 00:00:00 2001 From: Nicholas Wolverson Date: Sun, 24 Sep 2017 15:47:53 +0100 Subject: [PATCH 33/82] Prepare 0.8.3 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b4de90a..e15fdad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-purescript", - "version": "0.8.2", + "version": "0.8.3", "description": "PureScript language support for the Atom editor", "license": "MIT", "repository": "https://github.com/darinmorrison/atom-language-purescript", From fa8e4c98b6617eeab370fa9a114b7a5874cf235d Mon Sep 17 00:00:00 2001 From: Colbyn Wadman Date: Tue, 29 May 2018 14:18:57 -0600 Subject: [PATCH 34/82] Updated settings file to automatically indent cursor via given regex pattern. --- settings/language-purescript.cson | 1 + 1 file changed, 1 insertion(+) diff --git a/settings/language-purescript.cson b/settings/language-purescript.cson index 96bf077..7009469 100644 --- a/settings/language-purescript.cson +++ b/settings/language-purescript.cson @@ -2,3 +2,4 @@ 'editor': 'autoIndentOnPaste': false 'commentStart': '-- ' + 'increaseIndentPattern': '(((=|\\bdo|\\bwhere|\\bthen|\\belse|\\bof)\\s*)|(\\bif(?!.*\\bthen\\b.*\\belse\\b.*).*))$' From 80d3c37a4ee86abe6a5c4e195714dc091a26c161 Mon Sep 17 00:00:00 2001 From: Nicholas Wolverson Date: Wed, 18 Jul 2018 10:27:21 +0100 Subject: [PATCH 35/82] Update CONTRIBUTING.md --- CONTRIBUTING.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0fd0ad6..4a44ddc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1 +1,7 @@ -See the [Atom contributing guide](https://github.com/atom/atom/blob/master/CONTRIBUTING.md) +This repository contains generated code. + +If you are about to make a change to the language grammar: + +* Do **NOT** edit `grammars/purescript.cson` directly, this will be overwritten + +* Edit `src/purescript.coffee` and regenerate via `npm run build` From cc2cb471968eb331af7259aac219feb3017d709e Mon Sep 17 00:00:00 2001 From: Tim Steenvoorden Date: Tue, 11 Sep 2018 13:44:23 +0200 Subject: [PATCH 36/82] add `ado` keyword for applicative do notation --- grammars/purescript.cson | 2 +- src/purescript.coffee | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 64def67..1dd9fe7 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -256,7 +256,7 @@ } { 'name': 'keyword.control.purescript' - 'match': '\\b(do|if|then|else|case|of|let|in)(?!\')\\b' + 'match': '\\b(do|ado|if|then|else|case|of|let|in)(?!\')\\b' } { 'name': 'constant.numeric.float.purescript' diff --git a/src/purescript.coffee b/src/purescript.coffee index 44638eb..6c82c9d 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -233,7 +233,7 @@ purescriptGrammar = match: /\b(data|type|newtype)(?!')\b/ , name: 'keyword.control' - match: /\b(do|if|then|else|case|of|let|in)(?!')\b/ + match: /\b(do|ado|if|then|else|case|of|let|in)(?!')\b/ , name: 'constant.numeric.float' match: /\b([0-9]+\.[0-9]+([eE][+-]?[0-9]+)?|[0-9]+[eE][+-]?[0-9]+)\b/ @@ -367,7 +367,7 @@ purescriptGrammar = patterns: [ name: 'punctuation.separator.comma.purescript' match: ',' - , + , include: '#record_field_declaration' , include: '#comments' From 96f81f5f673c0cf7f6c1314db8a96553bfde34cf Mon Sep 17 00:00:00 2001 From: Nicholas Wolverson Date: Wed, 19 Sep 2018 09:14:04 +0100 Subject: [PATCH 37/82] Add ado snippet --- snippets/language-purescript.cson | 3 +++ 1 file changed, 3 insertions(+) diff --git a/snippets/language-purescript.cson b/snippets/language-purescript.cson index 52979ce..c12f6ba 100644 --- a/snippets/language-purescript.cson +++ b/snippets/language-purescript.cson @@ -1,4 +1,7 @@ '.source.purescript': + 'ADo': + 'prefix': 'ado' + 'body': 'ado\n ' 'Case': 'prefix': 'case' 'body': 'case ${1:expression} of\n ${2:pattern} -> ${3:expression}' From 32c8c1a3e230df0280b1a10868e3ecce6b0a58f4 Mon Sep 17 00:00:00 2001 From: Nicholas Wolverson Date: Wed, 19 Sep 2018 09:14:47 +0100 Subject: [PATCH 38/82] Add 'else instance' syntax, fix #43 --- grammars/purescript.cson | 4 +++- src/purescript.coffee | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 1dd9fe7..dc237be 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -74,12 +74,14 @@ } { 'name': 'meta.declaration.instance.purescript' - 'begin': '\\b(instance)(?!\')\\b' + 'begin': '\\b(else\\s+)?(instance)(?!\')\\b' 'end': '\\b(where)\\b|$' 'contentName': 'meta.type-signature.purescript' 'beginCaptures': '1': 'name': 'keyword.other.purescript' + '2': + 'name': 'keyword.other.purescript' 'endCaptures': '1': 'name': 'keyword.other.purescript' diff --git a/src/purescript.coffee b/src/purescript.coffee index 6c82c9d..82f3317 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -117,11 +117,12 @@ purescriptGrammar = ] , name: 'meta.declaration.instance' - begin: /\b(instance)(?!')\b/ + begin: /\b(else\s+)?(instance)(?!')\b/ end: /\b(where)\b|$/ contentName: 'meta.type-signature' beginCaptures: 1: name: 'keyword.other' + 2: name: 'keyword.other' endCaptures: 1: name: 'keyword.other' patterns: [ From 63c87c87fb6225a75c462875e339bf5655ccdab4 Mon Sep 17 00:00:00 2001 From: Nicholas Wolverson Date: Wed, 19 Sep 2018 09:31:56 +0100 Subject: [PATCH 39/82] 0.9.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e15fdad..0dfe6b7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-purescript", - "version": "0.8.3", + "version": "0.9.0", "description": "PureScript language support for the Atom editor", "license": "MIT", "repository": "https://github.com/darinmorrison/atom-language-purescript", From fd4a42811b3c9d32f78e82319bc2609d75087300 Mon Sep 17 00:00:00 2001 From: Carsten Csiky Date: Wed, 31 Jul 2019 00:00:43 +0200 Subject: [PATCH 40/82] Fix Syntax-Highlighting for `_` in Numbers Purescript has added, that numeric literals can contain `_`, which the syntax highlighting did not pickup --- grammars/purescript.cson | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index dc237be..c3296a7 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -262,7 +262,7 @@ } { 'name': 'constant.numeric.float.purescript' - 'match': '\\b([0-9]+\\.[0-9]+([eE][+-]?[0-9]+)?|[0-9]+[eE][+-]?[0-9]+)\\b' + 'match': '\\b(([0-9]+_?)+[0-9]+\\.[0-9]+([eE][+-]?[0-9]+)?|[0-9]+[eE][+-]?[0-9]+)\\b' } { 'name': 'constant.language.boolean.purescript' @@ -270,7 +270,7 @@ } { 'name': 'constant.numeric.purescript' - 'match': '\\b([0-9]+|0([xX][0-9a-fA-F]+|[oO][0-7]+))\\b' + 'match': '\\b(([0-9]+_?)+[0-9]+|0([xX][0-9a-fA-F]+|[oO][0-7]+))\\b' } { 'name': 'string.quoted.triple.purescript' @@ -726,4 +726,4 @@ } ] } - ] \ No newline at end of file + ] From 40485a26485b9fd29f045d9c43a4233a201f9173 Mon Sep 17 00:00:00 2001 From: "Carsten Csiky (csicar)" Date: Wed, 31 Jul 2019 11:18:10 +0200 Subject: [PATCH 41/82] move numeric literals changes to cs file & generate --- grammars/purescript.cson | 6 +++--- src/purescript.coffee | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index c3296a7..f72b151 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -262,7 +262,7 @@ } { 'name': 'constant.numeric.float.purescript' - 'match': '\\b(([0-9]+_?)+[0-9]+\\.[0-9]+([eE][+-]?[0-9]+)?|[0-9]+[eE][+-]?[0-9]+)\\b' + 'match': '\\b((([0-9]+_?)+[0-9]+|[0-9]+)\\.[0-9]+([eE][+-]?[0-9]+)?|[0-9]+[eE][+-]?[0-9]+)\\b' } { 'name': 'constant.language.boolean.purescript' @@ -270,7 +270,7 @@ } { 'name': 'constant.numeric.purescript' - 'match': '\\b(([0-9]+_?)+[0-9]+|0([xX][0-9a-fA-F]+|[oO][0-7]+))\\b' + 'match': '\\b(([0-9]+_?)+[0-9]+|[0-9]+|0([xX][0-9a-fA-F]+|[oO][0-7]+))\\b' } { 'name': 'string.quoted.triple.purescript' @@ -726,4 +726,4 @@ } ] } - ] + ] \ No newline at end of file diff --git a/src/purescript.coffee b/src/purescript.coffee index 82f3317..107242a 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -237,14 +237,14 @@ purescriptGrammar = match: /\b(do|ado|if|then|else|case|of|let|in)(?!')\b/ , name: 'constant.numeric.float' - match: /\b([0-9]+\.[0-9]+([eE][+-]?[0-9]+)?|[0-9]+[eE][+-]?[0-9]+)\b/ + match: /\b((([0-9]+_?)+[0-9]+|[0-9]+)\.[0-9]+([eE][+-]?[0-9]+)?|[0-9]+[eE][+-]?[0-9]+)\b/ # Floats are always decimal , name: 'constant.language.boolean' match: /\b(true|false)\b/ , name: 'constant.numeric' - match: /\b([0-9]+|0([xX][0-9a-fA-F]+|[oO][0-7]+))\b/ + match: /\b(([0-9]+_?)+[0-9]+|[0-9]+|0([xX][0-9a-fA-F]+|[oO][0-7]+))\b/ , name: 'string.quoted.triple' begin: /"""/ From 635394feb44d7b7dd2159767cbeb91a4a81082bf Mon Sep 17 00:00:00 2001 From: "Carsten Csiky (csicar)" Date: Thu, 1 Aug 2019 01:37:23 +0200 Subject: [PATCH 42/82] simplify regex --- grammars/purescript.cson | 4 ++-- src/purescript.coffee | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index f72b151..1de5aa5 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -262,7 +262,7 @@ } { 'name': 'constant.numeric.float.purescript' - 'match': '\\b((([0-9]+_?)+[0-9]+|[0-9]+)\\.[0-9]+([eE][+-]?[0-9]+)?|[0-9]+[eE][+-]?[0-9]+)\\b' + 'match': '\\b(([0-9]+_?)*[0-9]+\\.[0-9]+([eE][+-]?[0-9]+)?|[0-9]+[eE][+-]?[0-9]+)\\b' } { 'name': 'constant.language.boolean.purescript' @@ -270,7 +270,7 @@ } { 'name': 'constant.numeric.purescript' - 'match': '\\b(([0-9]+_?)+[0-9]+|[0-9]+|0([xX][0-9a-fA-F]+|[oO][0-7]+))\\b' + 'match': '\\b(([0-9]+_?)*[0-9]+|0([xX][0-9a-fA-F]+|[oO][0-7]+))\\b' } { 'name': 'string.quoted.triple.purescript' diff --git a/src/purescript.coffee b/src/purescript.coffee index 107242a..bc30165 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -237,14 +237,14 @@ purescriptGrammar = match: /\b(do|ado|if|then|else|case|of|let|in)(?!')\b/ , name: 'constant.numeric.float' - match: /\b((([0-9]+_?)+[0-9]+|[0-9]+)\.[0-9]+([eE][+-]?[0-9]+)?|[0-9]+[eE][+-]?[0-9]+)\b/ + match: /\b(([0-9]+_?)*[0-9]+\.[0-9]+([eE][+-]?[0-9]+)?|[0-9]+[eE][+-]?[0-9]+)\b/ # Floats are always decimal , name: 'constant.language.boolean' match: /\b(true|false)\b/ , name: 'constant.numeric' - match: /\b(([0-9]+_?)+[0-9]+|[0-9]+|0([xX][0-9a-fA-F]+|[oO][0-7]+))\b/ + match: /\b(([0-9]+_?)*[0-9]+|0([xX][0-9a-fA-F]+|[oO][0-7]+))\b/ , name: 'string.quoted.triple' begin: /"""/ From 44f8d5962b1cb43e29f614e854737e6b9255c7ad Mon Sep 17 00:00:00 2001 From: Nicholas Wolverson Date: Sun, 8 Sep 2019 10:14:00 +0100 Subject: [PATCH 43/82] Prepare 0.9.1 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0dfe6b7..d8f7adc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-purescript", - "version": "0.9.0", + "version": "0.9.1", "description": "PureScript language support for the Atom editor", "license": "MIT", "repository": "https://github.com/darinmorrison/atom-language-purescript", From d0f78c3e842fd71646f29df795c188351281e21c Mon Sep 17 00:00:00 2001 From: Nicholas Wolverson Date: Sun, 8 Sep 2019 10:18:16 +0100 Subject: [PATCH 44/82] Prepare 0.9.2 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d8f7adc..60dbbae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-purescript", - "version": "0.9.1", + "version": "0.9.2", "description": "PureScript language support for the Atom editor", "license": "MIT", "repository": "https://github.com/darinmorrison/atom-language-purescript", From 7a1d46e841efab0d322ab2864d4cf3b105099541 Mon Sep 17 00:00:00 2001 From: Nicholas Wolverson Date: Sun, 8 Sep 2019 10:19:09 +0100 Subject: [PATCH 45/82] Prepare 0.9.3 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 60dbbae..225ebb2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-purescript", - "version": "0.9.2", + "version": "0.9.3", "description": "PureScript language support for the Atom editor", "license": "MIT", "repository": "https://github.com/darinmorrison/atom-language-purescript", From 411b916442b2997f38db23cc1420278cb99c2e48 Mon Sep 17 00:00:00 2001 From: Nicholas Wolverson Date: Sun, 26 Apr 2020 13:01:18 +0100 Subject: [PATCH 46/82] Update numeric regexes for slowness issue - https://github.com/nwolverson/vscode-language-purescript/issues/13 --- grammars/purescript.cson | 23 +++++++++++++++++++++-- src/purescript.coffee | 29 ++++++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 1de5aa5..4a4d5c0 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -261,8 +261,27 @@ 'match': '\\b(do|ado|if|then|else|case|of|let|in)(?!\')\\b' } { - 'name': 'constant.numeric.float.purescript' - 'match': '\\b(([0-9]+_?)*[0-9]+\\.[0-9]+([eE][+-]?[0-9]+)?|[0-9]+[eE][+-]?[0-9]+)\\b' + 'name': 'constant.numeric.hex.purescript' + 'match': '\\b(? Date: Sun, 26 Apr 2020 13:03:03 +0100 Subject: [PATCH 47/82] Prepare 0.9.4 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 225ebb2..9243915 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-purescript", - "version": "0.9.3", + "version": "0.9.4", "description": "PureScript language support for the Atom editor", "license": "MIT", "repository": "https://github.com/darinmorrison/atom-language-purescript", From ce7654bd033478e8b8a78e325a38300f24ca5a28 Mon Sep 17 00:00:00 2001 From: Nicholas Wolverson Date: Sun, 26 Apr 2020 13:47:03 +0100 Subject: [PATCH 48/82] Fix decimal regex a bit --- grammars/purescript.cson | 2 +- src/purescript.coffee | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 4a4d5c0..18b3dfe 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -266,7 +266,7 @@ } { 'name': 'constant.numeric.decimal.purescript' - 'match': '(?x)\n(? Date: Sun, 26 Apr 2020 13:47:15 +0100 Subject: [PATCH 49/82] Prepare 0.9.5 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9243915..d19bf8f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-purescript", - "version": "0.9.4", + "version": "0.9.5", "description": "PureScript language support for the Atom editor", "license": "MIT", "repository": "https://github.com/darinmorrison/atom-language-purescript", From 8b1cc919f51ea414ff8c5beb2cd048f390192457 Mon Sep 17 00:00:00 2001 From: wclr Date: Sat, 1 May 2021 16:39:42 +0500 Subject: [PATCH 50/82] update grammars add ^\s* to basic keywrords --- grammars/purescript.cson | 16 +++++++++------- src/purescript.coffee | 22 +++++++++++++--------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 18b3dfe..c40f689 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -32,7 +32,7 @@ } { 'name': 'meta.declaration.module.purescript' - 'begin': '\\b(module)(?!\')\\b' + 'begin': '^\\s*\\b(module)(?!\')\\b' 'end': '(where)' 'beginCaptures': '1': @@ -58,7 +58,7 @@ } { 'name': 'meta.declaration.typeclass.purescript' - 'begin': '\\b(class)(?!\')\\b' + 'begin': '^\\s*\\b(class)(?!\')\\b' 'end': '\\b(where)\\b|$' 'beginCaptures': '1': @@ -74,7 +74,7 @@ } { 'name': 'meta.declaration.instance.purescript' - 'begin': '\\b(else\\s+)?(instance)(?!\')\\b' + 'begin': '^\\s*\\b(else\\s+)?(derive\\s+)?(instance)(?!\')\\b' 'end': '\\b(where)\\b|$' 'contentName': 'meta.type-signature.purescript' 'beginCaptures': @@ -82,6 +82,8 @@ 'name': 'keyword.other.purescript' '2': 'name': 'keyword.other.purescript' + '3': + 'name': 'keyword.other.purescript' 'endCaptures': '1': 'name': 'keyword.other.purescript' @@ -139,7 +141,7 @@ } { 'name': 'meta.import.purescript' - 'begin': '\\b(import)(?!\')\\b' + 'begin': '^\\s*\\b(import)(?!\')\\b' 'end': '($|(?=--))' 'beginCaptures': '1': @@ -246,7 +248,7 @@ } { 'name': 'keyword.other.purescript' - 'match': '\\b(derive|where|data|type|newtype|infix[lr]?|foreign)(?!\')\\b' + 'match': '^\\s*\\b(derive|where|data|type|newtype|infix[lr]?|foreign(\\s+import)?(\\s+data)?)(?!\')\\b' } { 'name': 'entity.name.function.typed-hole.purescript' @@ -254,11 +256,11 @@ } { 'name': 'storage.type.purescript' - 'match': '\\b(data|type|newtype)(?!\')\\b' + 'match': '^\\s*\\b(data|type|newtype)(?!\')\\b' } { 'name': 'keyword.control.purescript' - 'match': '\\b(do|ado|if|then|else|case|of|let|in)(?!\')\\b' + 'match': '\\b(do|ado|if|then|else|case|of|let|in)(?!(\'|\\s*(:|=)))\\b' } { 'name': 'constant.numeric.hex.purescript' diff --git a/src/purescript.coffee b/src/purescript.coffee index a95c928..0547a77 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -88,7 +88,7 @@ purescriptGrammar = ### , name: 'meta.declaration.module' - begin: /\b(module)(?!')\b/ + begin: /^\s*\b(module)(?!')\b/ end: /(where)/ beginCaptures: 1: name: 'keyword.other' @@ -106,7 +106,7 @@ purescriptGrammar = ] , name: 'meta.declaration.typeclass' - begin: /\b(class)(?!')\b/ + begin: /^\s*\b(class)(?!')\b/ end: /\b(where)\b|$/ beginCaptures: 1: name: 'storage.type.class' @@ -116,13 +116,14 @@ purescriptGrammar = include: '#type_signature' ] , - name: 'meta.declaration.instance' - begin: /\b(else\s+)?(instance)(?!')\b/ + name: 'meta.declaration.instance' + begin: /^\s*\b(else\s+)?(derive\s+)?(instance)(?!')\b/ end: /\b(where)\b|$/ contentName: 'meta.type-signature' beginCaptures: 1: name: 'keyword.other' 2: name: 'keyword.other' + 3: name: 'keyword.other' endCaptures: 1: name: 'keyword.other' patterns: [ @@ -160,7 +161,7 @@ purescriptGrammar = ] , name: 'meta.import' - begin: /\b(import)(?!')\b/ + begin: /^\s*\b(import)(?!')\b/ end: /($|(?=--))/ beginCaptures: 1: name: 'keyword.other' @@ -224,17 +225,20 @@ purescriptGrammar = include: '#comments' ] , - name: 'keyword.other' - match: /\b(derive|where|data|type|newtype|infix[lr]?|foreign)(?!')\b/ + name: 'keyword.other' + match: /^\s*\b(derive|where|data|type|newtype|infix[lr]?|foreign(\s+import)?(\s+data)?)(?!')\b/ , name: 'entity.name.function.typed-hole' match: /\?(?:{functionNameOne}|{classNameOne})/ , name: 'storage.type' - match: /\b(data|type|newtype)(?!')\b/ + match: /^\s*\b(data|type|newtype)(?!')\b/ , name: 'keyword.control' - match: /\b(do|ado|if|then|else|case|of|let|in)(?!')\b/ + # match only if a keyword is not followed by: + # ' - names with prime symbol + # `:` or `=` - records define/update + match: /\b(do|ado|if|then|else|case|of|let|in)(?!('|\s*(:|=)))\b/ , name: 'constant.numeric.hex.purescript', match: '\\b(? Date: Sat, 1 May 2021 16:39:56 +0500 Subject: [PATCH 51/82] Add test purs file --- test/Main.purs | 218 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 218 insertions(+) create mode 100644 test/Main.purs diff --git a/test/Main.purs b/test/Main.purs new file mode 100644 index 0000000..391e249 --- /dev/null +++ b/test/Main.purs @@ -0,0 +1,218 @@ +{- Test file to visually assess syntax highlighting. -} +module Main.App where +module Main.App + ( main + ) where + + +import Prelude + +import Data.String as String +import Data.String (Pattern) +import Data.String (Pattern(..), split) + + +-- Foreign import +foreign +foreign import +foreign import data +foreign import calculateInterest :: Number -> Number +foreign import data F :: Type + + +-- Containers + + +data D a = D1 a | D2 String + + +type T = { a :: String } +type T a = { n :: N a, b :: String } + + +newtype N a = N a + + +-- infix -- TODO: as + + +infixr 0 apply as <| +infixl 0 applyFlipped as |> + + +-- Type class + + +class Functor v <= Mountable vnode where + mount :: ∀ m. Element -> T Void (v m) + unmount :: ∀ m. v m -> v m -> T Void E + + +derive instance newtypeMySub :: Newtype (MySub vnode msg) _ + + +derive instance genericCmd :: Generic PhonerCmd _ +instance encodeCmd :: EncodeJson PhonerCmd where + encodeJson a = genericEncodeJson a + + +instance functorA :: Functor A where + map = split + + +instance functorA :: Functor A where + map = split + + +-- chained instances + + +class MyShow a where + myShow :: a -> String + + +instance showString :: MyShow String where + myShow s = s + + +else instance showBoolean :: MyShow Boolean where + myShow true = "true" + myShow false = "false" +else instance showA :: MyShow a where + myShow _ = "Invalid" + + +-- Records with fields that are reserved words + + +type Rec = + { module :: String + , import :: String + , data :: String + , newtype :: String + } + + +-- https://github.com/purescript/purescript-in-purescript/blob/master/src/Language/PureScript/Keywords.purs +rec = + { data: "data" + , type: "type" + , foreign: "foreign" + , import: "import" + , infixl: "infixl" + , infixr: "infixr" + , infix: "infix" + , class: "class" + , instance: "instance" + , case: case some of _ -> 1 + , of: "of" + , if: "if" + , then: "then" + , else: "else" + , do: "do" + , let: "let" + -- no big reason to strive to make true/false not highlighted here + , true: "true" + , false: "false" + , in: "in" + , where: "where" + , forall: "forall" + , module: "module" + } + + +updateRec = rec + { data = "data" + , type ="type" + , foreign = "foreign" + , import = "import" + , infixl = "infixl" + , infixr = "infixr" + , infix = "infix" + , class = "class" + , instance = "instance" + , case = case some of _ -> 1 + , of = "of" + , if = if true then "true" else "false" + , then = "then" + , else = "else" + , do = "do" + , let = "let" + , true = true + , false = false + , in = "in" + , where = "where" + , forall = "forall" + , module = "module" + } + + +-- quoted row type +type QuotedRow = + ( "A" :: Int + , "B" :: Number + ) + +-- quoted record type +type Quoted = + { "A" :: Int + , "B" :: Number + } + + +-- quoted row type +quoted = + { "A": "a" + , "B": 1 + } + + +-- Function, forall + + +-- do, where +toStr :: forall a. a -> Effect Unit +toStr x = do + log $ show num + log $ show str + where + num = 1 + str = "Str" + + +addIf true = singleton +addIf false = const [] + + +-- let in, case of +fn + :: forall a. a -> String +fn a = + let b = "str" + in case a of + "1" -> b + "1" + _ -> b + a + + +-- if' fn and if statement with +if' = if true then "false" else "true" + + +-- true' +true' = if false then "false" else "true" + + +-- false' +false' = if false then true' else "false" + + +case' = if true + then if' + else "true" + + +-- +type Schema + = { + , widgets :: { id :: Int } ==> Array Widget + } From a9706a90ca5a40f4d4c24983dc19ea91c448a151 Mon Sep 17 00:00:00 2001 From: wclr Date: Fri, 7 May 2021 11:13:08 +0500 Subject: [PATCH 52/82] add 'derive newtype' syntax --- grammars/purescript.cson | 4 +++- src/purescript.coffee | 3 ++- test/Main.purs | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index c40f689..169450d 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -74,7 +74,7 @@ } { 'name': 'meta.declaration.instance.purescript' - 'begin': '^\\s*\\b(else\\s+)?(derive\\s+)?(instance)(?!\')\\b' + 'begin': '^\\s*\\b(else\\s+)?(derive\\s+)?(newtype\\s+)?(instance)(?!\')\\b' 'end': '\\b(where)\\b|$' 'contentName': 'meta.type-signature.purescript' 'beginCaptures': @@ -84,6 +84,8 @@ 'name': 'keyword.other.purescript' '3': 'name': 'keyword.other.purescript' + '4': + 'name': 'keyword.other.purescript' 'endCaptures': '1': 'name': 'keyword.other.purescript' diff --git a/src/purescript.coffee b/src/purescript.coffee index 0547a77..4cf359d 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -117,13 +117,14 @@ purescriptGrammar = ] , name: 'meta.declaration.instance' - begin: /^\s*\b(else\s+)?(derive\s+)?(instance)(?!')\b/ + begin: /^\s*\b(else\s+)?(derive\s+)?(newtype\s+)?(instance)(?!')\b/ end: /\b(where)\b|$/ contentName: 'meta.type-signature' beginCaptures: 1: name: 'keyword.other' 2: name: 'keyword.other' 3: name: 'keyword.other' + 4: name: 'keyword.other' endCaptures: 1: name: 'keyword.other' patterns: [ diff --git a/test/Main.purs b/test/Main.purs index 391e249..1f091b2 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -49,7 +49,7 @@ class Functor v <= Mountable vnode where derive instance newtypeMySub :: Newtype (MySub vnode msg) _ - +derive newtype instance semiringScore :: Semiring Score derive instance genericCmd :: Generic PhonerCmd _ instance encodeCmd :: EncodeJson PhonerCmd where @@ -81,6 +81,7 @@ else instance showBoolean :: MyShow Boolean where else instance showA :: MyShow a where myShow _ = "Invalid" +else newtype instance showA :: MyShow a where -- Records with fields that are reserved words From 0629209cd7009df0e7a4c2b6e6356ffa6c1eeaf2 Mon Sep 17 00:00:00 2001 From: Nicholas Wolverson Date: Wed, 12 May 2021 20:40:37 +0100 Subject: [PATCH 53/82] 0.9.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d19bf8f..6b5a777 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-purescript", - "version": "0.9.5", + "version": "0.9.6", "description": "PureScript language support for the Atom editor", "license": "MIT", "repository": "https://github.com/darinmorrison/atom-language-purescript", From 416e2bd3ef2ac80e82cd051bd1469c4e724c5967 Mon Sep 17 00:00:00 2001 From: wclr Date: Sat, 22 May 2021 22:33:31 +0500 Subject: [PATCH 54/82] refactor and update grammar --- src/purescript.coffee | 780 +++++++++++++++++++++++++++--------------- test/Main.purs | 227 +++++++++--- 2 files changed, 696 insertions(+), 311 deletions(-) diff --git a/src/purescript.coffee b/src/purescript.coffee index 4cf359d..3990b5b 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -61,6 +61,10 @@ purescriptGrammar = list('classConstraint',/{className}|{functionName}/,/\s+/) functionTypeDeclaration: /({functionNameOne})\s*(::|∷)/ + # record field may be quoted string + recordFieldQuoted: /"(?:{className}|{functionNameOne})"/ + recordFieldDeclaration: + /((?:{recordFieldQuoted})|{functionNameOne})\s*(::|∷)/ ctorArgs: /// (?: {className} #proper type @@ -74,281 +78,67 @@ purescriptGrammar = indentChar: /[ \t]/ indentBlockEnd: /^(?!\1{indentChar}|{indentChar}*$)/ maybeBirdTrack: /^/ + doubleColon: ///(?: :: | ∷ )/// patterns: [ - name: 'keyword.operator.function.infix' - match: /(`){functionName}(`)/ - captures: - 1: name: 'punctuation.definition.entity' - 2: name: 'punctuation.definition.entity' - ### - In case this regex seems unusual for an infix operator, note - that PureScript allows any ordinary function application (elem 4 (1..10)) - to be rewritten as an infix expression (4 `elem` (1..10)). - ### + include: '#module_declaration' , - name: 'meta.declaration.module' - begin: /^\s*\b(module)(?!')\b/ - end: /(where)/ - beginCaptures: - 1: name: 'keyword.other' - endCaptures: - 1: name: 'keyword.other' - patterns: [ - include: '#comments' - , - include: '#module_name' - , - include: '#module_exports' - , - name: 'invalid' - match: /[a-z]+/ - ] + include: '#module_import' , - name: 'meta.declaration.typeclass' - begin: /^\s*\b(class)(?!')\b/ - end: /\b(where)\b|$/ - beginCaptures: - 1: name: 'storage.type.class' - endCaptures: - 1: name: 'keyword.other' - patterns: [ - include: '#type_signature' - ] + include: '#type_kind_signature' , - name: 'meta.declaration.instance' - begin: /^\s*\b(else\s+)?(derive\s+)?(newtype\s+)?(instance)(?!')\b/ - end: /\b(where)\b|$/ - contentName: 'meta.type-signature' - beginCaptures: - 1: name: 'keyword.other' - 2: name: 'keyword.other' - 3: name: 'keyword.other' - 4: name: 'keyword.other' - endCaptures: - 1: name: 'keyword.other' - patterns: [ - include: '#type_signature' - ] + include: '#row_type_declaration' , - name: 'meta.foreign.data' - begin: /^(\s*)(foreign)\s+(import)\s+(data)\s+({classNameOne})/ - end: /{indentBlockEnd}/ - contentName: 'meta.kind-signature' - beginCaptures: - 2: name: 'keyword.other' - 3: name: 'keyword.other' - 4: name: 'keyword.other' - 5: name: 'entity.name.type' - 6: name: 'keyword.other.double-colon' - patterns: [ - include: '#double_colon' - , - include: '#kind_signature' - ] + include: '#type_synonym_declaration' , - name: 'meta.foreign' - begin: /^(\s*)(foreign)\s+(import)\s+({functionNameOne})/ - end: /{indentBlockEnd}/ - contentName: 'meta.type-signature' - beginCaptures: - 2: name: 'keyword.other' - 3: name: 'keyword.other' - 4: name: 'entity.name.function' - patterns: [ - include: '#double_colon' - , - include: '#type_signature' - ] + # data and newtype + include: '#data_type_declaration' , - name: 'meta.import' - begin: /^\s*\b(import)(?!')\b/ - end: /($|(?=--))/ - beginCaptures: - 1: name: 'keyword.other' - patterns: [ - include: '#module_name' - , - include: '#module_exports' - , - match: /\b(as|hiding)\b/ - captures: - 1: name: 'keyword.other' - ] + include: '#typeclass_declaration' , - name: 'meta.declaration.type.data' - begin: /{maybeBirdTrack}(\s)*(data|newtype)\s+({typeDecl})\s*(?=\=|$)/ - end: /{indentBlockEnd}/ - beginCaptures: - 2: name: 'storage.type.data' - 3: - name: 'meta.type-signature' - patterns: [include: '#type_signature'] - patterns: [ - include: '#comments' - , - match: /=/ - captures: - 0: name: 'keyword.operator.assignment' - , - match: /{ctor}/ - captures: - 1: patterns: [include: '#data_ctor'] - 2: - name: 'meta.type-signature' - patterns: [include: '#type_signature'] - , - match: /\|/ - captures: - 0: name: 'punctuation.separator.pipe' - , - include: '#record_types' - ] + include: '#instance_declaration' , - name: 'meta.declaration.type.type' - begin: /{maybeBirdTrack}(\s)*(type)\s+({typeDecl})\s*(?=\=|$)/ - end: /{indentBlockEnd}/ - contentName: 'meta.type-signature' - beginCaptures: - 2: name: 'storage.type.data' - 3: - name: 'meta.type-signature' - patterns: [include: '#type_signature'] - patterns: [ - match: /=/ - captures: - 0: name: 'keyword.operator.assignment' - , - include: '#type_signature' - , - include: '#record_types' - , - include: '#comments' - ] + include: '#derive_declaration' , - name: 'keyword.other' - match: /^\s*\b(derive|where|data|type|newtype|infix[lr]?|foreign(\s+import)?(\s+data)?)(?!')\b/ + include: '#infix_op_declaration' , - name: 'entity.name.function.typed-hole' - match: /\?(?:{functionNameOne}|{classNameOne})/ + include: '#foreign_import_data' , - name: 'storage.type' - match: /^\s*\b(data|type|newtype)(?!')\b/ + include: '#foreign_import' , - name: 'keyword.control' - # match only if a keyword is not followed by: - # ' - names with prime symbol - # `:` or `=` - records define/update - match: /\b(do|ado|if|then|else|case|of|let|in)(?!('|\s*(:|=)))\b/ + include: '#function_type_declaration' , - name: 'constant.numeric.hex.purescript', - match: '\\b(?(?:[^()]|\\(\\g\\))*)(::|∷)(?(?:[^()]|\\(\\g\\))*)\\)' - captures: - 1: patterns: [include: '$self'] - 2: name: 'keyword.other.double-colon' - 3: {name: 'meta.type-signature', patterns: [include: '#type_signature']} + include: '#string_single_quoted' , - begin: /// - ^ - ( \s* ) - (?: ( :: | ∷ ) ) - /// - beginCaptures: - 2: name: 'keyword.other.double-colon' - end: /// - ^ - (?! \1 {indentChar}* | {indentChar}* $ ) - /// - patterns: [ - include: '#type_signature' - ] + include: '#string_double_quoted' , - include: '#data_ctor' + include: '#string_triple_quoted' , - include: '#comments' + include: '#markup_newline' , - include: '#infix_op' + include: '#double_colon_parens' + , + include: '#double_colon_orphan' + , + include: '#comments' , name: 'keyword.other.arrow' match: /\<-|-\>/ @@ -360,6 +150,414 @@ purescriptGrammar = match: /,/ ] repository: + module_declaration: + patterns: [ + name: 'meta.declaration.module' + begin: /^\s*\b(module)(?!')\b/ + end: /(\bwhere\b)/ + beginCaptures: + 1: name: 'keyword.other' + endCaptures: + 1: name: 'keyword.other' + patterns: [ + include: '#comments' + , + include: '#module_name' + , + include: '#module_exports' + , + name: 'invalid' + match: /[a-z]+/ + ] + ] + + function_infix: + patterns: [ + name: 'keyword.operator.function.infix' + match: /(`){functionName}(`)/ + captures: + 1: name: 'punctuation.definition.entity' + 2: name: 'punctuation.definition.entity' + ### + In case this regex seems unusual for an infix operator, note + that PureScript allows any ordinary function application (elem 4 (1..10)) + to be rewritten as an infix expression (4 `elem` (1..10)). + ### + ] + + typeclass_declaration: + patterns: [ + name: 'meta.declaration.typeclass' + begin: /^\s*\b(class)(?!')\b/ + end: /(\bwhere\b|(?=^\S))/ + beginCaptures: + 1: name: 'storage.type.class' + endCaptures: + 1: name: 'keyword.other' + patterns: [ + include: '#type_signature' + + ] + ] + + instance_declaration: + patterns: [ + name: 'meta.declaration.instance' + begin: /^\s*\b(else\s+)?(newtype\s+)?(instance)(?!')\b/ + end: /(\bwhere\b|(?=^\S))/ + contentName: 'meta.type-signature' + beginCaptures: + 1: name: 'keyword.other' + 2: name: 'keyword.other' + 3: name: 'keyword.other' + 4: name: 'keyword.other' + endCaptures: + 1: name: 'keyword.other' + patterns: [ + include: '#type_signature' + ] + ] + + derive_declaration: + patterns: [ + name: 'meta.declaration.derive' + begin: /^\s*\b(derive)(\s+newtype)?(\s+instance)?(?!')\b/ + end: /^(?=\S)/ + contentName: 'meta.type-signature' + beginCaptures: + 1: name: 'keyword.other' + 2: name: 'keyword.other' + 3: name: 'keyword.other' + 4: name: 'keyword.other' + endCaptures: + 1: name: 'keyword.other' + patterns: [ + include: '#type_signature' + ] + ] + + foreign_import_data: + patterns: [ + name: 'meta.foreign.data' + begin: /^(\s*)(foreign)\s+(import)\s+(data)(?:\s+({classNameOne})\s*({doubleColon}))?/ + end: /{indentBlockEnd}/ + contentName: 'meta.kind-signature' + beginCaptures: + 2: name: 'keyword.other' + 3: name: 'keyword.other' + 4: name: 'keyword.other' + 5: name: 'entity.name.type' + 6: name: 'keyword.other.double-colon' + patterns: [ + include: '#comments' + , + include: '#type_signature' + ] + ] + + foreign_import: + patterns: [ + name: 'meta.foreign' + begin: /^(\s*)(foreign)\s+(import)\s+({functionNameOne})/ + end: /{indentBlockEnd}/ + contentName: 'meta.type-signature' + beginCaptures: + 2: name: 'keyword.other' + 3: name: 'keyword.other' + 4: name: 'entity.name.function' + patterns: [ + include: '#double_colon' + , + include: '#type_signature' + ] + ] + + module_import: + patterns: [ + name: 'meta.import' + begin: /^\s*\b(import)(?!')\b/ + end: /^(?=\S)/ + beginCaptures: + 1: name: 'keyword.other' + patterns: [ + include: '#module_name' + , + include: '#comments' + , + include: '#module_exports' + , + match: /\b(as|hiding)\b/ + captures: + 1: name: 'keyword.other' + ] + ] + + type_kind_signature: + patterns: [ + name: 'meta.declaration.type.data.signature' + begin: /{maybeBirdTrack}(data|newtype)\s+({classNameOne})\s*({doubleColon})/ + end: /(?=^\S)/ + beginCaptures: + 1: name: 'storage.type.data' + 2: + name: 'meta.type-signature' + patterns: [include: '#type_signature'] + 3: name: 'keyword.other.double-colon' + patterns: [ + include: '#comments' + include: '#type_signature' + , + match: /=/ + captures: + 0: name: 'keyword.operator.assignment' + , + match: /{ctor}/ + captures: + 1: patterns: [include: '#data_ctor'] + 2: + name: 'meta.type-signature' + patterns: [include: '#type_signature'] + , + match: /\|/ + captures: + 0: name: 'punctuation.separator.pipe' + , + include: '#record_types' + ] + ] + + data_type_declaration: + patterns: [ + name: 'meta.declaration.type.data' + begin: /{maybeBirdTrack}(\s)*(data|newtype)\s+({typeDecl})\s*(?=\=|$)/ + end: /{indentBlockEnd}/ + beginCaptures: + 2: name: 'storage.type.data' + 3: + name: 'meta.type-signature' + patterns: [include: '#type_signature'] + patterns: [ + include: '#comments' + , + match: /=/ + captures: + 0: name: 'keyword.operator.assignment' + , + match: /{ctor}/ + captures: + 1: patterns: [include: '#data_ctor'] + 2: + name: 'meta.type-signature' + patterns: [include: '#type_signature'] + , + match: /\|/ + captures: + 0: name: 'punctuation.separator.pipe' + , + include: '#record_types' + ] + ] + + type_synonym_declaration: + patterns: [ + name: 'meta.declaration.type.type' + begin: /{maybeBirdTrack}(\s)*(type)\s+({typeDecl})\s*(?=\=|$)/ + end: /{indentBlockEnd}/ + contentName: 'meta.type-signature' + beginCaptures: + 2: name: 'storage.type.data' + 3: + name: 'meta.type-signature' + patterns: [include: '#type_signature'] + patterns: [ + match: /=/ + captures: + 0: name: 'keyword.operator.assignment' + , + include: '#type_signature' + , + include: '#row_type' + , + include: '#record_types' + , + include: '#comments' + ] + ] + + infix_op_declaration: + patterns: [ + name: 'meta.infix.declaration' + begin: /^\b(infix[l|r]?)(?!')\b/ + end: /($)/ + beginCaptures: + 1: name: 'keyword.other' + patterns: [ + include: '#comments' + , + include: '#type_name' + , + name: 'constant.numeric' + match: /\d+/ + , + match: /({operator})/ + captures: + 1: name: 'keyword.other' + , + match: /\b(as|type)\b/ + captures: + 1: name: 'keyword.other' + ] + ] + + keywords_orphan: + patterns: [ + name: 'keyword.other' + match: /^\s*\b(derive|where|data|type|newtype|foreign(\s+import)?(\s+data)?)(?!')\b/ + ] + + typed_hole: + patterns: [ + name: 'entity.name.function.typed-hole' + match: /\?(?:{functionNameOne}|{classNameOne})/ + ] + + control_keywords: + patterns: [ + name: 'keyword.control' + # match only if a keyword is not followed by: + # ' - names with prime symbol + # `:` or `=` - records define/update + match: /\b(do|ado|if|then|else|case|of|let|in)(?!('|\s*(:|=)))\b/ + ] + + constants_numeric_decimal: + patterns: [ + name: 'constant.numeric.decimal.purescript' + match: '''(?x) + (?(?:[^()]|\\(\\g\\))*)(::|∷)(?(?:[^()]|\\(\\g\\))*)\\)' + captures: + 1: patterns: [ + include: '$self' + ] + 2: name: 'keyword.other.double-colon' + 3: {name: 'meta.type-signature', patterns: [include: '#type_signature']} + ] + + double_colon_orphan: + patterns: [ + begin: /// + ^ + ( \s* ) + (?: ( :: | ∷ ) ) + /// + beginCaptures: + 2: name: 'keyword.other.double-colon' + end: /// + ^ + (?! \1 {indentChar}* | {indentChar}* $ ) + /// + patterns: [ + include: '#type_signature' + ] + ] + + markup_newline: + patterns: [ + name: 'markup.other.escape.newline' + match: /\\$/ + ] + + block_comment: patterns: [ name: 'comment.block.documentation' @@ -384,26 +582,7 @@ purescriptGrammar = include: '#block_comment' ] ] - record_types: - patterns: [ - name: 'meta.type.record' - begin: '\\{' - beginCaptures: - 0: - name: 'keyword.operator.type.record.begin.purescript' - end: '\\}' - endCaptures: - 0: - name: 'keyword.operator.type.record.end.purescript' - patterns: [ - name: 'punctuation.separator.comma.purescript' - match: ',' - , - include: '#record_field_declaration' - , - include: '#comments' - ] - ] + comments: patterns: [ begin: /({maybeBirdTrack}[ \t]+)?(?=--+\s+\|)/ @@ -445,9 +624,11 @@ purescriptGrammar = 2: name: 'constant.character.escape.octal' 3: name: 'constant.character.escape.hexadecimal' 4: name: 'constant.character.escape.control' + infix_op: name: 'entity.name.function.infix' match: /{operatorFun}/ + module_exports: name: 'meta.declaration.exports' begin: /\(/ @@ -468,9 +649,11 @@ purescriptGrammar = name: 'meta.other.constructor-list' match: /\(.*?\)/ ] + module_name: name: 'support.other.module' match: /(?:{className}\.)*{className}\.?/ + function_type_declaration: name: 'meta.function.type-declaration' begin: /// @@ -489,24 +672,76 @@ purescriptGrammar = include: '#double_colon' , include: '#type_signature' + , + include: '#record_types' + ] + + row_type: + patterns: [ + name: 'meta.type.row' + begin: /(?<=(^|=)\s*)\(/ + beginCaptures: + 0: + name: 'keyword.operator.type.row.begin.purescript' + end: /\)(?=\s*($|--))/ # add comment + endCaptures: + 0: + name: 'keyword.operator.type.row.end.purescript' + patterns: [ + name: 'punctuation.separator.comma.purescript' + match: ',' + , + include: '#record_field_declaration' + , + include: '#comments' + ] + ] + + record_types: + patterns: [ + name: 'meta.type.record' + begin: '\\{' + beginCaptures: + 0: + name: 'keyword.operator.type.record.begin.purescript' + end: '\\}' + endCaptures: + 0: + name: 'keyword.operator.type.record.end.purescript' + patterns: [ + name: 'punctuation.separator.comma.purescript' + match: ',' + , + include: '#record_field_declaration' + , + include: '#comments' + ] ] + record_field_declaration: name: 'meta.record-field.type-declaration' - begin: /{functionTypeDeclaration}/ - end: /(?={functionTypeDeclaration}|})/ + begin: /{recordFieldDeclaration}/ + end: /(?={recordFieldDeclaration}|}|\))/ contentName: 'meta.type-signature' beginCaptures: 1: patterns: [ name: 'entity.other.attribute-name' match: /{functionName}/ + , + name: 'string.quoted.double' + match: /"{functionNameOne}|{classNameOne}"/ ] 2: name: 'keyword.other.double-colon' patterns: [ include: '#type_signature' + , + include: '#comments' , include: '#record_types' ] + + # this can probalby be removed as we can use type_signature instead kind_signature: patterns: [ name: 'keyword.other.star' @@ -540,10 +775,10 @@ purescriptGrammar = 4: name: 'keyword.other.big-arrow' , name: 'keyword.other.arrow' - match: /->|→/ + match: /(?|→)/ , name: 'keyword.other.big-arrow' - match: /=>|⇒/ + match: /(?|⇒)/ , name: 'keyword.other.big-arrow-left' match: /<=|⇐/ @@ -556,6 +791,9 @@ purescriptGrammar = include: '#type_name' , include: '#comments' + , + name: 'keyword.other' + match: /{operator}/ ] type_name: name: 'entity.name.type' diff --git a/test/Main.purs b/test/Main.purs index 1f091b2..14220d2 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -5,42 +5,87 @@ module Main.App ) where -import Prelude +import Prelude -- can comment +import Prelude hiding (div) import Data.String as String -import Data.String (Pattern) -import Data.String (Pattern(..), split) +-- comment +import Data.String (Pattern) -- comment +import Data.String (Pattern(..), split) as String -- comment + + +-- multi-line import +import Data.String + ( Pattern(..), split -- comment + + ) as String -- comment +import Something (fd) -- Foreign import foreign -foreign import -foreign import data -foreign import calculateInterest :: Number -> Number -foreign import data F :: Type +foreign import --comment +foreign import data --comment +foreign import calculateInterest :: Number -> Number --comment +foreign import data F :: Type -> Type --comment + -- Containers -data D a = D1 a | D2 String +data D a = D1 a | D2 String --comment -type T = { a :: String } +type T = { a :: String } --comment type T a = { n :: N a, b :: String } newtype N a = N a --- infix -- TODO: as +data Proxy :: forall k. k -> Type +data Proxy a = Proxy + +-- newtype with multi-line kind signature +newtype MySub :: + forall k. (k -> Type) -> k -> Type --comment +newtype MySub vnode msg = + MySub (SubRec vnode msg) -infixr 0 apply as <| + +-- infix operators +infixr 0 apply as <| -- comment as <| infixl 0 applyFlipped as |> --- Type class +--- +data Sum a b + = Inl a + | Inr b --comment + + +data Product a b = Product a b + + +-- Type operators +infixl 6 type Sum as :+: -- comment +infixl 7 type Product as :*: + + + +-- type class signatures + + +class Category :: forall k. (k -> k -> Type) -> Constraint +class Semigroupoid a <= Category a where + identity :: forall t. a t t + + +-- type class without where +class ListToRow :: forall k. RowList k -> Row k -> Constraint +class ListToRow list row | list -> row class Functor v <= Mountable vnode where @@ -48,11 +93,46 @@ class Functor v <= Mountable vnode where unmount :: ∀ m. v m -> v m -> T Void E -derive instance newtypeMySub :: Newtype (MySub vnode msg) _ +--orphan keyword +class + + +-- multi-line type def +class Functor v + <= Mountable vnode where --comment + mount :: ∀ m. Element -> T Void (v m) + unmount :: ∀ m. v m -> v m -> T Void E + + +instance + + +instance listToRowCons + :: ( ListToRow tail tailRow + , Row.Cons label ty tailRow row ) --comment + => ListToRow (Cons label ty tail) row + + +--orphan keyword +derive +derive instance newtypeMySub :: Newtype (MySub vnode msg) _ --comment +derive newtype derive newtype instance semiringScore :: Semiring Score -derive instance genericCmd :: Generic PhonerCmd _ -instance encodeCmd :: EncodeJson PhonerCmd where + +-- multi-line derive +derive instance genericCmd + :: Generic PhonerCmd _ + + +-- TODO: multi-line, double-colons +derive instance genericCmd :: + Generic PhonerCmd _ + + +-- multi-line instance +instance encodeCmd + :: EncodeJson PhonerCmd where --comment encodeJson a = genericEncodeJson a @@ -61,7 +141,8 @@ instance functorA :: Functor A where instance functorA :: Functor A where - map = split + map = split -- comment + -- chained instances @@ -75,20 +156,23 @@ instance showString :: MyShow String where myShow s = s +-- chained instances else instance showBoolean :: MyShow Boolean where - myShow true = "true" + myShow true = "true" --comment myShow false = "false" -else instance showA :: MyShow a where +else instance showA :: MyShow a where myShow _ = "Invalid" - else newtype instance showA :: MyShow a where + + -- Records with fields that are reserved words type Rec = - { module :: String - , import :: String + { module :: String -- comment + , import :: Either Error (Array String) + -- comment , data :: String , newtype :: String } @@ -124,10 +208,10 @@ rec = updateRec = rec { data = "data" - , type ="type" + , type ="type" -- comment , foreign = "foreign" , import = "import" - , infixl = "infixl" + , infixl = "infixl" -- comment , infixr = "infixr" , infix = "infix" , class = "class" @@ -148,47 +232,93 @@ updateRec = rec } +type RowLine = ( name :: String, age :: { nested :: Number } ) + + -- quoted row type -type QuotedRow = +type QuotedRow a = ( "A" :: Int - , "B" :: Number - ) + -- comment + , "B" :: { nested :: Number } + , a :: Int -- comment + | a + ) --som + + +type NotRow a = Either Error (Array Int) + --- quoted record type +-- record with quoted fields type Quoted = - { "A" :: Int + { "A" :: Int -- comment + , a :: Boolean , "B" :: Number + , b :: Int -- comment + , "x" :: SmallCap } --- quoted row type +-- inlined type def +quoted :: + { "A" :: Int -- comment + , a :: Boolean + , "B" :: Number + , b :: Int -- comment + , "x" :: SmallCap + } quoted = - { "A": "a" - , "B": 1 + { "A": "a" -- comment + , "B": fn (1 :: Int) x 2 -- typed param in parens + , "C": 1 :: Int -- typed param without parens (no proper highlight) + , a: 2 } +-- typed hole +foo :: List Int -> List Int +foo = map ?myHole + + + -- Function, forall --- do, where -toStr :: forall a. a -> Effect Unit +-- infix functions +infixFun = 1 `add` 2 + + +-- function declaration, do, where +toStr :: forall a. Functor a => a -> Effect Unit --comment toStr x = do log $ show num - log $ show str + log $ show $ 1 `add` 2 where - num = 1 + -- indented type signature + num :: Int + num = (something :: Int) str = "Str" + + addIf true = singleton addIf false = const [] --- let in, case of -fn +-- double colon inside quotes breaks proper highlight +text = (" ::" + global) + + +-- fn type signature without :: in the same line lacks highlighting +-- it seems to be a bit harder case for proper handling +-- maybe it's also a sign that it is better not to have it in the code :-) + fn + -- line orphan signature :: forall a. a -> String + + fn a = + -- let in, case of let b = "str" in case a of "1" -> b + "1" @@ -212,8 +342,25 @@ case' = if true else "true" --- +-- operators inside type signature ==> type Schema - = { - , widgets :: { id :: Int } ==> Array Widget + = { widgets :: { id :: Int } ==> Array Widget --comment } + + + +-- constants + + +int = 1 + + +decimal = 41.0 + + +hex = 0xE0 + + +multiString = """ +WOW +""" From 5760f91580d8e8293f1769e634024b5122c26eed Mon Sep 17 00:00:00 2001 From: wclr Date: Sun, 30 May 2021 20:20:22 +0500 Subject: [PATCH 55/82] update recursive parens/row type and misc --- src/purescript.coffee | 91 ++++++++++++++++++++++++++++++++++++------- test/Main.purs | 32 +++++++++++---- 2 files changed, 103 insertions(+), 20 deletions(-) diff --git a/src/purescript.coffee b/src/purescript.coffee index 3990b5b..ddca4c0 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -86,8 +86,6 @@ purescriptGrammar = include: '#module_import' , include: '#type_kind_signature' - , - include: '#row_type_declaration' , include: '#type_synonym_declaration' , @@ -139,6 +137,8 @@ purescriptGrammar = include: '#double_colon_orphan' , include: '#comments' + , + include: '#double_colon_inlined_signature' , name: 'keyword.other.arrow' match: /\<-|-\>/ @@ -148,6 +148,7 @@ purescriptGrammar = , name: 'punctuation.separator.comma' match: /,/ + ] repository: module_declaration: @@ -521,16 +522,69 @@ purescriptGrammar = 0: name: 'punctuation.definition.string.end' ] + # double_colon_parens: + # patterns: [ + # # Note recursive regex matching nested parens + # match: [ + # '\\(', + # '(?(?:[^()]|\\(\\g\\))*)', + # '(::|∷)', + # '(?(?:[^()]|\\(\\g\\))*)', + # '\\)' + # ].join('') + # captures: + # 1: patterns: [ + # include: '$self' + # ] + # 2: name: 'keyword.other.double-colon' + # 3: {name: 'meta.type-signature', patterns: [include: '#type_signature']} + # ] + + double_colon_inlined_signature: + patterns: [ + # Note recursive regex matching nested parens + match: [ + # '\\(', + # '(?(?:[^()]|\\(\\g\\))*)', + '(::|∷)', + #'(?(?:[^()]|\\(\\g\\))*)', + '(.*)', + # '\\)' + ].join('') + captures: + # 1: patterns: [ + # include: '$self' + # ] + 1: name: 'keyword.other.double-colon' + 2: {name: 'meta.type-signature', patterns: [include: '#type_signature']} + ] + double_colon_parens: patterns: [ # Note recursive regex matching nested parens - match: '\\((?(?:[^()]|\\(\\g\\))*)(::|∷)(?(?:[^()]|\\(\\g\\))*)\\)' + # Here we will only match parens with :: inside + match: [ + '\\(', + # '(?(?:[^()]|\\(\\g\\))*)', + '(?(?:[^()]*(::|∷)[^()]*|\\(\\g\\)*))', + # '(::|∷)', + # '(?(?:[^()]|\\(\\g\\))*)', + '\\)' + ].join('') + # match: [ + # '\\((?(?:[^()]|\\(\\g\\))*)', + # '(::|∷)', + # '(?(?:[^()]|\\(\\g\\))*)', + # '\\)' + # ].join('') captures: 1: patterns: [ + # include: "#string_double_quoted" + # , + # include: '#double_colon_inlined_signature' + #, include: '$self' ] - 2: name: 'keyword.other.double-colon' - 3: {name: 'meta.type-signature', patterns: [include: '#type_signature']} ] double_colon_orphan: @@ -679,19 +733,23 @@ purescriptGrammar = row_type: patterns: [ name: 'meta.type.row' - begin: /(?<=(^|=)\s*)\(/ - beginCaptures: - 0: - name: 'keyword.operator.type.row.begin.purescript' - end: /\)(?=\s*($|--))/ # add comment - endCaptures: - 0: - name: 'keyword.operator.type.row.end.purescript' + # as row paren follows after = or type name or starts in a new line + begin: /(?<=(^|=|{classNameOne})\s*)\(/ + # beginCaptures: + # 0: name: 'keyword.operator.type.row.begin.purescript' + end: /\)/ + applyEndPatternsLast: true + # endCaptures: + # 0: name: 'keyword.operator.type.row.end.purescript' patterns: [ name: 'punctuation.separator.comma.purescript' match: ',' + , + include: '#row_type' , include: '#record_field_declaration' + , + include: '#type_signature' , include: '#comments' ] @@ -734,6 +792,11 @@ purescriptGrammar = ] 2: name: 'keyword.other.double-colon' patterns: [ + # # row type pipe + # match: /\|(?=\s*{functionNameOne})/ + # captures: + # 0: name: 'punctuation.separator.pipe' + # , include: '#type_signature' , include: '#comments' @@ -758,6 +821,8 @@ purescriptGrammar = ] type_signature: patterns: [ + include: '#string_double_quoted' + , name: 'meta.class-constraints' match: concat /\(/, list('classConstraints',/{classConstraint}/,/,/), diff --git a/test/Main.purs b/test/Main.purs index 14220d2..0ff8300 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -120,6 +120,10 @@ derive newtype derive newtype instance semiringScore :: Semiring Score +-- instance without name +derive newtype instance Semiring Score + + -- multi-line derive derive instance genericCmd :: Generic PhonerCmd _ @@ -232,7 +236,17 @@ updateRec = rec } -type RowLine = ( name :: String, age :: { nested :: Number } ) +-- row type parens are not highlighted as it doesn't seem necessary +type RowLine a = ( name :: String, age :: { nested :: Number } | a ) + + +type RowRecord a + = Record + ( RowLine ( some :: Either Error (Array a) ) + ) + + +type RowRecordLine = Record ( RowLine ( some :: String ) ) -- quoted row type @@ -274,6 +288,14 @@ quoted = } +-- proxy +proxy = Proxy :: Proxy Int -- k is Type + + +intAtFoo :: forall r. Variant (foo :: Int | r) +intAtFoo = inj (Proxy :: Proxy "foo") 42 + + -- typed hole foo :: List Int -> List Int foo = map ?myHole @@ -295,12 +317,10 @@ toStr x = do where -- indented type signature num :: Int - num = (something :: Int) + num = ((something :: Int) :: Int) str = "Str" - - addIf true = singleton addIf false = const [] @@ -312,11 +332,9 @@ text = (" ::" + global) -- fn type signature without :: in the same line lacks highlighting -- it seems to be a bit harder case for proper handling -- maybe it's also a sign that it is better not to have it in the code :-) - fn +fn -- line orphan signature :: forall a. a -> String - - fn a = -- let in, case of let b = "str" From 5188ad88f5f930c2540890b73fce7590cba46d73 Mon Sep 17 00:00:00 2001 From: wclr Date: Mon, 31 May 2021 02:16:17 +0500 Subject: [PATCH 56/82] make ADT pipe operator --- src/purescript.coffee | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/purescript.coffee b/src/purescript.coffee index ddca4c0..d65a104 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -321,7 +321,8 @@ purescriptGrammar = , match: /\|/ captures: - 0: name: 'punctuation.separator.pipe' + # 0: name: 'punctuation.separator.pipe' + 0: name: 'keyword.operator.pipe' , include: '#record_types' ] @@ -353,7 +354,8 @@ purescriptGrammar = , match: /\|/ captures: - 0: name: 'punctuation.separator.pipe' + # 0: name: 'punctuation.separator.pipe' + 0: name: 'keyword.operator.pipe' , include: '#record_types' ] From 52f26531b581a99c52d46a50372278f3306a6795 Mon Sep 17 00:00:00 2001 From: wclr Date: Mon, 14 Jun 2021 18:16:39 +0500 Subject: [PATCH 57/82] fix types highlight inside ADT --- src/purescript.coffee | 23 ++++++++++++++--------- test/Main.purs | 23 +++++++++++++++++++---- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/purescript.coffee b/src/purescript.coffee index d65a104..5773b33 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -84,8 +84,8 @@ purescriptGrammar = include: '#module_declaration' , include: '#module_import' - , - include: '#type_kind_signature' + # , + # include: '#type_kind_signature' , include: '#type_synonym_declaration' , @@ -344,13 +344,13 @@ purescriptGrammar = match: /=/ captures: 0: name: 'keyword.operator.assignment' - , - match: /{ctor}/ + # , + match: /(?<=(\||=)\s*)({classNameOne})/ captures: - 1: patterns: [include: '#data_ctor'] - 2: - name: 'meta.type-signature' - patterns: [include: '#type_signature'] + 2: patterns: [include: '#data_ctor'] + # 2: + # name: 'meta.type-signature' + # patterns: [include: '#type_signature'] , match: /\|/ captures: @@ -358,6 +358,8 @@ purescriptGrammar = 0: name: 'keyword.operator.pipe' , include: '#record_types' + , + include: '#type_signature' ] ] @@ -736,7 +738,8 @@ purescriptGrammar = patterns: [ name: 'meta.type.row' # as row paren follows after = or type name or starts in a new line - begin: /(?<=(^|=|{classNameOne})\s*)\(/ + # begin: /(?<=(^|=|{classNameOne})\s*)\(/ + begin: /\((?=\s*({functionNameOne}|"{functionNameOne}"|"{classNameOne}")\s*(::|∷))/ # beginCaptures: # 0: name: 'keyword.operator.type.row.begin.purescript' end: /\)/ @@ -824,6 +827,8 @@ purescriptGrammar = type_signature: patterns: [ include: '#string_double_quoted' + , + include: '#row_type' , name: 'meta.class-constraints' match: concat /\(/, diff --git a/test/Main.purs b/test/Main.purs index 0ff8300..0c3b1ea 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -34,7 +34,19 @@ foreign import data F :: Type -> Type --comment -- Containers -data D a = D1 a | D2 String --comment +data D a = D1 a | D2 (Array a) --comment + + +-- some issues with proper highlighting inside parens +data D1 a + = D1 a + | D2 (Array Some.Type) + | D3 (Either Aff.Error Db.Client) + | D4 + (Array Some.Type) --comment + | D5 String + Int -- not proper + | S1 (forall f. f String -> f a) type T = { a :: String } --comment @@ -249,12 +261,15 @@ type RowRecord a type RowRecordLine = Record ( RowLine ( some :: String ) ) +type EntireRecordCodec = T "Str" ( a :: String , "B" :: Boolean) + + -- quoted row type type QuotedRow a = ( "A" :: Int -- comment , "B" :: { nested :: Number } - , a :: Int -- comment + , a :: Some.Int -- comment | a ) --som @@ -283,7 +298,7 @@ quoted :: quoted = { "A": "a" -- comment , "B": fn (1 :: Int) x 2 -- typed param in parens - , "C": 1 :: Int -- typed param without parens (no proper highlight) + , "C": 1 :: Int -- typed param without parens , a: 2 } @@ -325,7 +340,7 @@ addIf true = singleton addIf false = const [] --- double colon inside quotes breaks proper highlight +-- double colon inside quoted string text = (" ::" + global) From e4046c4e3eea314de2ce26f37a5b45f25f0d6528 Mon Sep 17 00:00:00 2001 From: wclr Date: Sun, 5 Sep 2021 13:07:44 +0500 Subject: [PATCH 58/82] fix row types higlight --- src/purescript.coffee | 70 +++++++++++++++++++++++-------------------- test/Main.purs | 59 ++++++++++++++++++++++++++---------- 2 files changed, 81 insertions(+), 48 deletions(-) diff --git a/src/purescript.coffee b/src/purescript.coffee index 5773b33..3c86787 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -64,7 +64,7 @@ purescriptGrammar = # record field may be quoted string recordFieldQuoted: /"(?:{className}|{functionNameOne})"/ recordFieldDeclaration: - /((?:{recordFieldQuoted})|{functionNameOne})\s*(::|∷)/ + /((?:[ ,])(?:{recordFieldQuoted})|{functionNameOne})\s*(::|∷)/ ctorArgs: /// (?: {className} #proper type @@ -251,8 +251,10 @@ purescriptGrammar = 6: name: 'keyword.other.double-colon' patterns: [ include: '#comments' - , + , include: '#type_signature' + , + include: '#record_types' ] ] @@ -270,6 +272,8 @@ purescriptGrammar = include: '#double_colon' , include: '#type_signature' + , + include: '#record_types' ] ] @@ -282,6 +286,8 @@ purescriptGrammar = 1: name: 'keyword.other' patterns: [ include: '#module_name' + , + include: "#string_double_quoted" , include: '#comments' , @@ -380,10 +386,10 @@ purescriptGrammar = 0: name: 'keyword.operator.assignment' , include: '#type_signature' - , - include: '#row_type' , include: '#record_types' + , + include: '#row_types' , include: '#comments' ] @@ -732,31 +738,26 @@ purescriptGrammar = include: '#type_signature' , include: '#record_types' + , + include: '#row_types' ] - row_type: + row_types: patterns: [ name: 'meta.type.row' - # as row paren follows after = or type name or starts in a new line - # begin: /(?<=(^|=|{classNameOne})\s*)\(/ - begin: /\((?=\s*({functionNameOne}|"{functionNameOne}"|"{classNameOne}")\s*(::|∷))/ - # beginCaptures: - # 0: name: 'keyword.operator.type.row.begin.purescript' - end: /\)/ - applyEndPatternsLast: true - # endCaptures: - # 0: name: 'keyword.operator.type.row.end.purescript' + ### + For distinction of row type we use pattern with a space after/before a bracket, + because there doesn't seem to be a correct way to distinguish row type declaration + from another types put in brackets. + ### + begin: /\((?= \s*({functionNameOne}|"{functionNameOne}"|"{classNameOne}")\s*(::|∷))/ + end: / \)/ + #applyEndPatternsLast: true patterns: [ - name: 'punctuation.separator.comma.purescript' - match: ',' - , - include: '#row_type' - , - include: '#record_field_declaration' - , - include: '#type_signature' - , - include: '#comments' + # name: 'punctuation.separator.comma.purescript' + # match: ',' + # , + include: '#record_field_declaration' ] ] @@ -784,7 +785,9 @@ purescriptGrammar = record_field_declaration: name: 'meta.record-field.type-declaration' begin: /{recordFieldDeclaration}/ - end: /(?={recordFieldDeclaration}|}|\))/ + # we use end pattern of " )" with space (as as row type ending) + end: /(?={recordFieldDeclaration}|}| \))/ + # applyEndPatternsLast: true contentName: 'meta.type-signature' beginCaptures: 1: @@ -792,8 +795,9 @@ purescriptGrammar = name: 'entity.other.attribute-name' match: /{functionName}/ , + # match quoated props name: 'string.quoted.double' - match: /"{functionNameOne}|{classNameOne}"/ + match: /\"({functionNameOne}|{classNameOne})\"/ ] 2: name: 'keyword.other.double-colon' patterns: [ @@ -802,11 +806,13 @@ purescriptGrammar = # captures: # 0: name: 'punctuation.separator.pipe' # , + include: '#record_types' + # , + # include: '#row_types' + , include: '#type_signature' , include: '#comments' - , - include: '#record_types' ] # this can probalby be removed as we can use type_signature instead @@ -826,10 +832,8 @@ purescriptGrammar = ] type_signature: patterns: [ - include: '#string_double_quoted' - , - include: '#row_type' - , + # include: '#row_types' + # , name: 'meta.class-constraints' match: concat /\(/, list('classConstraints',/{classConstraint}/,/,/), @@ -857,6 +861,8 @@ purescriptGrammar = , name: 'keyword.other.forall' match: /forall|∀/ + , + include: '#string_double_quoted' , include: '#generic_type' , diff --git a/test/Main.purs b/test/Main.purs index 0c3b1ea..6622f5e 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -30,6 +30,10 @@ foreign import calculateInterest :: Number -> Number --comment foreign import data F :: Type -> Type --comment +-- import data with record type +foreign import data R :: { prop :: String } + + -- Containers @@ -37,7 +41,7 @@ foreign import data F :: Type -> Type --comment data D a = D1 a | D2 (Array a) --comment --- some issues with proper highlighting inside parens +-- data D1 a = D1 a | D2 (Array Some.Type) @@ -45,7 +49,7 @@ data D1 a | D4 (Array Some.Type) --comment | D5 String - Int -- not proper + Int | S1 (forall f. f String -> f a) @@ -116,6 +120,11 @@ class Functor v unmount :: ∀ m. v m -> v m -> T Void E +-- class with type, breaks highlighting +class RowTypeClass (rl :: RL.RowList Type) where + rowListCodec :: forall proxy. proxy rl -> Record ri -> CA.JPropCodec (Record ro) + + instance @@ -185,9 +194,22 @@ else newtype instance showA :: MyShow a where -- Records with fields that are reserved words -type Rec = +-- quoted row type +type QuotedRow a = + ( "A" :: Int + -- comment + , "B" :: { nested :: Number } + , c :: Either (Maybe Bad) Int + , d :: Some.Int -- comment + , e :: Some.Int -- comment + | a + ) --som + + +data Rec = { module :: String -- comment , import :: Either Error (Array String) + , import2 :: Either (Maybe Bad) Good -- no proper -- comment , data :: String , newtype :: String @@ -261,17 +283,7 @@ type RowRecord a type RowRecordLine = Record ( RowLine ( some :: String ) ) -type EntireRecordCodec = T "Str" ( a :: String , "B" :: Boolean) - - --- quoted row type -type QuotedRow a = - ( "A" :: Int - -- comment - , "B" :: { nested :: Number } - , a :: Some.Int -- comment - | a - ) --som +type EntireRecordCodec = T "Str" ( a :: String , "B" :: Boolean ) type NotRow a = Either Error (Array Int) @@ -287,7 +299,7 @@ type Quoted = } --- inlined type def +-- inlined record type def quoted :: { "A" :: Int -- comment , a :: Boolean @@ -303,11 +315,23 @@ quoted = } +-- inlined record type def inside foreign import +foreign import createSource :: + String -> + { onOpen :: Effect Unit + , onMessage :: SourceEvent -> Effect Unit + , onError :: SourceError -> Effect Unit + , withCredentials :: Boolean + } -> + Effect EventSource + + -- proxy proxy = Proxy :: Proxy Int -- k is Type -intAtFoo :: forall r. Variant (foo :: Int | r) +-- no proper for row +intAtFoo :: forall r. Variant ( foo :: Int | r ) intAtFoo = inj (Proxy :: Proxy "foo") 42 @@ -397,3 +421,6 @@ hex = 0xE0 multiString = """ WOW """ + +-- after mult-line string +class Foo (a :: Symbol) From 099f3188fadf38cbf4c3b115e10dd6a4c7976dbd Mon Sep 17 00:00:00 2001 From: wclr Date: Wed, 8 Sep 2021 12:48:38 +0500 Subject: [PATCH 59/82] fix inner quotes inside triple quotes --- src/purescript.coffee | 5 +++-- test/Main.purs | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/purescript.coffee b/src/purescript.coffee index 3c86787..5809498 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -123,12 +123,13 @@ purescriptGrammar = include: '#constant_numeric' , include: '#constant_boolean' + , + ### Triple quotes should come first to enclose inner quotes ### + include: '#string_triple_quoted' , include: '#string_single_quoted' , include: '#string_double_quoted' - , - include: '#string_triple_quoted' , include: '#markup_newline' , diff --git a/test/Main.purs b/test/Main.purs index 6622f5e..3f2e558 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -419,8 +419,13 @@ hex = 0xE0 multiString = """ -WOW + + 'text' "WOW" text + """ +multiStringOneLine = """ "WOW" text """ + + -- after mult-line string class Foo (a :: Symbol) From ccaef631dd37ae65da24caa2aed22f69455458ad Mon Sep 17 00:00:00 2001 From: wclr Date: Sat, 20 Nov 2021 12:52:28 +0500 Subject: [PATCH 60/82] fix comments highlight --- src/purescript.coffee | 43 +++++++++++++++++++++++-------------------- test/Main.purs | 23 ++++++++++++++++++----- 2 files changed, 41 insertions(+), 25 deletions(-) diff --git a/src/purescript.coffee b/src/purescript.coffee index 5809498..3941e2c 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -84,8 +84,6 @@ purescriptGrammar = include: '#module_declaration' , include: '#module_import' - # , - # include: '#type_kind_signature' , include: '#type_synonym_declaration' , @@ -137,7 +135,7 @@ purescriptGrammar = , include: '#double_colon_orphan' , - include: '#comments' + include: '#comments' , include: '#double_colon_inlined_signature' , @@ -650,25 +648,29 @@ purescriptGrammar = comments: patterns: [ - begin: /({maybeBirdTrack}[ \t]+)?(?=--+\s+\|)/ - end: /(?!\G)/ - beginCaptures: - 1: name: 'punctuation.whitespace.comment.leading' - patterns: [ - name: 'comment.line.double-dash.documentation' - begin: /(--+)\s+(\|)/ - end: /\n/ - beginCaptures: - 1: name: 'punctuation.definition.comment' - 2: name: 'punctuation.definition.comment.documentation' - ] - , + # begin: /({maybeBirdTrack}[ \t]+)?(?=--+\s*\|)/ + # #begin: / --/ + # # begin: /({maybeBirdTrack}[ \t]+)?(?=--+)/ + # end: /(?!\G)/ + # beginCaptures: + # 1: name: 'punctuation.whitespace.comment.leading' + # patterns: [ + # name: 'comment.line.double-dash.documentation' + # begin: /(--+)\s*(\|)/ + # # begin: /(--+)/ + # end: /\n/ + # beginCaptures: + # 1: name: 'punctuation.definition.comment' + # 2: name: 'punctuation.definition.comment.documentation' + # ] + # , ### Operators may begin with -- as long as they are not entirely composed of - characters. This means comments can't be immediately followed by an allowable operator character. ### - begin: /({maybeBirdTrack}[ \t]+)?(?=--+(?!{operatorChar}))/ + # begin: /({maybeBirdTrack}[ \t]+)?(?=--+(?!{operatorChar}))/ + begin: /({maybeBirdTrack}[ \t]+)?(?=--+)/ end: /(?!\G)/ beginCaptures: 1: name: 'punctuation.whitespace.comment.leading' @@ -765,7 +767,8 @@ purescriptGrammar = record_types: patterns: [ name: 'meta.type.record' - begin: '\\{' + # start with {, but not block comment + begin: '\\{(?!-)' beginCaptures: 0: name: 'keyword.operator.type.record.begin.purescript' @@ -776,10 +779,10 @@ purescriptGrammar = patterns: [ name: 'punctuation.separator.comma.purescript' match: ',' - , - include: '#record_field_declaration' , include: '#comments' + , + include: '#record_field_declaration' ] ] diff --git a/test/Main.purs b/test/Main.purs index 3f2e558..2b77026 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -1,3 +1,4 @@ +-- start {- Test file to visually assess syntax highlighting. -} module Main.App where module Main.App @@ -35,6 +36,15 @@ foreign import data R :: { prop :: String } +-- line comments with no space between first char +--| some + +-- comments with operators after +--# some +--! some + + + -- Containers @@ -45,6 +55,7 @@ data D a = D1 a | D2 (Array a) --comment data D1 a = D1 a | D2 (Array Some.Type) + {- comment inside -} | D3 (Either Aff.Error Db.Client) | D4 (Array Some.Type) --comment @@ -72,8 +83,9 @@ newtype MySub vnode msg = -- infix operators -infixr 0 apply as <| -- comment as <| -infixl 0 applyFlipped as |> +-- operators that contain -- within +infixr 0 apply as :--> -- comment as :--> +infixl 0 applyFlipped as <--: --- @@ -109,7 +121,7 @@ class Functor v <= Mountable vnode where unmount :: ∀ m. v m -> v m -> T Void E ---orphan keyword +--| orphan keyword class @@ -199,6 +211,7 @@ type QuotedRow a = ( "A" :: Int -- comment , "B" :: { nested :: Number } + {- block comment inside -} , c :: Either (Maybe Bad) Int , d :: Some.Int -- comment , e :: Some.Int -- comment @@ -209,7 +222,7 @@ type QuotedRow a = data Rec = { module :: String -- comment , import :: Either Error (Array String) - , import2 :: Either (Maybe Bad) Good -- no proper + , import2 :: Either (Maybe Bad) Good -- comment , data :: String , newtype :: String @@ -330,7 +343,7 @@ foreign import createSource :: proxy = Proxy :: Proxy Int -- k is Type --- no proper for row +-- row type intAtFoo :: forall r. Variant ( foo :: Int | r ) intAtFoo = inj (Proxy :: Proxy "foo") 42 From 7a3ab9550b59fb34d052fbbf20efd860d1a4fbd7 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 30 May 2022 22:04:32 +0500 Subject: [PATCH 61/82] double colon inlined fixes --- src/purescript.coffee | 47 ++++++++++++++++++++++++++++++++++++++----- test/Main.purs | 17 +++++++++++++++- 2 files changed, 58 insertions(+), 6 deletions(-) diff --git a/src/purescript.coffee b/src/purescript.coffee index 3941e2c..d2930d6 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -87,7 +87,6 @@ purescriptGrammar = , include: '#type_synonym_declaration' , - # data and newtype include: '#data_type_declaration' , include: '#typeclass_declaration' @@ -115,6 +114,8 @@ purescriptGrammar = include: '#data_ctor' , include: '#infix_op' + , + include: '#double_colon_inlined_signature' , include: '#constants_numeric_decimal' , @@ -136,8 +137,6 @@ purescriptGrammar = include: '#double_colon_orphan' , include: '#comments' - , - include: '#double_colon_inlined_signature' , name: 'keyword.other.arrow' match: /\<-|-\>/ @@ -550,8 +549,44 @@ purescriptGrammar = # ] double_colon_inlined_signature: + patterns: [ + patterns: [ + match: '(SomeType)\s*({doubleColon})(.*)' + captures: + 1: name: 'meta.type-signature' + 2: name: 'keyword.other.double-colon' + 3: {name: 'meta.type-signature', patterns: [include: '#type_signature']} + + ] + , + patterns: [ + match: '({doubleColon})(.*)(<-)' + captures: + 1: name: 'keyword.other.double-colon' + 2: {name: 'meta.type-signature', patterns: [ include: '#type_signature']} + 3: name: 'keyword.other.double-colon' + + ] + , + patterns: [ + match: '({doubleColon})(.*)' + captures: + 1: name: 'keyword.other.double-colon' + 2: { + name: 'meta.type-signature' + patterns: [ + include: "#record_types" + include: '#type_signature' + ] + } + + ] + ] + + _double_colon_inlined_signature: patterns: [ # Note recursive regex matching nested parens + # match: '\\((?(?:[^()]|\\(\\g\\))*)(::|∷)(?(?:[^()]|\\(\\g\\))*)\\)' match: [ # '\\(', # '(?(?:[^()]|\\(\\g\\))*)', @@ -836,8 +871,10 @@ purescriptGrammar = ] type_signature: patterns: [ - # include: '#row_types' - # , + include: "#record_types" + , + include: '#row_types' + , name: 'meta.class-constraints' match: concat /\(/, list('classConstraints',/{classConstraint}/,/,/), diff --git a/test/Main.purs b/test/Main.purs index 2b77026..5b561ed 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -1,4 +1,6 @@ -- start + + {- Test file to visually assess syntax highlighting. -} module Main.App where module Main.App @@ -39,6 +41,8 @@ foreign import data R :: { prop :: String } -- line comments with no space between first char --| some + + -- comments with operators after --# some --! some @@ -362,7 +366,7 @@ infixFun = 1 `add` 2 -- function declaration, do, where -toStr :: forall a. Functor a => a -> Effect Unit --comment +toStr :: forall a. Functor a => { a :: a } -> Effect Unit --comment toStr x = do log $ show num log $ show $ 1 `add` 2 @@ -373,6 +377,16 @@ toStr x = do str = "Str" +-- double_colon_inlined_signature +gotConfig :: AVar { a :: Unit } <- AVar.empty + + +SomeType :: ( a :: Int ) + + +AVar :: Type → Type + + addIf true = singleton addIf false = const [] @@ -437,6 +451,7 @@ multiString = """ """ + multiStringOneLine = """ "WOW" text """ From 836d758e50f7a2e7162bb3837fd13edfb1b6de1c Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 30 May 2022 22:18:38 +0500 Subject: [PATCH 62/82] infix data ctor --- src/purescript.coffee | 7 ++++++- test/Main.purs | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/purescript.coffee b/src/purescript.coffee index d2930d6..26e07b1 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -403,7 +403,7 @@ purescriptGrammar = patterns: [ include: '#comments' , - include: '#type_name' + include: '#data_ctor' , name: 'constant.numeric' match: /\d+/ @@ -411,6 +411,11 @@ purescriptGrammar = match: /({operator})/ captures: 1: name: 'keyword.other' + , + match: /\b(type)\s+({className})\b/ + captures: + 1: name: 'keyword.other' + 2: name: 'entity.name.type' , match: /\b(as|type)\b/ captures: diff --git a/test/Main.purs b/test/Main.purs index 5b561ed..5b209bd 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -106,6 +106,9 @@ infixl 6 type Sum as :+: -- comment infixl 7 type Product as :*: +-- Ctor operators +infixl 2 Inl as $% +infixr 2 Inr as %$ -- type class signatures From a28890af466517cc3dbea9967bf10866fe94393e Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 12 Jul 2022 12:31:55 +0500 Subject: [PATCH 63/82] fix issues with row types and other --- src/purescript.coffee | 173 +++++++++++++++++++----------------------- test/Main.purs | 41 +++++++--- 2 files changed, 108 insertions(+), 106 deletions(-) diff --git a/src/purescript.coffee b/src/purescript.coffee index 26e07b1..1959ebb 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -114,8 +114,6 @@ purescriptGrammar = include: '#data_ctor' , include: '#infix_op' - , - include: '#double_colon_inlined_signature' , include: '#constants_numeric_decimal' , @@ -133,10 +131,12 @@ purescriptGrammar = include: '#markup_newline' , include: '#double_colon_parens' + , + include: '#double_colon_inlined' , include: '#double_colon_orphan' , - include: '#comments' + include: '#comments' , name: 'keyword.other.arrow' match: /\<-|-\>/ @@ -535,42 +535,45 @@ purescriptGrammar = 0: name: 'punctuation.definition.string.end' ] - # double_colon_parens: - # patterns: [ - # # Note recursive regex matching nested parens - # match: [ - # '\\(', - # '(?(?:[^()]|\\(\\g\\))*)', - # '(::|∷)', - # '(?(?:[^()]|\\(\\g\\))*)', - # '\\)' - # ].join('') - # captures: - # 1: patterns: [ - # include: '$self' - # ] - # 2: name: 'keyword.other.double-colon' - # 3: {name: 'meta.type-signature', patterns: [include: '#type_signature']} - # ] - - double_colon_inlined_signature: + # for inline signatures with parens + double_colon_parens: patterns: [ - patterns: [ - match: '(SomeType)\s*({doubleColon})(.*)' - captures: - 1: name: 'meta.type-signature' - 2: name: 'keyword.other.double-colon' - 3: {name: 'meta.type-signature', patterns: [include: '#type_signature']} + # Note recursive regex matching nested parens + match: [ + '\\(', + '(?(?:[^()]|\\(\\g\\))*)', + '(::|∷)', + '(?(?:[^()]|\\(\\g\\))*)', + '\\)' + ].join('') + captures: + 1: patterns: [ + include: '$self' + ] + 2: name: 'keyword.other.double-colon' + 3: {name: 'meta.type-signature', patterns: [include: '#type_signature']} + ] - ] - , + # for inline signatures without parens + double_colon_inlined: + patterns: [ + # signatures in ide tooptips (starts from new line) + # patterns: [ + # match: '^({classNameOne})(?: +)({doubleColon})(.*)' + # captures: + # 1: {name: 'meta.type-signature', patterns: [include: '#type_signature']} + # 2: name: 'keyword.other.double-colon' + # 3: {name: 'meta.type-signature', patterns: [include: '#type_signature']} + # ] + # , patterns: [ - match: '({doubleColon})(.*)(<-)' + match: '({doubleColon})(.*)(?=<-|")' captures: 1: name: 'keyword.other.double-colon' - 2: {name: 'meta.type-signature', patterns: [ include: '#type_signature']} - 3: name: 'keyword.other.double-colon' + 2: {name: 'meta.type-signature', patterns: [ + include: '#type_signature' + ]} ] , patterns: [ @@ -587,61 +590,13 @@ purescriptGrammar = ] ] - - _double_colon_inlined_signature: - patterns: [ - # Note recursive regex matching nested parens - # match: '\\((?(?:[^()]|\\(\\g\\))*)(::|∷)(?(?:[^()]|\\(\\g\\))*)\\)' - match: [ - # '\\(', - # '(?(?:[^()]|\\(\\g\\))*)', - '(::|∷)', - #'(?(?:[^()]|\\(\\g\\))*)', - '(.*)', - # '\\)' - ].join('') - captures: - # 1: patterns: [ - # include: '$self' - # ] - 1: name: 'keyword.other.double-colon' - 2: {name: 'meta.type-signature', patterns: [include: '#type_signature']} - ] - - double_colon_parens: - patterns: [ - # Note recursive regex matching nested parens - # Here we will only match parens with :: inside - match: [ - '\\(', - # '(?(?:[^()]|\\(\\g\\))*)', - '(?(?:[^()]*(::|∷)[^()]*|\\(\\g\\)*))', - # '(::|∷)', - # '(?(?:[^()]|\\(\\g\\))*)', - '\\)' - ].join('') - # match: [ - # '\\((?(?:[^()]|\\(\\g\\))*)', - # '(::|∷)', - # '(?(?:[^()]|\\(\\g\\))*)', - # '\\)' - # ].join('') - captures: - 1: patterns: [ - # include: "#string_double_quoted" - # , - # include: '#double_colon_inlined_signature' - #, - include: '$self' - ] - ] - double_colon_orphan: patterns: [ begin: /// - ^ ( \s* ) (?: ( :: | ∷ ) ) + ( \s* ) + $ /// beginCaptures: 2: name: 'keyword.other.double-colon' @@ -653,6 +608,23 @@ purescriptGrammar = include: '#type_signature' ] ] + # double_colon_orphan: + # patterns: [ + # begin: /// + # ^ + # ( \s* ) + # (?: ( :: | ∷ ) ) + # /// + # beginCaptures: + # 2: name: 'keyword.other.double-colon' + # end: /// + # ^ + # (?! \1 {indentChar}* | {indentChar}* $ ) + # /// + # patterns: [ + # include: '#type_signature' + # ] + # ] markup_newline: patterns: [ @@ -793,14 +765,21 @@ purescriptGrammar = because there doesn't seem to be a correct way to distinguish row type declaration from another types put in brackets. ### - begin: /\((?= \s*({functionNameOne}|"{functionNameOne}"|"{classNameOne}")\s*(::|∷))/ - end: / \)/ + # begin: /\((?= \s*({functionNameOne}|"{functionNameOne}"|"{classNameOne}")\s*(::|∷))/ + # end: / \)/ + begin: /\((?=\s*({functionNameOne}|"{functionNameOne}"|"{classNameOne}")\s*(::|∷))/ + end: /(?=^\S)/ + #applyEndPatternsLast: true patterns: [ - # name: 'punctuation.separator.comma.purescript' - # match: ',' - # , - include: '#record_field_declaration' + name: 'punctuation.separator.comma.purescript' + match: ',' + , + include: '#comments' + , + include: '#record_field_declaration' + , + include: '#type_signature' ] ] @@ -821,8 +800,11 @@ purescriptGrammar = match: ',' , include: '#comments' + , include: '#record_field_declaration' + , + include: '#type_signature' ] ] @@ -830,7 +812,7 @@ purescriptGrammar = name: 'meta.record-field.type-declaration' begin: /{recordFieldDeclaration}/ # we use end pattern of " )" with space (as as row type ending) - end: /(?={recordFieldDeclaration}|}| \))/ + end: /(?={recordFieldDeclaration}|}| \)|{indentBlockEnd})/ # applyEndPatternsLast: true contentName: 'meta.type-signature' beginCaptures: @@ -845,16 +827,13 @@ purescriptGrammar = ] 2: name: 'keyword.other.double-colon' patterns: [ - # # row type pipe - # match: /\|(?=\s*{functionNameOne})/ - # captures: - # 0: name: 'punctuation.separator.pipe' - # , include: '#record_types' # , # include: '#row_types' , include: '#type_signature' + # , + # include: '#record_field_declaration' , include: '#comments' ] @@ -878,8 +857,8 @@ purescriptGrammar = patterns: [ include: "#record_types" , - include: '#row_types' - , + # include: '#row_types' + # , name: 'meta.class-constraints' match: concat /\(/, list('classConstraints',/{classConstraint}/,/,/), diff --git a/test/Main.purs b/test/Main.purs index 5b209bd..a8e3c84 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -110,6 +110,8 @@ infixl 7 type Product as :*: infixl 2 Inl as $% infixr 2 Inr as %$ + + -- type class signatures @@ -139,7 +141,7 @@ class Functor v unmount :: ∀ m. v m -> v m -> T Void E --- class with type, breaks highlighting +-- class with row type class RowTypeClass (rl :: RL.RowList Type) where rowListCodec :: forall proxy. proxy rl -> Record ri -> CA.JPropCodec (Record ro) @@ -187,8 +189,6 @@ instance functorA :: Functor A where instance functorA :: Functor A where map = split -- comment - - -- chained instances @@ -209,7 +209,6 @@ else instance showA :: MyShow a where else newtype instance showA :: MyShow a where - -- Records with fields that are reserved words @@ -217,7 +216,8 @@ else newtype instance showA :: MyShow a where type QuotedRow a = ( "A" :: Int -- comment - , "B" :: { nested :: Number } + , "B" :: { nested :: Number, nested2 :: { x :: Maybe (Array Int) } | a } + , "C" :: { | (c :: Int) } {- block comment inside -} , c :: Either (Maybe Bad) Int , d :: Some.Int -- comment @@ -290,8 +290,14 @@ updateRec = rec } --- row type parens are not highlighted as it doesn't seem necessary -type RowLine a = ( name :: String, age :: { nested :: Number } | a ) +type RowLineSpacing a = ( name :: String, age :: { nested :: Number } | a ) + + +--one line row type with no spaces after/before braces +type RowLine a = (names :: Maybe (Array String), age :: { nested :: Number } | a) +type RowLine a = { | } +type RowLine a = { | a } +type RowLine a = { | (a :: Maybe (Array a)) } type RowRecord a @@ -331,6 +337,7 @@ quoted = { "A": "a" -- comment , "B": fn (1 :: Int) x 2 -- typed param in parens , "C": 1 :: Int -- typed param without parens + , "C": (1 :: Maybe (Array Int) ) x (1 :: Int) , a: 2 } @@ -350,6 +357,14 @@ foreign import createSource :: proxy = Proxy :: Proxy Int -- k is Type +-- orphan inline signature +x = 1 + :: + Int +x = {a: 1} :: + { | (a :: Int) } + + -- row type intAtFoo :: forall r. Variant ( foo :: Int | r ) intAtFoo = inj (Proxy :: Proxy "foo") 42 @@ -384,13 +399,17 @@ toStr x = do gotConfig :: AVar { a :: Unit } <- AVar.empty -SomeType :: ( a :: Int ) +-- signatures in ide tooltips +SomeType :: (a :: Int) +-- we may not distinct Type names from type ctors +-- so we highlight as ctors AVar :: Type → Type -addIf true = singleton +-- +-- addIf true = singleton addIf false = const [] @@ -447,6 +466,10 @@ decimal = 41.0 hex = 0xE0 +-- quotes after type def +px = Proxy :: Proxy """fdsfsdf + fdsfdsfsdf + """ multiString = """ From 16c02808a5b221ce7335f828a20891105d31cdc4 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 15 Aug 2022 13:48:53 +0500 Subject: [PATCH 64/82] Improve grammar with better rules (#56) * refactor and update grammar * update recursive parens/row type and misc * make ADT pipe operator * fix types highlight inside ADT * fix row types higlight * fix inner quotes inside triple quotes * fix comments highlight * double colon inlined fixes * infix data ctor --- src/purescript.coffee | 913 +++++++++++++++++++++++++++++------------- test/Main.purs | 356 +++++++++++++--- 2 files changed, 938 insertions(+), 331 deletions(-) diff --git a/src/purescript.coffee b/src/purescript.coffee index 4cf359d..1959ebb 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -61,6 +61,10 @@ purescriptGrammar = list('classConstraint',/{className}|{functionName}/,/\s+/) functionTypeDeclaration: /({functionNameOne})\s*(::|∷)/ + # record field may be quoted string + recordFieldQuoted: /"(?:{className}|{functionNameOne})"/ + recordFieldDeclaration: + /((?:[ ,])(?:{recordFieldQuoted})|{functionNameOne})\s*(::|∷)/ ctorArgs: /// (?: {className} #proper type @@ -74,281 +78,65 @@ purescriptGrammar = indentChar: /[ \t]/ indentBlockEnd: /^(?!\1{indentChar}|{indentChar}*$)/ maybeBirdTrack: /^/ + doubleColon: ///(?: :: | ∷ )/// patterns: [ - name: 'keyword.operator.function.infix' - match: /(`){functionName}(`)/ - captures: - 1: name: 'punctuation.definition.entity' - 2: name: 'punctuation.definition.entity' - ### - In case this regex seems unusual for an infix operator, note - that PureScript allows any ordinary function application (elem 4 (1..10)) - to be rewritten as an infix expression (4 `elem` (1..10)). - ### + include: '#module_declaration' , - name: 'meta.declaration.module' - begin: /^\s*\b(module)(?!')\b/ - end: /(where)/ - beginCaptures: - 1: name: 'keyword.other' - endCaptures: - 1: name: 'keyword.other' - patterns: [ - include: '#comments' - , - include: '#module_name' - , - include: '#module_exports' - , - name: 'invalid' - match: /[a-z]+/ - ] + include: '#module_import' , - name: 'meta.declaration.typeclass' - begin: /^\s*\b(class)(?!')\b/ - end: /\b(where)\b|$/ - beginCaptures: - 1: name: 'storage.type.class' - endCaptures: - 1: name: 'keyword.other' - patterns: [ - include: '#type_signature' - ] + include: '#type_synonym_declaration' , - name: 'meta.declaration.instance' - begin: /^\s*\b(else\s+)?(derive\s+)?(newtype\s+)?(instance)(?!')\b/ - end: /\b(where)\b|$/ - contentName: 'meta.type-signature' - beginCaptures: - 1: name: 'keyword.other' - 2: name: 'keyword.other' - 3: name: 'keyword.other' - 4: name: 'keyword.other' - endCaptures: - 1: name: 'keyword.other' - patterns: [ - include: '#type_signature' - ] + include: '#data_type_declaration' , - name: 'meta.foreign.data' - begin: /^(\s*)(foreign)\s+(import)\s+(data)\s+({classNameOne})/ - end: /{indentBlockEnd}/ - contentName: 'meta.kind-signature' - beginCaptures: - 2: name: 'keyword.other' - 3: name: 'keyword.other' - 4: name: 'keyword.other' - 5: name: 'entity.name.type' - 6: name: 'keyword.other.double-colon' - patterns: [ - include: '#double_colon' - , - include: '#kind_signature' - ] + include: '#typeclass_declaration' , - name: 'meta.foreign' - begin: /^(\s*)(foreign)\s+(import)\s+({functionNameOne})/ - end: /{indentBlockEnd}/ - contentName: 'meta.type-signature' - beginCaptures: - 2: name: 'keyword.other' - 3: name: 'keyword.other' - 4: name: 'entity.name.function' - patterns: [ - include: '#double_colon' - , - include: '#type_signature' - ] + include: '#instance_declaration' , - name: 'meta.import' - begin: /^\s*\b(import)(?!')\b/ - end: /($|(?=--))/ - beginCaptures: - 1: name: 'keyword.other' - patterns: [ - include: '#module_name' - , - include: '#module_exports' - , - match: /\b(as|hiding)\b/ - captures: - 1: name: 'keyword.other' - ] + include: '#derive_declaration' , - name: 'meta.declaration.type.data' - begin: /{maybeBirdTrack}(\s)*(data|newtype)\s+({typeDecl})\s*(?=\=|$)/ - end: /{indentBlockEnd}/ - beginCaptures: - 2: name: 'storage.type.data' - 3: - name: 'meta.type-signature' - patterns: [include: '#type_signature'] - patterns: [ - include: '#comments' - , - match: /=/ - captures: - 0: name: 'keyword.operator.assignment' - , - match: /{ctor}/ - captures: - 1: patterns: [include: '#data_ctor'] - 2: - name: 'meta.type-signature' - patterns: [include: '#type_signature'] - , - match: /\|/ - captures: - 0: name: 'punctuation.separator.pipe' - , - include: '#record_types' - ] + include: '#infix_op_declaration' , - name: 'meta.declaration.type.type' - begin: /{maybeBirdTrack}(\s)*(type)\s+({typeDecl})\s*(?=\=|$)/ - end: /{indentBlockEnd}/ - contentName: 'meta.type-signature' - beginCaptures: - 2: name: 'storage.type.data' - 3: - name: 'meta.type-signature' - patterns: [include: '#type_signature'] - patterns: [ - match: /=/ - captures: - 0: name: 'keyword.operator.assignment' - , - include: '#type_signature' - , - include: '#record_types' - , - include: '#comments' - ] + include: '#foreign_import_data' , - name: 'keyword.other' - match: /^\s*\b(derive|where|data|type|newtype|infix[lr]?|foreign(\s+import)?(\s+data)?)(?!')\b/ + include: '#foreign_import' , - name: 'entity.name.function.typed-hole' - match: /\?(?:{functionNameOne}|{classNameOne})/ + include: '#function_type_declaration' , - name: 'storage.type' - match: /^\s*\b(data|type|newtype)(?!')\b/ + include: '#typed_hole' , - name: 'keyword.control' - # match only if a keyword is not followed by: - # ' - names with prime symbol - # `:` or `=` - records define/update - match: /\b(do|ado|if|then|else|case|of|let|in)(?!('|\s*(:|=)))\b/ + include: '#keywords_orphan' , - name: 'constant.numeric.hex.purescript', - match: '\\b(?(?:[^()]|\\(\\g\\))*)(::|∷)(?(?:[^()]|\\(\\g\\))*)\\)' - captures: - 1: patterns: [include: '$self'] - 2: name: 'keyword.other.double-colon' - 3: {name: 'meta.type-signature', patterns: [include: '#type_signature']} + include: '#string_double_quoted' , - begin: /// - ^ - ( \s* ) - (?: ( :: | ∷ ) ) - /// - beginCaptures: - 2: name: 'keyword.other.double-colon' - end: /// - ^ - (?! \1 {indentChar}* | {indentChar}* $ ) - /// - patterns: [ - include: '#type_signature' - ] + include: '#markup_newline' , - include: '#data_ctor' + include: '#double_colon_parens' , - include: '#comments' + include: '#double_colon_inlined' , - include: '#infix_op' + include: '#double_colon_orphan' + , + include: '#comments' , name: 'keyword.other.arrow' match: /\<-|-\>/ @@ -358,8 +146,493 @@ purescriptGrammar = , name: 'punctuation.separator.comma' match: /,/ + ] repository: + module_declaration: + patterns: [ + name: 'meta.declaration.module' + begin: /^\s*\b(module)(?!')\b/ + end: /(\bwhere\b)/ + beginCaptures: + 1: name: 'keyword.other' + endCaptures: + 1: name: 'keyword.other' + patterns: [ + include: '#comments' + , + include: '#module_name' + , + include: '#module_exports' + , + name: 'invalid' + match: /[a-z]+/ + ] + ] + + function_infix: + patterns: [ + name: 'keyword.operator.function.infix' + match: /(`){functionName}(`)/ + captures: + 1: name: 'punctuation.definition.entity' + 2: name: 'punctuation.definition.entity' + ### + In case this regex seems unusual for an infix operator, note + that PureScript allows any ordinary function application (elem 4 (1..10)) + to be rewritten as an infix expression (4 `elem` (1..10)). + ### + ] + + typeclass_declaration: + patterns: [ + name: 'meta.declaration.typeclass' + begin: /^\s*\b(class)(?!')\b/ + end: /(\bwhere\b|(?=^\S))/ + beginCaptures: + 1: name: 'storage.type.class' + endCaptures: + 1: name: 'keyword.other' + patterns: [ + include: '#type_signature' + + ] + ] + + instance_declaration: + patterns: [ + name: 'meta.declaration.instance' + begin: /^\s*\b(else\s+)?(newtype\s+)?(instance)(?!')\b/ + end: /(\bwhere\b|(?=^\S))/ + contentName: 'meta.type-signature' + beginCaptures: + 1: name: 'keyword.other' + 2: name: 'keyword.other' + 3: name: 'keyword.other' + 4: name: 'keyword.other' + endCaptures: + 1: name: 'keyword.other' + patterns: [ + include: '#type_signature' + ] + ] + + derive_declaration: + patterns: [ + name: 'meta.declaration.derive' + begin: /^\s*\b(derive)(\s+newtype)?(\s+instance)?(?!')\b/ + end: /^(?=\S)/ + contentName: 'meta.type-signature' + beginCaptures: + 1: name: 'keyword.other' + 2: name: 'keyword.other' + 3: name: 'keyword.other' + 4: name: 'keyword.other' + endCaptures: + 1: name: 'keyword.other' + patterns: [ + include: '#type_signature' + ] + ] + + foreign_import_data: + patterns: [ + name: 'meta.foreign.data' + begin: /^(\s*)(foreign)\s+(import)\s+(data)(?:\s+({classNameOne})\s*({doubleColon}))?/ + end: /{indentBlockEnd}/ + contentName: 'meta.kind-signature' + beginCaptures: + 2: name: 'keyword.other' + 3: name: 'keyword.other' + 4: name: 'keyword.other' + 5: name: 'entity.name.type' + 6: name: 'keyword.other.double-colon' + patterns: [ + include: '#comments' + , + include: '#type_signature' + , + include: '#record_types' + ] + ] + + foreign_import: + patterns: [ + name: 'meta.foreign' + begin: /^(\s*)(foreign)\s+(import)\s+({functionNameOne})/ + end: /{indentBlockEnd}/ + contentName: 'meta.type-signature' + beginCaptures: + 2: name: 'keyword.other' + 3: name: 'keyword.other' + 4: name: 'entity.name.function' + patterns: [ + include: '#double_colon' + , + include: '#type_signature' + , + include: '#record_types' + ] + ] + + module_import: + patterns: [ + name: 'meta.import' + begin: /^\s*\b(import)(?!')\b/ + end: /^(?=\S)/ + beginCaptures: + 1: name: 'keyword.other' + patterns: [ + include: '#module_name' + , + include: "#string_double_quoted" + , + include: '#comments' + , + include: '#module_exports' + , + match: /\b(as|hiding)\b/ + captures: + 1: name: 'keyword.other' + ] + ] + + type_kind_signature: + patterns: [ + name: 'meta.declaration.type.data.signature' + begin: /{maybeBirdTrack}(data|newtype)\s+({classNameOne})\s*({doubleColon})/ + end: /(?=^\S)/ + beginCaptures: + 1: name: 'storage.type.data' + 2: + name: 'meta.type-signature' + patterns: [include: '#type_signature'] + 3: name: 'keyword.other.double-colon' + patterns: [ + include: '#comments' + include: '#type_signature' + , + match: /=/ + captures: + 0: name: 'keyword.operator.assignment' + , + match: /{ctor}/ + captures: + 1: patterns: [include: '#data_ctor'] + 2: + name: 'meta.type-signature' + patterns: [include: '#type_signature'] + , + match: /\|/ + captures: + # 0: name: 'punctuation.separator.pipe' + 0: name: 'keyword.operator.pipe' + , + include: '#record_types' + ] + ] + + data_type_declaration: + patterns: [ + name: 'meta.declaration.type.data' + begin: /{maybeBirdTrack}(\s)*(data|newtype)\s+({typeDecl})\s*(?=\=|$)/ + end: /{indentBlockEnd}/ + beginCaptures: + 2: name: 'storage.type.data' + 3: + name: 'meta.type-signature' + patterns: [include: '#type_signature'] + patterns: [ + include: '#comments' + , + match: /=/ + captures: + 0: name: 'keyword.operator.assignment' + # , + match: /(?<=(\||=)\s*)({classNameOne})/ + captures: + 2: patterns: [include: '#data_ctor'] + # 2: + # name: 'meta.type-signature' + # patterns: [include: '#type_signature'] + , + match: /\|/ + captures: + # 0: name: 'punctuation.separator.pipe' + 0: name: 'keyword.operator.pipe' + , + include: '#record_types' + , + include: '#type_signature' + ] + ] + + type_synonym_declaration: + patterns: [ + name: 'meta.declaration.type.type' + begin: /{maybeBirdTrack}(\s)*(type)\s+({typeDecl})\s*(?=\=|$)/ + end: /{indentBlockEnd}/ + contentName: 'meta.type-signature' + beginCaptures: + 2: name: 'storage.type.data' + 3: + name: 'meta.type-signature' + patterns: [include: '#type_signature'] + patterns: [ + match: /=/ + captures: + 0: name: 'keyword.operator.assignment' + , + include: '#type_signature' + , + include: '#record_types' + , + include: '#row_types' + , + include: '#comments' + ] + ] + + infix_op_declaration: + patterns: [ + name: 'meta.infix.declaration' + begin: /^\b(infix[l|r]?)(?!')\b/ + end: /($)/ + beginCaptures: + 1: name: 'keyword.other' + patterns: [ + include: '#comments' + , + include: '#data_ctor' + , + name: 'constant.numeric' + match: /\d+/ + , + match: /({operator})/ + captures: + 1: name: 'keyword.other' + , + match: /\b(type)\s+({className})\b/ + captures: + 1: name: 'keyword.other' + 2: name: 'entity.name.type' + , + match: /\b(as|type)\b/ + captures: + 1: name: 'keyword.other' + ] + ] + + keywords_orphan: + patterns: [ + name: 'keyword.other' + match: /^\s*\b(derive|where|data|type|newtype|foreign(\s+import)?(\s+data)?)(?!')\b/ + ] + + typed_hole: + patterns: [ + name: 'entity.name.function.typed-hole' + match: /\?(?:{functionNameOne}|{classNameOne})/ + ] + + control_keywords: + patterns: [ + name: 'keyword.control' + # match only if a keyword is not followed by: + # ' - names with prime symbol + # `:` or `=` - records define/update + match: /\b(do|ado|if|then|else|case|of|let|in)(?!('|\s*(:|=)))\b/ + ] + + constants_numeric_decimal: + patterns: [ + name: 'constant.numeric.decimal.purescript' + match: '''(?x) + (?(?:[^()]|\\(\\g\\))*)', + '(::|∷)', + '(?(?:[^()]|\\(\\g\\))*)', + '\\)' + ].join('') + captures: + 1: patterns: [ + include: '$self' + ] + 2: name: 'keyword.other.double-colon' + 3: {name: 'meta.type-signature', patterns: [include: '#type_signature']} + ] + + # for inline signatures without parens + double_colon_inlined: + patterns: [ + # signatures in ide tooptips (starts from new line) + # patterns: [ + # match: '^({classNameOne})(?: +)({doubleColon})(.*)' + # captures: + # 1: {name: 'meta.type-signature', patterns: [include: '#type_signature']} + # 2: name: 'keyword.other.double-colon' + # 3: {name: 'meta.type-signature', patterns: [include: '#type_signature']} + # ] + # , + patterns: [ + match: '({doubleColon})(.*)(?=<-|")' + captures: + 1: name: 'keyword.other.double-colon' + 2: {name: 'meta.type-signature', patterns: [ + include: '#type_signature' + + ]} + ] + , + patterns: [ + match: '({doubleColon})(.*)' + captures: + 1: name: 'keyword.other.double-colon' + 2: { + name: 'meta.type-signature' + patterns: [ + include: "#record_types" + include: '#type_signature' + ] + } + + ] + ] + double_colon_orphan: + patterns: [ + begin: /// + ( \s* ) + (?: ( :: | ∷ ) ) + ( \s* ) + $ + /// + beginCaptures: + 2: name: 'keyword.other.double-colon' + end: /// + ^ + (?! \1 {indentChar}* | {indentChar}* $ ) + /// + patterns: [ + include: '#type_signature' + ] + ] + # double_colon_orphan: + # patterns: [ + # begin: /// + # ^ + # ( \s* ) + # (?: ( :: | ∷ ) ) + # /// + # beginCaptures: + # 2: name: 'keyword.other.double-colon' + # end: /// + # ^ + # (?! \1 {indentChar}* | {indentChar}* $ ) + # /// + # patterns: [ + # include: '#type_signature' + # ] + # ] + + markup_newline: + patterns: [ + name: 'markup.other.escape.newline' + match: /\\$/ + ] + + block_comment: patterns: [ name: 'comment.block.documentation' @@ -384,47 +657,32 @@ purescriptGrammar = include: '#block_comment' ] ] - record_types: - patterns: [ - name: 'meta.type.record' - begin: '\\{' - beginCaptures: - 0: - name: 'keyword.operator.type.record.begin.purescript' - end: '\\}' - endCaptures: - 0: - name: 'keyword.operator.type.record.end.purescript' - patterns: [ - name: 'punctuation.separator.comma.purescript' - match: ',' - , - include: '#record_field_declaration' - , - include: '#comments' - ] - ] + comments: patterns: [ - begin: /({maybeBirdTrack}[ \t]+)?(?=--+\s+\|)/ - end: /(?!\G)/ - beginCaptures: - 1: name: 'punctuation.whitespace.comment.leading' - patterns: [ - name: 'comment.line.double-dash.documentation' - begin: /(--+)\s+(\|)/ - end: /\n/ - beginCaptures: - 1: name: 'punctuation.definition.comment' - 2: name: 'punctuation.definition.comment.documentation' - ] - , + # begin: /({maybeBirdTrack}[ \t]+)?(?=--+\s*\|)/ + # #begin: / --/ + # # begin: /({maybeBirdTrack}[ \t]+)?(?=--+)/ + # end: /(?!\G)/ + # beginCaptures: + # 1: name: 'punctuation.whitespace.comment.leading' + # patterns: [ + # name: 'comment.line.double-dash.documentation' + # begin: /(--+)\s*(\|)/ + # # begin: /(--+)/ + # end: /\n/ + # beginCaptures: + # 1: name: 'punctuation.definition.comment' + # 2: name: 'punctuation.definition.comment.documentation' + # ] + # , ### Operators may begin with -- as long as they are not entirely composed of - characters. This means comments can't be immediately followed by an allowable operator character. ### - begin: /({maybeBirdTrack}[ \t]+)?(?=--+(?!{operatorChar}))/ + # begin: /({maybeBirdTrack}[ \t]+)?(?=--+(?!{operatorChar}))/ + begin: /({maybeBirdTrack}[ \t]+)?(?=--+)/ end: /(?!\G)/ beginCaptures: 1: name: 'punctuation.whitespace.comment.leading' @@ -445,9 +703,11 @@ purescriptGrammar = 2: name: 'constant.character.escape.octal' 3: name: 'constant.character.escape.hexadecimal' 4: name: 'constant.character.escape.control' + infix_op: name: 'entity.name.function.infix' match: /{operatorFun}/ + module_exports: name: 'meta.declaration.exports' begin: /\(/ @@ -468,9 +728,11 @@ purescriptGrammar = name: 'meta.other.constructor-list' match: /\(.*?\)/ ] + module_name: name: 'support.other.module' match: /(?:{className}\.)*{className}\.?/ + function_type_declaration: name: 'meta.function.type-declaration' begin: /// @@ -489,24 +751,94 @@ purescriptGrammar = include: '#double_colon' , include: '#type_signature' + , + include: '#record_types' + , + include: '#row_types' ] + + row_types: + patterns: [ + name: 'meta.type.row' + ### + For distinction of row type we use pattern with a space after/before a bracket, + because there doesn't seem to be a correct way to distinguish row type declaration + from another types put in brackets. + ### + # begin: /\((?= \s*({functionNameOne}|"{functionNameOne}"|"{classNameOne}")\s*(::|∷))/ + # end: / \)/ + begin: /\((?=\s*({functionNameOne}|"{functionNameOne}"|"{classNameOne}")\s*(::|∷))/ + end: /(?=^\S)/ + + #applyEndPatternsLast: true + patterns: [ + name: 'punctuation.separator.comma.purescript' + match: ',' + , + include: '#comments' + , + include: '#record_field_declaration' + , + include: '#type_signature' + ] + ] + + record_types: + patterns: [ + name: 'meta.type.record' + # start with {, but not block comment + begin: '\\{(?!-)' + beginCaptures: + 0: + name: 'keyword.operator.type.record.begin.purescript' + end: '\\}' + endCaptures: + 0: + name: 'keyword.operator.type.record.end.purescript' + patterns: [ + name: 'punctuation.separator.comma.purescript' + match: ',' + , + include: '#comments' + + , + include: '#record_field_declaration' + , + include: '#type_signature' + ] + ] + record_field_declaration: name: 'meta.record-field.type-declaration' - begin: /{functionTypeDeclaration}/ - end: /(?={functionTypeDeclaration}|})/ + begin: /{recordFieldDeclaration}/ + # we use end pattern of " )" with space (as as row type ending) + end: /(?={recordFieldDeclaration}|}| \)|{indentBlockEnd})/ + # applyEndPatternsLast: true contentName: 'meta.type-signature' beginCaptures: 1: patterns: [ name: 'entity.other.attribute-name' match: /{functionName}/ + , + # match quoated props + name: 'string.quoted.double' + match: /\"({functionNameOne}|{classNameOne})\"/ ] 2: name: 'keyword.other.double-colon' patterns: [ + include: '#record_types' + # , + # include: '#row_types' + , include: '#type_signature' + # , + # include: '#record_field_declaration' , - include: '#record_types' + include: '#comments' ] + + # this can probalby be removed as we can use type_signature instead kind_signature: patterns: [ name: 'keyword.other.star' @@ -523,6 +855,10 @@ purescriptGrammar = ] type_signature: patterns: [ + include: "#record_types" + , + # include: '#row_types' + # , name: 'meta.class-constraints' match: concat /\(/, list('classConstraints',/{classConstraint}/,/,/), @@ -540,22 +876,27 @@ purescriptGrammar = 4: name: 'keyword.other.big-arrow' , name: 'keyword.other.arrow' - match: /->|→/ + match: /(?|→)/ , name: 'keyword.other.big-arrow' - match: /=>|⇒/ + match: /(?|⇒)/ , name: 'keyword.other.big-arrow-left' match: /<=|⇐/ , name: 'keyword.other.forall' match: /forall|∀/ + , + include: '#string_double_quoted' , include: '#generic_type' , include: '#type_name' , include: '#comments' + , + name: 'keyword.other' + match: /{operator}/ ] type_name: name: 'entity.name.type' diff --git a/test/Main.purs b/test/Main.purs index 1f091b2..a8e3c84 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -1,3 +1,6 @@ +-- start + + {- Test file to visually assess syntax highlighting. -} module Main.App where module Main.App @@ -5,42 +8,121 @@ module Main.App ) where -import Prelude +import Prelude -- can comment +import Prelude hiding (div) import Data.String as String -import Data.String (Pattern) -import Data.String (Pattern(..), split) +-- comment +import Data.String (Pattern) -- comment +import Data.String (Pattern(..), split) as String -- comment + + +-- multi-line import +import Data.String + ( Pattern(..), split -- comment + + ) as String -- comment +import Something (fd) -- Foreign import foreign -foreign import -foreign import data -foreign import calculateInterest :: Number -> Number -foreign import data F :: Type +foreign import --comment +foreign import data --comment +foreign import calculateInterest :: Number -> Number --comment +foreign import data F :: Type -> Type --comment + + +-- import data with record type +foreign import data R :: { prop :: String } + + + +-- line comments with no space between first char +--| some + + + +-- comments with operators after +--# some +--! some + -- Containers -data D a = D1 a | D2 String +data D a = D1 a | D2 (Array a) --comment -type T = { a :: String } +-- +data D1 a + = D1 a + | D2 (Array Some.Type) + {- comment inside -} + | D3 (Either Aff.Error Db.Client) + | D4 + (Array Some.Type) --comment + | D5 String + Int + | S1 (forall f. f String -> f a) + + +type T = { a :: String } --comment type T a = { n :: N a, b :: String } newtype N a = N a --- infix -- TODO: as +data Proxy :: forall k. k -> Type +data Proxy a = Proxy + + +-- newtype with multi-line kind signature +newtype MySub :: + forall k. (k -> Type) -> k -> Type --comment +newtype MySub vnode msg = + MySub (SubRec vnode msg) + + +-- infix operators +-- operators that contain -- within +infixr 0 apply as :--> -- comment as :--> +infixl 0 applyFlipped as <--: + + +--- +data Sum a b + = Inl a + | Inr b --comment + + +data Product a b = Product a b + + +-- Type operators +infixl 6 type Sum as :+: -- comment +infixl 7 type Product as :*: + + +-- Ctor operators +infixl 2 Inl as $% +infixr 2 Inr as %$ + + +-- type class signatures -infixr 0 apply as <| -infixl 0 applyFlipped as |> +class Category :: forall k. (k -> k -> Type) -> Constraint +class Semigroupoid a <= Category a where + identity :: forall t. a t t --- Type class + +-- type class without where +class ListToRow :: forall k. RowList k -> Row k -> Constraint +class ListToRow list row | list -> row class Functor v <= Mountable vnode where @@ -48,11 +130,55 @@ class Functor v <= Mountable vnode where unmount :: ∀ m. v m -> v m -> T Void E -derive instance newtypeMySub :: Newtype (MySub vnode msg) _ +--| orphan keyword +class + + +-- multi-line type def +class Functor v + <= Mountable vnode where --comment + mount :: ∀ m. Element -> T Void (v m) + unmount :: ∀ m. v m -> v m -> T Void E + + +-- class with row type +class RowTypeClass (rl :: RL.RowList Type) where + rowListCodec :: forall proxy. proxy rl -> Record ri -> CA.JPropCodec (Record ro) + + +instance + + +instance listToRowCons + :: ( ListToRow tail tailRow + , Row.Cons label ty tailRow row ) --comment + => ListToRow (Cons label ty tail) row + + +--orphan keyword +derive +derive instance newtypeMySub :: Newtype (MySub vnode msg) _ --comment +derive newtype derive newtype instance semiringScore :: Semiring Score -derive instance genericCmd :: Generic PhonerCmd _ -instance encodeCmd :: EncodeJson PhonerCmd where + +-- instance without name +derive newtype instance Semiring Score + + +-- multi-line derive +derive instance genericCmd + :: Generic PhonerCmd _ + + +-- TODO: multi-line, double-colons +derive instance genericCmd :: + Generic PhonerCmd _ + + +-- multi-line instance +instance encodeCmd + :: EncodeJson PhonerCmd where --comment encodeJson a = genericEncodeJson a @@ -61,8 +187,7 @@ instance functorA :: Functor A where instance functorA :: Functor A where - map = split - + map = split -- comment -- chained instances @@ -75,20 +200,37 @@ instance showString :: MyShow String where myShow s = s +-- chained instances else instance showBoolean :: MyShow Boolean where - myShow true = "true" + myShow true = "true" --comment myShow false = "false" -else instance showA :: MyShow a where +else instance showA :: MyShow a where myShow _ = "Invalid" - else newtype instance showA :: MyShow a where + -- Records with fields that are reserved words -type Rec = - { module :: String - , import :: String +-- quoted row type +type QuotedRow a = + ( "A" :: Int + -- comment + , "B" :: { nested :: Number, nested2 :: { x :: Maybe (Array Int) } | a } + , "C" :: { | (c :: Int) } + {- block comment inside -} + , c :: Either (Maybe Bad) Int + , d :: Some.Int -- comment + , e :: Some.Int -- comment + | a + ) --som + + +data Rec = + { module :: String -- comment + , import :: Either Error (Array String) + , import2 :: Either (Maybe Bad) Good + -- comment , data :: String , newtype :: String } @@ -124,10 +266,10 @@ rec = updateRec = rec { data = "data" - , type ="type" + , type ="type" -- comment , foreign = "foreign" , import = "import" - , infixl = "infixl" + , infixl = "infixl" -- comment , infixr = "infixr" , infix = "infix" , class = "class" @@ -148,47 +290,141 @@ updateRec = rec } --- quoted row type -type QuotedRow = - ( "A" :: Int - , "B" :: Number - ) +type RowLineSpacing a = ( name :: String, age :: { nested :: Number } | a ) + + +--one line row type with no spaces after/before braces +type RowLine a = (names :: Maybe (Array String), age :: { nested :: Number } | a) +type RowLine a = { | } +type RowLine a = { | a } +type RowLine a = { | (a :: Maybe (Array a)) } + + +type RowRecord a + = Record + ( RowLine ( some :: Either Error (Array a) ) + ) + --- quoted record type +type RowRecordLine = Record ( RowLine ( some :: String ) ) + + +type EntireRecordCodec = T "Str" ( a :: String , "B" :: Boolean ) + + +type NotRow a = Either Error (Array Int) + + +-- record with quoted fields type Quoted = - { "A" :: Int + { "A" :: Int -- comment + , a :: Boolean , "B" :: Number + , b :: Int -- comment + , "x" :: SmallCap } --- quoted row type +-- inlined record type def +quoted :: + { "A" :: Int -- comment + , a :: Boolean + , "B" :: Number + , b :: Int -- comment + , "x" :: SmallCap + } quoted = - { "A": "a" - , "B": 1 + { "A": "a" -- comment + , "B": fn (1 :: Int) x 2 -- typed param in parens + , "C": 1 :: Int -- typed param without parens + , "C": (1 :: Maybe (Array Int) ) x (1 :: Int) + , a: 2 } +-- inlined record type def inside foreign import +foreign import createSource :: + String -> + { onOpen :: Effect Unit + , onMessage :: SourceEvent -> Effect Unit + , onError :: SourceError -> Effect Unit + , withCredentials :: Boolean + } -> + Effect EventSource + + +-- proxy +proxy = Proxy :: Proxy Int -- k is Type + + +-- orphan inline signature +x = 1 + :: + Int +x = {a: 1} :: + { | (a :: Int) } + + +-- row type +intAtFoo :: forall r. Variant ( foo :: Int | r ) +intAtFoo = inj (Proxy :: Proxy "foo") 42 + + +-- typed hole +foo :: List Int -> List Int +foo = map ?myHole + + + -- Function, forall --- do, where -toStr :: forall a. a -> Effect Unit +-- infix functions +infixFun = 1 `add` 2 + + +-- function declaration, do, where +toStr :: forall a. Functor a => { a :: a } -> Effect Unit --comment toStr x = do log $ show num - log $ show str + log $ show $ 1 `add` 2 where - num = 1 + -- indented type signature + num :: Int + num = ((something :: Int) :: Int) str = "Str" -addIf true = singleton +-- double_colon_inlined_signature +gotConfig :: AVar { a :: Unit } <- AVar.empty + + +-- signatures in ide tooltips +SomeType :: (a :: Int) + + +-- we may not distinct Type names from type ctors +-- so we highlight as ctors +AVar :: Type → Type + + +-- +-- addIf true = singleton addIf false = const [] --- let in, case of +-- double colon inside quoted string +text = (" ::" + global) + + +-- fn type signature without :: in the same line lacks highlighting +-- it seems to be a bit harder case for proper handling +-- maybe it's also a sign that it is better not to have it in the code :-) fn + -- line orphan signature :: forall a. a -> String fn a = + -- let in, case of let b = "str" in case a of "1" -> b + "1" @@ -212,8 +448,38 @@ case' = if true else "true" --- +-- operators inside type signature ==> type Schema - = { - , widgets :: { id :: Int } ==> Array Widget + = { widgets :: { id :: Int } ==> Array Widget --comment } + + + +-- constants + + +int = 1 + + +decimal = 41.0 + + +hex = 0xE0 + +-- quotes after type def +px = Proxy :: Proxy """fdsfsdf + fdsfdsfsdf + """ + +multiString = """ + + 'text' "WOW" text + +""" + + +multiStringOneLine = """ "WOW" text """ + + +-- after mult-line string +class Foo (a :: Symbol) From 9cd900265fdb29f2d7b8f9b3d23926c4ecd04ba2 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 15 Aug 2022 18:23:33 +0500 Subject: [PATCH 65/82] fix inlined sig with quotes --- src/purescript.coffee | 2 +- test/Main.purs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/purescript.coffee b/src/purescript.coffee index 1959ebb..78391f4 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -567,7 +567,7 @@ purescriptGrammar = # ] # , patterns: [ - match: '({doubleColon})(.*)(?=<-|")' + match: '({doubleColon})(.*)(?=<-|""")' captures: 1: name: 'keyword.other.double-colon' 2: {name: 'meta.type-signature', patterns: [ diff --git a/test/Main.purs b/test/Main.purs index a8e3c84..f102207 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -189,6 +189,8 @@ instance functorA :: Functor A where instance functorA :: Functor A where map = split -- comment + + -- chained instances @@ -209,6 +211,7 @@ else instance showA :: MyShow a where else newtype instance showA :: MyShow a where + -- Records with fields that are reserved words @@ -466,11 +469,20 @@ decimal = 41.0 hex = 0xE0 + +px = Proxy :: Proxy "fdsfsdf" + + -- quotes after type def px = Proxy :: Proxy """fdsfsdf fdsfdsfsdf """ + + +-- quotes after type def + + multiString = """ 'text' "WOW" text From 9e430425e05fa2cd3fa3468173cb929f78f72c12 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 23 Aug 2022 20:27:18 +0500 Subject: [PATCH 66/82] Fix inline signature (triple quotes) --- src/purescript.coffee | 19 ++++++++----------- test/Main.purs | 1 + 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/purescript.coffee b/src/purescript.coffee index 78391f4..2d6008b 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -567,7 +567,7 @@ purescriptGrammar = # ] # , patterns: [ - match: '({doubleColon})(.*)(?=<-|""")' + match: '({doubleColon})(.*)(?=<-)' captures: 1: name: 'keyword.other.double-colon' 2: {name: 'meta.type-signature', patterns: [ @@ -577,17 +577,14 @@ purescriptGrammar = ] , patterns: [ - match: '({doubleColon})(.*)' - captures: + begin: '({doubleColon})' + end: /(?=^\S)/ + beginCaptures: 1: name: 'keyword.other.double-colon' - 2: { - name: 'meta.type-signature' - patterns: [ - include: "#record_types" - include: '#type_signature' - ] - } - + patterns: [ + include: "#record_types" + include: '#type_signature' + ] ] ] double_colon_orphan: diff --git a/test/Main.purs b/test/Main.purs index f102207..a068ad7 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -478,6 +478,7 @@ px = Proxy :: Proxy """fdsfsdf fdsfdsfsdf """ +px = Proxy :: Proxy """fdsfsdffdsfdsfsdf""" -- quotes after type def From 60fe623c95cb4bf24a356717512956742fe4df94 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 25 Dec 2023 09:39:51 +0500 Subject: [PATCH 67/82] Add purs output ignore --- .gitignore | 2 + package-lock.json | 767 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 769 insertions(+) create mode 100644 package-lock.json diff --git a/.gitignore b/.gitignore index ade14b9..495cf9d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ .DS_Store npm-debug.log node_modules +output +.psc-ide-port \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..bb05cae --- /dev/null +++ b/package-lock.json @@ -0,0 +1,767 @@ +{ + "name": "language-purescript", + "version": "0.9.6", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "language-purescript", + "version": "0.9.6", + "license": "MIT", + "devDependencies": { + "coffee-script": "~1.9.0", + "season": "~2.0.0" + }, + "engines": { + "atom": ">= 0.105.0" + } + }, + "node_modules/abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "dev": true + }, + "node_modules/amdefine": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", + "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", + "dev": true, + "optional": true, + "engines": { + "node": ">=0.4.2" + } + }, + "node_modules/async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", + "dev": true + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/coffee-script": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.9.3.tgz", + "integrity": "sha1-WW5ug/z8tnxZZKtw1ES+/wrASsc=", + "deprecated": "CoffeeScript on NPM has moved to \"coffeescript\" (no hyphen)", + "dev": true, + "bin": { + "cake": "bin/cake", + "coffee": "bin/coffee" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/coffee-script-redux": { + "version": "2.0.0-beta8", + "resolved": "https://registry.npmjs.org/coffee-script-redux/-/coffee-script-redux-2.0.0-beta8.tgz", + "integrity": "sha1-D9e4QXNA3Q0zno9v2LS4cWlW6NU=", + "dev": true, + "dependencies": { + "nopt": "~2.1.2", + "StringScanner": "~0.0.3" + }, + "bin": { + "coffee": "bin/coffee" + }, + "engines": { + "node": "0.8.x || 0.10.x" + }, + "optionalDependencies": { + "cscodegen": "git://github.com/michaelficarra/cscodegen.git#73fd7202ac086c26f18c9d56f025b18b3c6f5383", + "escodegen": "~0.0.24", + "esmangle": "~0.0.8", + "source-map": "0.1.11" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "node_modules/cscodegen": { + "version": "0.1.0", + "resolved": "git+ssh://git@github.com/michaelficarra/cscodegen.git#73fd7202ac086c26f18c9d56f025b18b3c6f5383", + "integrity": "sha512-g9WfZJ9PTUMIPoYkSbUw/MVqze8BNSPB+2wkDDhM8SClgHLHUC0ioIRnU1h9N8Zp34uMGIjristDMjUnghYJLQ==", + "dev": true, + "optional": true, + "bin": { + "cake": "bin/cscodegen" + }, + "engines": { + "node": ">=0.6.0" + } + }, + "node_modules/cson-safe": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/cson-safe/-/cson-safe-0.1.1.tgz", + "integrity": "sha1-XFa4BC2UhCqTIg+mWn81f83gwnM=", + "dev": true, + "dependencies": { + "coffee-script-redux": "2.0.0-beta8" + } + }, + "node_modules/escodegen": { + "version": "0.0.28", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-0.0.28.tgz", + "integrity": "sha1-Dk/xcV8yh3XWyrUaxEpAbNer/9M=", + "dev": true, + "optional": true, + "dependencies": { + "esprima": "~1.0.2", + "estraverse": "~1.3.0" + }, + "bin": { + "escodegen": "bin/escodegen.js", + "esgenerate": "bin/esgenerate.js" + }, + "engines": { + "node": ">=0.4.0" + }, + "optionalDependencies": { + "source-map": ">= 0.1.2" + } + }, + "node_modules/escope": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escope/-/escope-1.0.3.tgz", + "integrity": "sha1-dZ3OhJbEJI/sLQyq9BCLzz8af10=", + "dev": true, + "optional": true, + "dependencies": { + "estraverse": "^2.0.0" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/escope/node_modules/estraverse": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-2.0.0.tgz", + "integrity": "sha1-WuRpYyQ2ACBmdMyySgnhZnT83KE=", + "dev": true, + "optional": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/esmangle": { + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/esmangle/-/esmangle-0.0.17.tgz", + "integrity": "sha1-TFyTYHzeXRJ2utOW6DYinbpo2Qw=", + "dev": true, + "optional": true, + "dependencies": { + "escodegen": "~ 0.0.28", + "escope": "~ 1.0.0", + "esprima": "~ 1.0.2", + "esshorten": "~ 0.0.2", + "estraverse": "~ 1.3.2", + "optimist": "*", + "source-map": "~ 0.1.8" + }, + "bin": { + "esmangle": "bin/esmangle.js" + }, + "engines": { + "node": ">=0.6.0" + } + }, + "node_modules/esprima": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.0.4.tgz", + "integrity": "sha1-n1V+CPw7TSbs6d00+Pv0drYlha0=", + "dev": true, + "optional": true, + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/esshorten": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/esshorten/-/esshorten-0.0.2.tgz", + "integrity": "sha1-KKZS8e/UDI4if4xt59vmtWDugSk=", + "dev": true, + "optional": true, + "dependencies": { + "escope": "~ 1.0.0", + "estraverse": "~ 1.2.0" + }, + "engines": { + "node": ">=0.6.0" + } + }, + "node_modules/esshorten/node_modules/estraverse": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.2.0.tgz", + "integrity": "sha1-aj3IpGpdZ2blZoY5/Hgpds5WYP0=", + "dev": true, + "optional": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/estraverse": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.3.2.tgz", + "integrity": "sha1-N8K4k+8T1yPydth41g2FNRUqbEI=", + "dev": true, + "optional": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/fs-plus": { + "version": "2.10.1", + "resolved": "https://registry.npmjs.org/fs-plus/-/fs-plus-2.10.1.tgz", + "integrity": "sha1-MgR4HXhAYR5jZOe2+wWMljJ8WqU=", + "dev": true, + "dependencies": { + "async": "^1.5.2", + "mkdirp": "^0.5.1", + "rimraf": "^2.5.2", + "underscore-plus": "1.x" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "node_modules/glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true + }, + "node_modules/mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "dev": true, + "dependencies": { + "minimist": "^1.2.5" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/nopt": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-2.1.2.tgz", + "integrity": "sha1-bMzZd7gBMqB3MdbozljCyDA8+a8=", + "dev": true, + "dependencies": { + "abbrev": "1" + }, + "bin": { + "nopt": "bin/nopt.js" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/optimist": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.4.0.tgz", + "integrity": "sha1-y47Dfy/jqphky2eidSUOfhliCiU=", + "dev": true, + "dependencies": { + "wordwrap": "~0.0.2" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "dev": true, + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + } + }, + "node_modules/season": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/season/-/season-2.0.0.tgz", + "integrity": "sha1-EKjXvO4an/ji/qcCji7cfJGNK30=", + "dev": true, + "dependencies": { + "cson-safe": "~0.1.1", + "fs-plus": "2.x", + "optimist": "~0.4.0", + "underscore-plus": "1.x" + }, + "bin": { + "csonc": "bin/csonc" + } + }, + "node_modules/source-map": { + "version": "0.1.11", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.11.tgz", + "integrity": "sha1-Lu8v1lp0wXmICuXuaXXZnOIet7Q=", + "dev": true, + "optional": true, + "dependencies": { + "amdefine": ">=0.0.4" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/StringScanner": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/StringScanner/-/StringScanner-0.0.3.tgz", + "integrity": "sha1-vwbs/ckARnEfTmF1VJJDt4zrOKo=", + "dev": true, + "engines": { + "node": ">=0.6" + } + }, + "node_modules/underscore": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.1.tgz", + "integrity": "sha512-hzSoAVtJF+3ZtiFX0VgfFPHEDRm7Y/QPjGyNo4TVdnDTdft3tr8hEkD25a1jC+TjTuE7tkHGKkhwCgs9dgBB2g==", + "dev": true + }, + "node_modules/underscore-plus": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/underscore-plus/-/underscore-plus-1.7.0.tgz", + "integrity": "sha512-A3BEzkeicFLnr+U/Q3EyWwJAQPbA19mtZZ4h+lLq3ttm9kn8WC4R3YpuJZEXmWdLjYP47Zc8aLZm9kwdv+zzvA==", + "dev": true, + "dependencies": { + "underscore": "^1.9.1" + } + }, + "node_modules/wordwrap": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", + "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + } + }, + "dependencies": { + "abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "dev": true + }, + "amdefine": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", + "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", + "dev": true, + "optional": true + }, + "async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", + "dev": true + }, + "balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "coffee-script": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.9.3.tgz", + "integrity": "sha1-WW5ug/z8tnxZZKtw1ES+/wrASsc=", + "dev": true + }, + "coffee-script-redux": { + "version": "2.0.0-beta8", + "resolved": "https://registry.npmjs.org/coffee-script-redux/-/coffee-script-redux-2.0.0-beta8.tgz", + "integrity": "sha1-D9e4QXNA3Q0zno9v2LS4cWlW6NU=", + "dev": true, + "requires": { + "cscodegen": "git://github.com/michaelficarra/cscodegen.git#73fd7202ac086c26f18c9d56f025b18b3c6f5383", + "escodegen": "~0.0.24", + "esmangle": "~0.0.8", + "nopt": "~2.1.2", + "source-map": "0.1.11", + "StringScanner": "~0.0.3" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "cscodegen": { + "version": "git+ssh://git@github.com/michaelficarra/cscodegen.git#73fd7202ac086c26f18c9d56f025b18b3c6f5383", + "integrity": "sha512-g9WfZJ9PTUMIPoYkSbUw/MVqze8BNSPB+2wkDDhM8SClgHLHUC0ioIRnU1h9N8Zp34uMGIjristDMjUnghYJLQ==", + "dev": true, + "from": "cscodegen@git://github.com/michaelficarra/cscodegen.git#73fd7202ac086c26f18c9d56f025b18b3c6f5383", + "optional": true + }, + "cson-safe": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/cson-safe/-/cson-safe-0.1.1.tgz", + "integrity": "sha1-XFa4BC2UhCqTIg+mWn81f83gwnM=", + "dev": true, + "requires": { + "coffee-script-redux": "2.0.0-beta8" + } + }, + "escodegen": { + "version": "0.0.28", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-0.0.28.tgz", + "integrity": "sha1-Dk/xcV8yh3XWyrUaxEpAbNer/9M=", + "dev": true, + "optional": true, + "requires": { + "esprima": "~1.0.2", + "estraverse": "~1.3.0", + "source-map": ">= 0.1.2" + } + }, + "escope": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escope/-/escope-1.0.3.tgz", + "integrity": "sha1-dZ3OhJbEJI/sLQyq9BCLzz8af10=", + "dev": true, + "optional": true, + "requires": { + "estraverse": "^2.0.0" + }, + "dependencies": { + "estraverse": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-2.0.0.tgz", + "integrity": "sha1-WuRpYyQ2ACBmdMyySgnhZnT83KE=", + "dev": true, + "optional": true + } + } + }, + "esmangle": { + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/esmangle/-/esmangle-0.0.17.tgz", + "integrity": "sha1-TFyTYHzeXRJ2utOW6DYinbpo2Qw=", + "dev": true, + "optional": true, + "requires": { + "escodegen": "~ 0.0.28", + "escope": "~ 1.0.0", + "esprima": "~ 1.0.2", + "esshorten": "~ 0.0.2", + "estraverse": "~ 1.3.2", + "optimist": "*", + "source-map": "~ 0.1.8" + } + }, + "esprima": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.0.4.tgz", + "integrity": "sha1-n1V+CPw7TSbs6d00+Pv0drYlha0=", + "dev": true, + "optional": true + }, + "esshorten": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/esshorten/-/esshorten-0.0.2.tgz", + "integrity": "sha1-KKZS8e/UDI4if4xt59vmtWDugSk=", + "dev": true, + "optional": true, + "requires": { + "escope": "~ 1.0.0", + "estraverse": "~ 1.2.0" + }, + "dependencies": { + "estraverse": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.2.0.tgz", + "integrity": "sha1-aj3IpGpdZ2blZoY5/Hgpds5WYP0=", + "dev": true, + "optional": true + } + } + }, + "estraverse": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.3.2.tgz", + "integrity": "sha1-N8K4k+8T1yPydth41g2FNRUqbEI=", + "dev": true, + "optional": true + }, + "fs-plus": { + "version": "2.10.1", + "resolved": "https://registry.npmjs.org/fs-plus/-/fs-plus-2.10.1.tgz", + "integrity": "sha1-MgR4HXhAYR5jZOe2+wWMljJ8WqU=", + "dev": true, + "requires": { + "async": "^1.5.2", + "mkdirp": "^0.5.1", + "rimraf": "^2.5.2", + "underscore-plus": "1.x" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true + }, + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "dev": true, + "requires": { + "minimist": "^1.2.5" + } + }, + "nopt": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-2.1.2.tgz", + "integrity": "sha1-bMzZd7gBMqB3MdbozljCyDA8+a8=", + "dev": true, + "requires": { + "abbrev": "1" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "optimist": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.4.0.tgz", + "integrity": "sha1-y47Dfy/jqphky2eidSUOfhliCiU=", + "dev": true, + "requires": { + "wordwrap": "~0.0.2" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "season": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/season/-/season-2.0.0.tgz", + "integrity": "sha1-EKjXvO4an/ji/qcCji7cfJGNK30=", + "dev": true, + "requires": { + "cson-safe": "~0.1.1", + "fs-plus": "2.x", + "optimist": "~0.4.0", + "underscore-plus": "1.x" + } + }, + "source-map": { + "version": "0.1.11", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.11.tgz", + "integrity": "sha1-Lu8v1lp0wXmICuXuaXXZnOIet7Q=", + "dev": true, + "optional": true, + "requires": { + "amdefine": ">=0.0.4" + } + }, + "StringScanner": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/StringScanner/-/StringScanner-0.0.3.tgz", + "integrity": "sha1-vwbs/ckARnEfTmF1VJJDt4zrOKo=", + "dev": true + }, + "underscore": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.1.tgz", + "integrity": "sha512-hzSoAVtJF+3ZtiFX0VgfFPHEDRm7Y/QPjGyNo4TVdnDTdft3tr8hEkD25a1jC+TjTuE7tkHGKkhwCgs9dgBB2g==", + "dev": true + }, + "underscore-plus": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/underscore-plus/-/underscore-plus-1.7.0.tgz", + "integrity": "sha512-A3BEzkeicFLnr+U/Q3EyWwJAQPbA19mtZZ4h+lLq3ttm9kn8WC4R3YpuJZEXmWdLjYP47Zc8aLZm9kwdv+zzvA==", + "dev": true, + "requires": { + "underscore": "^1.9.1" + } + }, + "wordwrap": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", + "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + } + } +} From a39cbcbb26301d7bf19bece29c9e779f18ba4b92 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 25 Dec 2023 09:41:09 +0500 Subject: [PATCH 68/82] fixes for inline signatures, fixes for infix function --- grammars/purescript.cson | 1038 +++++++++++++++++++++++++------------- src/purescript.coffee | 32 +- test/Main.purs | 27 +- 3 files changed, 727 insertions(+), 370 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 169450d..b05fdd0 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -14,189 +14,637 @@ 'character': '(?:[ -\\[\\]-~]|(\\\\(?: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\\\\\\"\'\\&]))|(\\\\o[0-7]+)|(\\\\x[0-9A-Fa-f]+)|(\\^[A-Z@\\[\\]\\\\\\^_]))' 'classConstraint': '(?:(?:([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*)\\s+)(?:(?(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*|(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)(?:\\s*(?:\\s+)\\s*\\g)?)))' 'functionTypeDeclaration': '([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*(::|∷)' + 'recordFieldQuoted': '"(?:[\\p{Lu}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[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|(?:(?:[\\w()\'→⇒\\[\\],]|->|=>)+\\s*)+))(?:\\s*(?:\\s+)\\s*\\g)?)?))' 'typeDecl': '.+?' 'indentChar': '[ \\t]' 'indentBlockEnd': '^(?!\\1[ \\t]|[ \\t]*$)' 'maybeBirdTrack': '^' + 'doubleColon': '(?:::|∷)' 'patterns': [ { - 'name': 'keyword.operator.function.infix.purescript' - 'match': '(`)(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(`)' - 'captures': - '1': - 'name': 'punctuation.definition.entity.purescript' - '2': - 'name': 'punctuation.definition.entity.purescript' + 'include': '#module_declaration' } { - 'name': 'meta.declaration.module.purescript' - 'begin': '^\\s*\\b(module)(?!\')\\b' - 'end': '(where)' - 'beginCaptures': - '1': - 'name': 'keyword.other.purescript' - 'endCaptures': - '1': - 'name': 'keyword.other.purescript' + 'include': '#module_import' + } + { + 'include': '#type_synonym_declaration' + } + { + 'include': '#data_type_declaration' + } + { + 'include': '#typeclass_declaration' + } + { + 'include': '#instance_declaration' + } + { + 'include': '#derive_declaration' + } + { + 'include': '#infix_op_declaration' + } + { + 'include': '#foreign_import_data' + } + { + 'include': '#foreign_import' + } + { + 'include': '#function_type_declaration' + } + { + 'include': '#typed_hole' + } + { + 'include': '#keywords_orphan' + } + { + 'include': '#control_keywords' + } + { + 'include': '#function_infix' + } + { + 'include': '#data_ctor' + } + { + 'include': '#infix_op' + } + { + 'include': '#constants_numeric_decimal' + } + { + 'include': '#constant_numeric' + } + { + 'include': '#constant_boolean' + } + { + 'include': '#string_triple_quoted' + } + { + 'include': '#string_single_quoted' + } + { + 'include': '#string_double_quoted' + } + { + 'include': '#markup_newline' + } + { + 'include': '#double_colon_parens' + } + { + 'include': '#double_colon_inlined' + } + { + 'include': '#double_colon_orphan' + } + { + 'include': '#comments' + } + { + 'name': 'keyword.other.arrow.purescript' + 'match': '\\<-|-\\>' + } + { + 'name': 'keyword.operator.purescript' + 'match': '[\\p{S}\\p{P}&&[^(),;\\[\\]`{}_"\']]+' + } + { + 'name': 'punctuation.separator.comma.purescript' + 'match': ',' + } +] +'repository': + 'module_declaration': 'patterns': [ { - 'include': '#comments' + 'name': 'meta.declaration.module.purescript' + 'begin': '^\\s*\\b(module)(?!\')\\b' + 'end': '(\\bwhere\\b)' + 'beginCaptures': + '1': + 'name': 'keyword.other.purescript' + 'endCaptures': + '1': + 'name': 'keyword.other.purescript' + 'patterns': [ + { + 'include': '#comments' + } + { + 'include': '#module_name' + } + { + 'include': '#module_exports' + } + { + 'name': 'invalid.purescript' + 'match': '[a-z]+' + } + ] } + ] + 'function_infix': + 'patterns': [ { - 'include': '#module_name' + 'name': 'keyword.operator.function.infix.purescript' + 'match': '(`)(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*.*(`)' + 'captures': + '1': + 'name': 'punctuation.definition.entity.purescript' + '2': + 'name': 'punctuation.definition.entity.purescript' } + ] + 'typeclass_declaration': + 'patterns': [ { - 'include': '#module_exports' + 'name': 'meta.declaration.typeclass.purescript' + 'begin': '^\\s*\\b(class)(?!\')\\b' + 'end': '(\\bwhere\\b|(?=^\\S))' + 'beginCaptures': + '1': + 'name': 'storage.type.class.purescript' + 'endCaptures': + '1': + 'name': 'keyword.other.purescript' + 'patterns': [ + { + 'include': '#type_signature' + } + ] } + ] + 'instance_declaration': + 'patterns': [ { - 'name': 'invalid.purescript' - 'match': '[a-z]+' + 'name': 'meta.declaration.instance.purescript' + 'begin': '^\\s*\\b(else\\s+)?(newtype\\s+)?(instance)(?!\')\\b' + 'end': '(\\bwhere\\b|(?=^\\S))' + 'contentName': 'meta.type-signature.purescript' + 'beginCaptures': + '1': + 'name': 'keyword.other.purescript' + '2': + 'name': 'keyword.other.purescript' + '3': + 'name': 'keyword.other.purescript' + '4': + 'name': 'keyword.other.purescript' + 'endCaptures': + '1': + 'name': 'keyword.other.purescript' + 'patterns': [ + { + 'include': '#type_signature' + } + ] } ] - } - { - 'name': 'meta.declaration.typeclass.purescript' - 'begin': '^\\s*\\b(class)(?!\')\\b' - 'end': '\\b(where)\\b|$' - 'beginCaptures': - '1': - 'name': 'storage.type.class.purescript' - 'endCaptures': - '1': - 'name': 'keyword.other.purescript' + 'derive_declaration': 'patterns': [ { - 'include': '#type_signature' + 'name': 'meta.declaration.derive.purescript' + 'begin': '^\\s*\\b(derive)(\\s+newtype)?(\\s+instance)?(?!\')\\b' + 'end': '^(?=\\S)' + 'contentName': 'meta.type-signature.purescript' + 'beginCaptures': + '1': + 'name': 'keyword.other.purescript' + '2': + 'name': 'keyword.other.purescript' + '3': + 'name': 'keyword.other.purescript' + '4': + 'name': 'keyword.other.purescript' + 'endCaptures': + '1': + 'name': 'keyword.other.purescript' + 'patterns': [ + { + 'include': '#type_signature' + } + ] } ] - } - { - 'name': 'meta.declaration.instance.purescript' - 'begin': '^\\s*\\b(else\\s+)?(derive\\s+)?(newtype\\s+)?(instance)(?!\')\\b' - 'end': '\\b(where)\\b|$' - 'contentName': 'meta.type-signature.purescript' - 'beginCaptures': - '1': - 'name': 'keyword.other.purescript' - '2': - 'name': 'keyword.other.purescript' - '3': - 'name': 'keyword.other.purescript' - '4': - 'name': 'keyword.other.purescript' - 'endCaptures': - '1': - 'name': 'keyword.other.purescript' + 'foreign_import_data': 'patterns': [ { - 'include': '#type_signature' + 'name': 'meta.foreign.data.purescript' + 'begin': '^(\\s*)(foreign)\\s+(import)\\s+(data)(?:\\s+([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*((?:::|∷)))?' + 'end': '^(?!\\1[ \\t]|[ \\t]*$)' + 'contentName': 'meta.kind-signature.purescript' + 'beginCaptures': + '2': + 'name': 'keyword.other.purescript' + '3': + 'name': 'keyword.other.purescript' + '4': + 'name': 'keyword.other.purescript' + '5': + 'name': 'entity.name.type.purescript' + '6': + 'name': 'keyword.other.double-colon.purescript' + 'patterns': [ + { + 'include': '#comments' + } + { + 'include': '#type_signature' + } + { + 'include': '#record_types' + } + ] } ] - } - { - 'name': 'meta.foreign.data.purescript' - 'begin': '^(\\s*)(foreign)\\s+(import)\\s+(data)\\s+([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)' - 'end': '^(?!\\1[ \\t]|[ \\t]*$)' - 'contentName': 'meta.kind-signature.purescript' - 'beginCaptures': - '2': - 'name': 'keyword.other.purescript' - '3': - 'name': 'keyword.other.purescript' - '4': - 'name': 'keyword.other.purescript' - '5': - 'name': 'entity.name.type.purescript' - '6': - 'name': 'keyword.other.double-colon.purescript' + 'foreign_import': 'patterns': [ { - 'include': '#double_colon' + 'name': 'meta.foreign.purescript' + 'begin': '^(\\s*)(foreign)\\s+(import)\\s+([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)' + 'end': '^(?!\\1[ \\t]|[ \\t]*$)' + 'contentName': 'meta.type-signature.purescript' + 'beginCaptures': + '2': + 'name': 'keyword.other.purescript' + '3': + 'name': 'keyword.other.purescript' + '4': + 'name': 'entity.name.function.purescript' + 'patterns': [ + { + 'include': '#double_colon' + } + { + 'include': '#type_signature' + } + { + 'include': '#record_types' + } + ] } + ] + 'module_import': + 'patterns': [ { - 'include': '#kind_signature' + 'name': 'meta.import.purescript' + 'begin': '^\\s*\\b(import)(?!\')\\b' + 'end': '^(?=\\S)' + 'beginCaptures': + '1': + 'name': 'keyword.other.purescript' + 'patterns': [ + { + 'include': '#module_name' + } + { + 'include': '#string_double_quoted' + } + { + 'include': '#comments' + } + { + 'include': '#module_exports' + } + { + 'match': '\\b(as|hiding)\\b' + 'captures': + '1': + 'name': 'keyword.other.purescript' + } + ] } ] - } - { - 'name': 'meta.foreign.purescript' - 'begin': '^(\\s*)(foreign)\\s+(import)\\s+([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)' - 'end': '^(?!\\1[ \\t]|[ \\t]*$)' - 'contentName': 'meta.type-signature.purescript' - 'beginCaptures': - '2': - 'name': 'keyword.other.purescript' - '3': - 'name': 'keyword.other.purescript' - '4': - 'name': 'entity.name.function.purescript' + 'type_kind_signature': 'patterns': [ { - 'include': '#double_colon' + 'name': 'meta.declaration.type.data.signature.purescript' + 'begin': '^(data|newtype)\\s+([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*((?:::|∷))' + 'end': '(?=^\\S)' + 'beginCaptures': + '1': + 'name': 'storage.type.data.purescript' + '2': + 'name': 'meta.type-signature.purescript' + 'patterns': [ + { + 'include': '#type_signature' + } + ] + '3': + 'name': 'keyword.other.double-colon.purescript' + 'patterns': [ + { + 'include': '#type_signature' + } + { + 'match': '=' + 'captures': + '0': + 'name': 'keyword.operator.assignment.purescript' + } + { + 'match': '(?:(?:\\b([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*)\\s+)(?:(?(?:(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*|(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|(?:(?:[\\w()\'→⇒\\[\\],]|->|=>)+\\s*)+))(?:\\s*(?:\\s+)\\s*\\g)?)?))' + 'captures': + '1': + 'patterns': [ + { + 'include': '#data_ctor' + } + ] + '2': + 'name': 'meta.type-signature.purescript' + 'patterns': [ + { + 'include': '#type_signature' + } + ] + } + { + 'match': '\\|' + 'captures': + '0': + 'name': 'keyword.operator.pipe.purescript' + } + { + 'include': '#record_types' + } + ] } + ] + 'data_type_declaration': + 'patterns': [ { - 'include': '#type_signature' + 'name': 'meta.declaration.type.data.purescript' + 'begin': '^(\\s)*(data|newtype)\\s+(.+?)\\s*(?=\\=|$)' + 'end': '^(?!\\1[ \\t]|[ \\t]*$)' + 'beginCaptures': + '2': + 'name': 'storage.type.data.purescript' + '3': + 'name': 'meta.type-signature.purescript' + 'patterns': [ + { + 'include': '#type_signature' + } + ] + 'patterns': [ + { + 'include': '#comments' + } + { + 'match': '(?<=(\\||=)\\s*)([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)' + 'captures': + '2': + 'patterns': [ + { + 'include': '#data_ctor' + } + ] + } + { + 'match': '\\|' + 'captures': + '0': + 'name': 'keyword.operator.pipe.purescript' + } + { + 'include': '#record_types' + } + { + 'include': '#type_signature' + } + ] } ] - } - { - 'name': 'meta.import.purescript' - 'begin': '^\\s*\\b(import)(?!\')\\b' - 'end': '($|(?=--))' - 'beginCaptures': - '1': + 'type_synonym_declaration': + 'patterns': [ + { + 'name': 'meta.declaration.type.type.purescript' + 'begin': '^(\\s)*(type)\\s+(.+?)\\s*(?=\\=|$)' + 'end': '^(?!\\1[ \\t]|[ \\t]*$)' + 'contentName': 'meta.type-signature.purescript' + 'beginCaptures': + '2': + 'name': 'storage.type.data.purescript' + '3': + 'name': 'meta.type-signature.purescript' + 'patterns': [ + { + 'include': '#type_signature' + } + ] + 'patterns': [ + { + 'match': '=' + 'captures': + '0': + 'name': 'keyword.operator.assignment.purescript' + } + { + 'include': '#type_signature' + } + { + 'include': '#record_types' + } + { + 'include': '#row_types' + } + { + 'include': '#comments' + } + ] + } + ] + 'infix_op_declaration': + 'patterns': [ + { + 'name': 'meta.infix.declaration.purescript' + 'begin': '^\\b(infix[l|r]?)(?!\')\\b' + 'end': '($)' + 'beginCaptures': + '1': + 'name': 'keyword.other.purescript' + 'patterns': [ + { + 'include': '#comments' + } + { + 'include': '#data_ctor' + } + { + 'name': 'constant.numeric.purescript' + 'match': ' \\d+ ' + } + { + 'match': '([\\p{S}\\p{P}&&[^(),;\\[\\]`{}_"\']]+)' + 'captures': + '1': + 'name': 'keyword.other.purescript' + } + { + 'match': '\\b(type)\\s+([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*)\\b' + 'captures': + '1': + 'name': 'keyword.other.purescript' + '2': + 'name': 'entity.name.type.purescript' + } + { + 'match': '\\b(as|type)\\b' + 'captures': + '1': + 'name': 'keyword.other.purescript' + } + ] + } + ] + 'keywords_orphan': + 'patterns': [ + { 'name': 'keyword.other.purescript' + 'match': '^\\s*\\b(derive|where|data|type|newtype|foreign(\\s+import)?(\\s+data)?)(?!\')\\b' + } + ] + 'typed_hole': 'patterns': [ { - 'include': '#module_name' + 'name': 'entity.name.function.typed-hole.purescript' + 'match': '\\?(?:[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)' } + ] + 'control_keywords': + 'patterns': [ { - 'include': '#module_exports' + 'name': 'keyword.control.purescript' + 'match': '\\b(do|ado|if|then|else|case|of|let|in)(?!(\'|\\s*(:|=)))\\b' } + ] + 'constants_numeric_decimal': + 'patterns': [ + { + 'name': 'constant.numeric.decimal.purescript' + 'match': '(?x)\n(?(?:(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*|(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|(?:(?:[\\w()\'→⇒\\[\\],]|->|=>)+\\s*)+))(?:\\s*(?:\\s+)\\s*\\g)?)?))' + 'match': '\\((?(?:[^()]|\\(\\g\\))*)(::|∷)(?(?:[^()}]|\\(\\g\\))*)\\)' 'captures': '1': 'patterns': [ { - 'include': '#data_ctor' + 'include': '$self' } ] '2': + 'name': 'keyword.other.double-colon.purescript' + '3': 'name': 'meta.type-signature.purescript' 'patterns': [ { @@ -204,216 +652,66 @@ } ] } - { - 'match': '\\|' - 'captures': - '0': - 'name': 'punctuation.separator.pipe.purescript' - } - { - 'include': '#record_types' - } ] - } - { - 'name': 'meta.declaration.type.type.purescript' - 'begin': '^(\\s)*(type)\\s+(.+?)\\s*(?=\\=|$)' - 'end': '^(?!\\1[ \\t]|[ \\t]*$)' - 'contentName': 'meta.type-signature.purescript' - 'beginCaptures': - '2': - 'name': 'storage.type.data.purescript' - '3': - 'name': 'meta.type-signature.purescript' + 'double_colon_inlined': + 'patterns': [ + { 'patterns': [ { - 'include': '#type_signature' + 'match': '((?:::|∷))(.*)(?=<-| """| })' + 'captures': + '1': + 'name': 'keyword.other.double-colon.purescript' + '2': + 'name': 'meta.type-signature.purescript' + 'patterns': [ + { + 'include': '#type_signature' + } + ] } ] - 'patterns': [ - { - 'match': '=' - 'captures': - '0': - 'name': 'keyword.operator.assignment.purescript' - } - { - 'include': '#type_signature' - } - { - 'include': '#record_types' - } - { - 'include': '#comments' - } - ] - } - { - 'name': 'keyword.other.purescript' - 'match': '^\\s*\\b(derive|where|data|type|newtype|infix[lr]?|foreign(\\s+import)?(\\s+data)?)(?!\')\\b' - } - { - 'name': 'entity.name.function.typed-hole.purescript' - 'match': '\\?(?:[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)' - } - { - 'name': 'storage.type.purescript' - 'match': '^\\s*\\b(data|type|newtype)(?!\')\\b' - } - { - 'name': 'keyword.control.purescript' - 'match': '\\b(do|ado|if|then|else|case|of|let|in)(?!(\'|\\s*(:|=)))\\b' - } - { - 'name': 'constant.numeric.hex.purescript' - 'match': '\\b(?(?:[^()]|\\(\\g\\))*)(::|∷)(?(?:[^()]|\\(\\g\\))*)\\)' - 'captures': - '1': - 'patterns': [ - { - 'include': '$self' - } - ] - '2': - 'name': 'keyword.other.double-colon.purescript' - '3': - 'name': 'meta.type-signature.purescript' + 'double_colon_orphan': + 'patterns': [ + { + 'begin': '(\\s*)(?:(::|∷))(\\s*)$' + 'beginCaptures': + '2': + 'name': 'keyword.other.double-colon.purescript' + 'end': '^(?!\\1[ \\t]*|[ \\t]*$)' 'patterns': [ { 'include': '#type_signature' } ] - } - { - 'begin': '^(\\s*)(?:(::|∷))' - 'beginCaptures': - '2': - 'name': 'keyword.other.double-colon.purescript' - 'end': '^(?!\\1[ \\t]*|[ \\t]*$)' + } + ] + 'markup_newline': 'patterns': [ { - 'include': '#type_signature' + 'name': 'markup.other.escape.newline.purescript' + 'match': '\\\\$' } ] - } - { - 'include': '#data_ctor' - } - { - 'include': '#comments' - } - { - 'include': '#infix_op' - } - { - 'name': 'keyword.other.arrow.purescript' - 'match': '\\<-|-\\>' - } - { - 'name': 'keyword.operator.purescript' - 'match': '[\\p{S}\\p{P}&&[^(),;\\[\\]`{}_"\']]+' - } - { - 'name': 'punctuation.separator.comma.purescript' - 'match': ',' - } -] -'repository': 'block_comment': 'patterns': [ { @@ -448,55 +746,10 @@ ] } ] - 'record_types': - 'patterns': [ - { - 'name': 'meta.type.record.purescript' - 'begin': '\\{' - 'beginCaptures': - '0': - 'name': 'keyword.operator.type.record.begin.purescript' - 'end': '\\}' - 'endCaptures': - '0': - 'name': 'keyword.operator.type.record.end.purescript' - 'patterns': [ - { - 'name': 'punctuation.separator.comma.purescript' - 'match': ',' - } - { - 'include': '#record_field_declaration' - } - { - 'include': '#comments' - } - ] - } - ] 'comments': 'patterns': [ { - 'begin': '(^[ \\t]+)?(?=--+\\s+\\|)' - 'end': '(?!\\G)' - 'beginCaptures': - '1': - 'name': 'punctuation.whitespace.comment.leading.purescript' - 'patterns': [ - { - 'name': 'comment.line.double-dash.documentation.purescript' - 'begin': '(--+)\\s+(\\|)' - 'end': '\\n' - 'beginCaptures': - '1': - 'name': 'punctuation.definition.comment.purescript' - '2': - 'name': 'punctuation.definition.comment.documentation.purescript' - } - ] - } - { - 'begin': '(^[ \\t]+)?(?=--+(?![\\p{S}\\p{P}&&[^(),;\\[\\]`{}_"\']]))' + 'begin': '(^[ \\t]+)?(?=--+)' 'end': '(?!\\G)' 'beginCaptures': '1': @@ -595,6 +848,64 @@ { 'include': '#type_signature' } + { + 'include': '#record_types' + } + { + 'include': '#row_types' + } + ] + } + ] + 'row_types': + 'patterns': [ + { + 'name': 'meta.type.row.purescript' + 'begin': '\\((?=\\s*([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|"[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*"|"[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*")\\s*(::|∷))' + 'end': '(?=^\\S)' + 'patterns': [ + { + 'name': 'punctuation.separator.comma.purescript' + 'match': ',' + } + { + 'include': '#comments' + } + { + 'include': '#record_field_declaration' + } + { + 'include': '#type_signature' + } + ] + } + ] + 'record_types': + 'patterns': [ + { + 'name': 'meta.type.record.purescript' + 'begin': '\\{(?!-)' + 'beginCaptures': + '0': + 'name': 'keyword.operator.type.record.begin.purescript' + 'end': '\\}' + 'endCaptures': + '0': + 'name': 'keyword.operator.type.record.end.purescript' + 'patterns': [ + { + 'name': 'punctuation.separator.comma.purescript' + 'match': ',' + } + { + 'include': '#comments' + } + { + 'include': '#record_field_declaration' + } + { + 'include': '#type_signature' + } ] } ] @@ -602,8 +913,8 @@ 'patterns': [ { 'name': 'meta.record-field.type-declaration.purescript' - 'begin': '([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*(::|∷)' - 'end': '(?=([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*(::|∷)|})' + 'begin': '((?:[ ,])(?:"(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*|[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)")|[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*(::|∷)' + 'end': '(?=((?:[ ,])(?:"(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*|[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)")|[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*(::|∷)|}| \\)|^(?!\\1[ \\t]|[ \\t]*$))' 'contentName': 'meta.type-signature.purescript' 'beginCaptures': '1': @@ -612,15 +923,22 @@ 'name': 'entity.other.attribute-name.purescript' 'match': '(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*' } + { + 'name': 'string.quoted.double.purescript' + 'match': '\\"([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\"' + } ] '2': 'name': 'keyword.other.double-colon.purescript' 'patterns': [ + { + 'include': '#record_types' + } { 'include': '#type_signature' } { - 'include': '#record_types' + 'include': '#comments' } ] } @@ -646,6 +964,9 @@ ] 'type_signature': 'patterns': [ + { + 'include': '#record_types' + } { 'name': 'meta.class-constraints.purescript' 'match': '(?:(?:\\()(?:(?(?:(?:(?:([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*)\\s+)(?:(?(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*|(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)(?:\\s*(?:\\s+)\\s*\\g)?))))(?:\\s*(?:,)\\s*\\g)?))(?:\\))(?:\\s*(=>|<=|⇐|⇒)))' @@ -674,11 +995,11 @@ } { 'name': 'keyword.other.arrow.purescript' - 'match': '->|→' + 'match': '(?|→)' } { 'name': 'keyword.other.big-arrow.purescript' - 'match': '=>|⇒' + 'match': '(?|⇒)' } { 'name': 'keyword.other.big-arrow-left.purescript' @@ -688,6 +1009,9 @@ 'name': 'keyword.other.forall.purescript' 'match': 'forall|∀' } + { + 'include': '#string_double_quoted' + } { 'include': '#generic_type' } @@ -697,6 +1021,10 @@ { 'include': '#comments' } + { + 'name': 'keyword.other.purescript' + 'match': '[\\p{S}\\p{P}&&[^(),;\\[\\]`{}_"\']]+' + } ] 'type_name': 'patterns': [ diff --git a/src/purescript.coffee b/src/purescript.coffee index 2d6008b..75924ac 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -173,7 +173,7 @@ purescriptGrammar = function_infix: patterns: [ name: 'keyword.operator.function.infix' - match: /(`){functionName}(`)/ + match: /(`){functionName}.*(`)/ captures: 1: name: 'punctuation.definition.entity' 2: name: 'punctuation.definition.entity' @@ -406,7 +406,7 @@ purescriptGrammar = include: '#data_ctor' , name: 'constant.numeric' - match: /\d+/ + match: / \d+ / , match: /({operator})/ captures: @@ -543,7 +543,7 @@ purescriptGrammar = '\\(', '(?(?:[^()]|\\(\\g\\))*)', '(::|∷)', - '(?(?:[^()]|\\(\\g\\))*)', + '(?(?:[^()}]|\\(\\g\\))*)', '\\)' ].join('') captures: @@ -567,25 +567,33 @@ purescriptGrammar = # ] # , patterns: [ - match: '({doubleColon})(.*)(?=<-)' + match: '({doubleColon})(.*)(?=<-| """| })' captures: 1: name: 'keyword.other.double-colon' 2: {name: 'meta.type-signature', patterns: [ include: '#type_signature' - ]} ] , patterns: [ - begin: '({doubleColon})' - end: /(?=^\S)/ - beginCaptures: + match: '({doubleColon})(.*)(?!<-| """| })' + captures: 1: name: 'keyword.other.double-colon' - patterns: [ - include: "#record_types" - include: '#type_signature' - ] + 2: {name: 'meta.type-signature', patterns: [ + include: '#type_signature' + ]} ] + # , + # patterns: [ + # begin: '({doubleColon})' + # end: /(?=^\S)/ + # beginCaptures: + # 1: name: 'keyword.other.double-colon' + # patterns: [ + # include: "#record_types" + # include: '#type_signature' + # ] + # ] ] double_colon_orphan: patterns: [ diff --git a/test/Main.purs b/test/Main.purs index a068ad7..1095ad0 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -86,10 +86,10 @@ newtype MySub vnode msg = MySub (SubRec vnode msg) --- infix operators +-- infix operators (with numbers in hame) -- operators that contain -- within -infixr 0 apply as :--> -- comment as :--> -infixl 0 applyFlipped as <--: +infixr 0 apply2 as :--> -- comment as :--> +infixl 0 apply2Flipped as <--: --- @@ -385,6 +385,10 @@ foo = map ?myHole -- infix functions infixFun = 1 `add` 2 +-- infix function with params -- no proper +-- maybe no need because its weird +infixFun = 1 `flip add` 2 + -- function declaration, do, where toStr :: forall a. Functor a => { a :: a } -> Effect Unit --comment @@ -402,6 +406,17 @@ toStr x = do gotConfig :: AVar { a :: Unit } <- AVar.empty +-- no proper for params arrow first +_run + :: forall m + . Functor m + => Config + -> SpecT Aff Unit m Unit + -> m TestEvents + +-- no proper fro colons in string inside parens +x = ("func1 ::") + -- signatures in ide tooltips SomeType :: (a :: Int) @@ -481,6 +496,12 @@ px = Proxy :: Proxy """fdsfsdf px = Proxy :: Proxy """fdsfsdffdsfdsfsdf""" +px = + ({ x = Set.empty :: Set X { x :: Int } } /\ y) + where + y = 1 + + -- quotes after type def From 26934ed3b5f57d8c1519274d48fea4589e8cd459 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 25 Dec 2023 09:47:11 +0500 Subject: [PATCH 69/82] fix foreign import data --- grammars/purescript.cson | 2 +- src/purescript.coffee | 2 +- test/Main.purs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index b05fdd0..7fb008e 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -238,7 +238,7 @@ 'patterns': [ { 'name': 'meta.foreign.data.purescript' - 'begin': '^(\\s*)(foreign)\\s+(import)\\s+(data)(?:\\s+([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*((?:::|∷)))?' + 'begin': '^(\\s*)(foreign)\\s+(import)\\s+(data)\\s(?:\\s+([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*((?:::|∷)))?' 'end': '^(?!\\1[ \\t]|[ \\t]*$)' 'contentName': 'meta.kind-signature.purescript' 'beginCaptures': diff --git a/src/purescript.coffee b/src/purescript.coffee index 75924ac..ca8efd1 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -238,7 +238,7 @@ purescriptGrammar = foreign_import_data: patterns: [ name: 'meta.foreign.data' - begin: /^(\s*)(foreign)\s+(import)\s+(data)(?:\s+({classNameOne})\s*({doubleColon}))?/ + begin: /^(\s*)(foreign)\s+(import)\s+(data)\s(?:\s+({classNameOne})\s*({doubleColon}))?/ end: /{indentBlockEnd}/ contentName: 'meta.kind-signature' beginCaptures: diff --git a/test/Main.purs b/test/Main.purs index 1095ad0..6dc35da 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -31,7 +31,7 @@ foreign import --comment foreign import data --comment foreign import calculateInterest :: Number -> Number --comment foreign import data F :: Type -> Type --comment - +foreign import databaseName :: Db -> Name -- import data with record type foreign import data R :: { prop :: String } From e07f97a2f2ff4d688b3737be420ce4490e114b71 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 27 Dec 2023 16:20:04 +0500 Subject: [PATCH 70/82] fix double colon in quotes, add arrow first signature support --- grammars/purescript.cson | 31 +++++++++++++++++++++++++++- src/purescript.coffee | 33 ++++++++++++++++++++++++++++-- test/Main.purs | 44 ++++++++++++++++++++-------------------- 3 files changed, 83 insertions(+), 25 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 7fb008e..7af54b6 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -57,6 +57,9 @@ { 'include': '#function_type_declaration' } + { + 'include': '#function_type_declaration_arrow_first' + } { 'include': '#typed_hole' } @@ -634,7 +637,7 @@ 'double_colon_parens': 'patterns': [ { - 'match': '\\((?(?:[^()]|\\(\\g\\))*)(::|∷)(?(?:[^()}]|\\(\\g\\))*)\\)' + 'match': '\\((?(?:[^()"]|\\(\\g\\))*)(::|∷)(?(?:[^()"}]|\\(\\g\\))*)\\)' 'captures': '1': 'patterns': [ @@ -857,6 +860,32 @@ ] } ] + 'function_type_declaration_arrow_first': + 'patterns': [ + { + 'name': 'meta.function.type-declaration.purescript' + 'begin': '^(\\s*)(?:\\s(::|∷)(?!.*<-))' + 'end': '^(?!\\1[ \\t]|[ \\t]*$)' + 'contentName': 'meta.type-signature.purescript' + 'beginCaptures': + '2': + 'name': 'keyword.other.double-colon.purescript' + 'patterns': [ + { + 'include': '#double_colon' + } + { + 'include': '#type_signature' + } + { + 'include': '#record_types' + } + { + 'include': '#row_types' + } + ] + } + ] 'row_types': 'patterns': [ { diff --git a/src/purescript.coffee b/src/purescript.coffee index ca8efd1..0fa7f16 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -76,6 +76,10 @@ purescriptGrammar = listMaybe('ctorArgs',/{ctorArgs}/,/\s+/) typeDecl: /.+?/ indentChar: /[ \t]/ + # In indent block here \1 means first captured group, + # + # So if the first capture block is (\s*) then end of indent block will be the line + # with less spaced then in captured block. indentBlockEnd: /^(?!\1{indentChar}|{indentChar}*$)/ maybeBirdTrack: /^/ doubleColon: ///(?: :: | ∷ )/// @@ -102,6 +106,8 @@ purescriptGrammar = include: '#foreign_import' , include: '#function_type_declaration' + , + include: '#function_type_declaration_arrow_first' , include: '#typed_hole' , @@ -541,9 +547,9 @@ purescriptGrammar = # Note recursive regex matching nested parens match: [ '\\(', - '(?(?:[^()]|\\(\\g\\))*)', + '(?(?:[^()"]|\\(\\g\\))*)', '(::|∷)', - '(?(?:[^()}]|\\(\\g\\))*)', + '(?(?:[^()"}]|\\(\\g\\))*)', '\\)' ].join('') captures: @@ -747,7 +753,9 @@ purescriptGrammar = \s* (?: ( :: | ∷ ) (?! .* <- ) ) /// + end: /{indentBlockEnd}/ + # end: /(?=^\S)/ contentName: 'meta.type-signature' beginCaptures: 2: name: 'entity.name.function' @@ -762,6 +770,27 @@ purescriptGrammar = include: '#row_types' ] + function_type_declaration_arrow_first: + name: 'meta.function.type-declaration' + begin: /// + ^ + ( \s* ) + (?: \s ( :: | ∷ ) (?! .* <- ) ) + /// + end: /{indentBlockEnd}/ + # end: /(?=^\S)/ + contentName: 'meta.type-signature' + beginCaptures: + 2: name: 'keyword.other.double-colon' + patterns: [ + include: '#double_colon' + , + include: '#type_signature' + , + include: '#record_types' + , + include: '#row_types' + ] row_types: patterns: [ name: 'meta.type.row' diff --git a/test/Main.purs b/test/Main.purs index 6dc35da..5df18b5 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -340,7 +340,7 @@ quoted = { "A": "a" -- comment , "B": fn (1 :: Int) x 2 -- typed param in parens , "C": 1 :: Int -- typed param without parens - , "C": (1 :: Maybe (Array Int) ) x (1 :: Int) + , "C": (1 :: Maybe (Array Int) ) x (1 :: Proxy "xxx") , a: 2 } @@ -378,15 +378,10 @@ foo :: List Int -> List Int foo = map ?myHole - --- Function, forall - - -- infix functions infixFun = 1 `add` 2 --- infix function with params -- no proper --- maybe no need because its weird +-- infix function with params infixFun = 1 `flip add` 2 @@ -406,16 +401,11 @@ toStr x = do gotConfig :: AVar { a :: Unit } <- AVar.empty --- no proper for params arrow first -_run - :: forall m - . Functor m - => Config - -> SpecT Aff Unit m Unit - -> m TestEvents --- no proper fro colons in string inside parens +-- colons in string inside parens x = ("func1 ::") +-- code coloring after end of quotes +text = (" ::" + global) -- signatures in ide tooltips SomeType :: (a :: Int) @@ -431,13 +421,9 @@ AVar :: Type → Type addIf false = const [] --- double colon inside quoted string -text = (" ::" + global) - - --- fn type signature without :: in the same line lacks highlighting --- it seems to be a bit harder case for proper handling --- maybe it's also a sign that it is better not to have it in the code :-) +-- fn type signature without (arrow first style) :: in the same line lacks +-- highlighting it seems to be a bit harder case for proper handling maybe it's +-- also a sign that it is better not to have it in the code :-) fn -- line orphan signature :: forall a. a -> String @@ -448,6 +434,20 @@ fn a = "1" -> b + "1" _ -> b + a +-- arrow first signature multiline +_run + :: forall m + . Functor m + => Config + -> SpecT Aff Unit m Unit + -> m TestEvents +_run c s = some + where + -- arrow first signature indented + some + :: Int + some = 1 + -- if' fn and if statement with if' = if true then "false" else "true" From e8b9f54e0c8e8821e48a9804a10352e36d474e68 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 8 May 2024 17:27:33 +0500 Subject: [PATCH 71/82] fixes for inline signature in colons --- grammars/purescript.cson | 46 ++++++++++---- src/purescript.coffee | 55 +++++++++------- test/Main.purs | 134 ++++++++++++++++++++------------------- 3 files changed, 132 insertions(+), 103 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 7af54b6..c412799 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -100,13 +100,13 @@ 'include': '#markup_newline' } { - 'include': '#double_colon_parens' + 'include': '#string_double_colon_parens' } { - 'include': '#double_colon_inlined' + 'include': '#double_colon_parens' } { - 'include': '#double_colon_orphan' + 'include': '#double_colon_inlined' } { 'include': '#comments' @@ -585,6 +585,25 @@ 'name': 'punctuation.definition.string.end.purescript' } ] + 'string_double_colon_parens': + 'patterns': [ + { + 'match': '\\((.*?)("(?:[ -\\[\\]-~]|(\\\\(?: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\\\\\\"\'\\&]))|(\\\\o[0-7]+)|(\\\\x[0-9A-Fa-f]+)|(\\^[A-Z@\\[\\]\\\\\\^_]))*(::|∷)((?:[ -\\[\\]-~]|(\\\\(?:NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS|US|SP|DEL|[abfnrtv\\\\\\"\'\\&]))|(\\\\o[0-7]+)|(\\\\x[0-9A-Fa-f]+)|(\\^[A-Z@\\[\\]\\\\\\^_])))*")' + 'captures': + '1': + 'patterns': [ + { + 'include': '$self' + } + ] + '2': + 'patterns': [ + { + 'include': '$self' + } + ] + } + ] 'string_double_quoted': 'patterns': [ { @@ -637,7 +656,7 @@ 'double_colon_parens': 'patterns': [ { - 'match': '\\((?(?:[^()"]|\\(\\g\\))*)(::|∷)(?(?:[^()"}]|\\(\\g\\))*)\\)' + 'match': '\\((?(?:[^()]|\\(\\g\\))*)(::|∷)(?(?:[^()}]|\\(\\g\\))*)\\)' 'captures': '1': 'patterns': [ @@ -661,7 +680,7 @@ { 'patterns': [ { - 'match': '((?:::|∷))(.*)(?=<-| """| })' + 'match': '((?:::|∷))(.*?)(?=<-| """)' 'captures': '1': 'name': 'keyword.other.double-colon.purescript' @@ -678,17 +697,16 @@ { 'patterns': [ { - 'match': '((?:::|∷))(.*)(?!<-| """| })' - 'captures': + 'begin': '((?:::|∷))' + 'end': '(?=^(\\s|\\S))' + 'beginCaptures': '1': 'name': 'keyword.other.double-colon.purescript' - '2': - 'name': 'meta.type-signature.purescript' - 'patterns': [ - { - 'include': '#type_signature' - } - ] + 'patterns': [ + { + 'include': '#type_signature' + } + ] } ] } diff --git a/src/purescript.coffee b/src/purescript.coffee index 0fa7f16..578f443 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -135,12 +135,14 @@ purescriptGrammar = include: '#string_double_quoted' , include: '#markup_newline' + , + include: '#string_double_colon_parens' , include: '#double_colon_parens' , include: '#double_colon_inlined' - , - include: '#double_colon_orphan' + # , + # include: '#double_colon_orphan' , include: '#comments' , @@ -504,7 +506,23 @@ purescriptGrammar = # {character} macro has 4 capture groups, here 3-6 7: name: 'punctuation.definition.string.end' ] - + # To match string that containt double colon as string, to play well with + # #double_colon_parens rule. + string_double_colon_parens: + patterns: [ + match: [ + '\\(', + '(.*?)' + '("{character}*(::|∷)({character})*")', + ].join('') + captures: + 1: patterns: [ + include: '$self' + ] + 2: patterns: [ + include: '$self' + ] + ] string_double_quoted: patterns: [ name: 'string.quoted.double' @@ -547,9 +565,9 @@ purescriptGrammar = # Note recursive regex matching nested parens match: [ '\\(', - '(?(?:[^()"]|\\(\\g\\))*)', + '(?(?:[^()]|\\(\\g\\))*)', '(::|∷)', - '(?(?:[^()"}]|\\(\\g\\))*)', + '(?(?:[^()}]|\\(\\g\\))*)', '\\)' ].join('') captures: @@ -573,7 +591,7 @@ purescriptGrammar = # ] # , patterns: [ - match: '({doubleColon})(.*)(?=<-| """| })' + match: '({doubleColon})(.*?)(?=<-| """)' captures: 1: name: 'keyword.other.double-colon' 2: {name: 'meta.type-signature', patterns: [ @@ -582,24 +600,15 @@ purescriptGrammar = ] , patterns: [ - match: '({doubleColon})(.*)(?!<-| """| })' - captures: + begin: '({doubleColon})' + end: /(?=^(\s|\S))/ + beginCaptures: 1: name: 'keyword.other.double-colon' - 2: {name: 'meta.type-signature', patterns: [ - include: '#type_signature' - ]} + patterns: [ + include: "#record_types" + include: '#type_signature' + ] ] - # , - # patterns: [ - # begin: '({doubleColon})' - # end: /(?=^\S)/ - # beginCaptures: - # 1: name: 'keyword.other.double-colon' - # patterns: [ - # include: "#record_types" - # include: '#type_signature' - # ] - # ] ] double_colon_orphan: patterns: [ @@ -622,9 +631,9 @@ purescriptGrammar = # double_colon_orphan: # patterns: [ # begin: /// - # ^ # ( \s* ) # (?: ( :: | ∷ ) ) + # ( \s* ) # /// # beginCaptures: # 2: name: 'keyword.other.double-colon' diff --git a/test/Main.purs b/test/Main.purs index 5df18b5..187e0e9 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -33,22 +33,20 @@ foreign import calculateInterest :: Number -> Number --comment foreign import data F :: Type -> Type --comment foreign import databaseName :: Db -> Name + -- import data with record type foreign import data R :: { prop :: String } - -- line comments with no space between first char --| some - -- comments with operators after --# some --! some - -- Containers @@ -111,7 +109,6 @@ infixl 2 Inl as $% infixr 2 Inr as %$ - -- type class signatures @@ -190,7 +187,6 @@ instance functorA :: Functor A where map = split -- comment - -- chained instances @@ -211,7 +207,6 @@ else instance showA :: MyShow a where else newtype instance showA :: MyShow a where - -- Records with fields that are reserved words @@ -328,23 +323,6 @@ type Quoted = } --- inlined record type def -quoted :: - { "A" :: Int -- comment - , a :: Boolean - , "B" :: Number - , b :: Int -- comment - , "x" :: SmallCap - } -quoted = - { "A": "a" -- comment - , "B": fn (1 :: Int) x 2 -- typed param in parens - , "C": 1 :: Int -- typed param without parens - , "C": (1 :: Maybe (Array Int) ) x (1 :: Proxy "xxx") - , a: 2 - } - - -- inlined record type def inside foreign import foreign import createSource :: String -> @@ -356,23 +334,6 @@ foreign import createSource :: Effect EventSource --- proxy -proxy = Proxy :: Proxy Int -- k is Type - - --- orphan inline signature -x = 1 - :: - Int -x = {a: 1} :: - { | (a :: Int) } - - --- row type -intAtFoo :: forall r. Variant ( foo :: Int | r ) -intAtFoo = inj (Proxy :: Proxy "foo") 42 - - -- typed hole foo :: List Int -> List Int foo = map ?myHole @@ -381,6 +342,7 @@ foo = map ?myHole -- infix functions infixFun = 1 `add` 2 + -- infix function with params infixFun = 1 `flip add` 2 @@ -401,11 +363,74 @@ toStr x = do gotConfig :: AVar { a :: Unit } <- AVar.empty +-- INLINE SIGNATURES + + +-- inlined record type def +quoted :: + { "A" :: Int -- comment + , a :: Boolean + , "B" :: Number + , b :: Int -- comment + , "x" :: SmallCap + } +quoted = + { "A": "a" -- comment + , "B": fn (1 :: Int) x 2 -- typed param in parens + , "C": 1 :: Proxy "xxx" -- typed param without parens + , "C": (1 :: Maybe (Array Int) ) x (1 :: Proxy "xxx") + , a: 2 + } + + +-- proxy +p :: Proxy "xxx" +p = Proxy + --- colons in string inside parens -x = ("func1 ::") +proxy = Proxy :: Proxy Int -- k is Type + + +-- orphan inline signature +x = 1 + :: + Int +x = {a: 1} :: + { | (a :: Int) } + + +-- row type +-- no proper for ctor variant tag value (double_colon_inlined) +injFoo :: forall r. Variant ( foo :: Int | r ) +injFoo = inj (Proxy :: Proxy "foo") P.ddd Cons (some) + + +-- operators inside type signature ==> +type Schema + = { widgets :: { id :: Int } ==> Array Widget --comment + } + + +px = Proxy :: Proxy "fdsfsdf" + + +-- quotes after type def +px = Proxy :: Proxy """fdsfsdf + fdsfdsfsdf + """ +px = Proxy :: Proxy """fdsfsdffdsfdsfsdf""" +px = + ({ x = Set.empty :: Set X { x :: Int } } /\ X) + where + y = 1 + + +-- double colons in string inside parens +x = ((x :: Int) "func1 ::" <> "func1 ::" <> ((show 1) :: Proxy "x" )) -- code coloring after end of quotes text = (" ::" + global) +text = (""" ::""" + global) + -- signatures in ide tooltips SomeType :: (a :: Int) @@ -434,6 +459,7 @@ fn a = "1" -> b + "1" _ -> b + a + -- arrow first signature multiline _run :: forall m @@ -466,13 +492,6 @@ case' = if true else "true" --- operators inside type signature ==> -type Schema - = { widgets :: { id :: Int } ==> Array Widget --comment - } - - - -- constants @@ -485,23 +504,6 @@ decimal = 41.0 hex = 0xE0 -px = Proxy :: Proxy "fdsfsdf" - - --- quotes after type def -px = Proxy :: Proxy """fdsfsdf - fdsfdsfsdf - """ - -px = Proxy :: Proxy """fdsfsdffdsfdsfsdf""" - - -px = - ({ x = Set.empty :: Set X { x :: Int } } /\ y) - where - y = 1 - - -- quotes after type def From a51982024a3838aad3337815366b7de4e29146c5 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 27 Oct 2024 14:47:12 +0500 Subject: [PATCH 72/82] add no proper case --- test/Main.purs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/Main.purs b/test/Main.purs index 187e0e9..66108d9 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -334,6 +334,13 @@ foreign import createSource :: Effect EventSource +-- no proper after quote +wow'X2 = 1 + +wow_X = 1 + +wow_2 = 1 + -- typed hole foo :: List Int -> List Int foo = map ?myHole @@ -519,3 +526,12 @@ multiStringOneLine = """ "WOW" text """ -- after mult-line string class Foo (a :: Symbol) + + +replaceUnicode :: String -> String +replaceUnicode text = + text + (Pattern ":: forall") (Replacement ":: ∀") + + +--no proper after this \ No newline at end of file From 6c5717f98af48bc4245bed13654be372b83f36a4 Mon Sep 17 00:00:00 2001 From: Steven Levithan Date: Sat, 1 Feb 2025 12:55:24 +0100 Subject: [PATCH 73/82] Use quantifier for list/listMaybe; avoid nested/overlapping recursion --- grammars/purescript.cson | 1050 +++++++++++++++++++++++++------------- src/purescript.coffee | 9 +- 2 files changed, 693 insertions(+), 366 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 169450d..0155018 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -12,191 +12,639 @@ 'operator': '[\\p{S}\\p{P}&&[^(),;\\[\\]`{}_"\']]+' 'operatorFun': '(?:\\((?!--+\\))[\\p{S}\\p{P}&&[^(),;\\[\\]`{}_"\']]+\\))' 'character': '(?:[ -\\[\\]-~]|(\\\\(?: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\\\\\\"\'\\&]))|(\\\\o[0-7]+)|(\\\\x[0-9A-Fa-f]+)|(\\^[A-Z@\\[\\]\\\\\\^_]))' - 'classConstraint': '(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\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*|(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|(?:(?:[\\w()\'→⇒\\[\\],]|->|=>)+\\s*)+)))*)?))' 'typeDecl': '.+?' 'indentChar': '[ \\t]' 'indentBlockEnd': '^(?!\\1[ \\t]|[ \\t]*$)' 'maybeBirdTrack': '^' + 'doubleColon': '(?:::|∷)' 'patterns': [ { - 'name': 'keyword.operator.function.infix.purescript' - 'match': '(`)(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(`)' - 'captures': - '1': - 'name': 'punctuation.definition.entity.purescript' - '2': - 'name': 'punctuation.definition.entity.purescript' + 'include': '#module_declaration' } { - 'name': 'meta.declaration.module.purescript' - 'begin': '^\\s*\\b(module)(?!\')\\b' - 'end': '(where)' - 'beginCaptures': - '1': - 'name': 'keyword.other.purescript' - 'endCaptures': - '1': - 'name': 'keyword.other.purescript' + 'include': '#module_import' + } + { + 'include': '#type_synonym_declaration' + } + { + 'include': '#data_type_declaration' + } + { + 'include': '#typeclass_declaration' + } + { + 'include': '#instance_declaration' + } + { + 'include': '#derive_declaration' + } + { + 'include': '#infix_op_declaration' + } + { + 'include': '#foreign_import_data' + } + { + 'include': '#foreign_import' + } + { + 'include': '#function_type_declaration' + } + { + 'include': '#typed_hole' + } + { + 'include': '#keywords_orphan' + } + { + 'include': '#control_keywords' + } + { + 'include': '#function_infix' + } + { + 'include': '#data_ctor' + } + { + 'include': '#infix_op' + } + { + 'include': '#constants_numeric_decimal' + } + { + 'include': '#constant_numeric' + } + { + 'include': '#constant_boolean' + } + { + 'include': '#string_triple_quoted' + } + { + 'include': '#string_single_quoted' + } + { + 'include': '#string_double_quoted' + } + { + 'include': '#markup_newline' + } + { + 'include': '#double_colon_parens' + } + { + 'include': '#double_colon_inlined' + } + { + 'include': '#double_colon_orphan' + } + { + 'include': '#comments' + } + { + 'name': 'keyword.other.arrow.purescript' + 'match': '\\<-|-\\>' + } + { + 'name': 'keyword.operator.purescript' + 'match': '[\\p{S}\\p{P}&&[^(),;\\[\\]`{}_"\']]+' + } + { + 'name': 'punctuation.separator.comma.purescript' + 'match': ',' + } +] +'repository': + 'module_declaration': 'patterns': [ { - 'include': '#comments' + 'name': 'meta.declaration.module.purescript' + 'begin': '^\\s*\\b(module)(?!\')\\b' + 'end': '(\\bwhere\\b)' + 'beginCaptures': + '1': + 'name': 'keyword.other.purescript' + 'endCaptures': + '1': + 'name': 'keyword.other.purescript' + 'patterns': [ + { + 'include': '#comments' + } + { + 'include': '#module_name' + } + { + 'include': '#module_exports' + } + { + 'name': 'invalid.purescript' + 'match': '[a-z]+' + } + ] } + ] + 'function_infix': + 'patterns': [ { - 'include': '#module_name' + 'name': 'keyword.operator.function.infix.purescript' + 'match': '(`)(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(`)' + 'captures': + '1': + 'name': 'punctuation.definition.entity.purescript' + '2': + 'name': 'punctuation.definition.entity.purescript' } + ] + 'typeclass_declaration': + 'patterns': [ { - 'include': '#module_exports' + 'name': 'meta.declaration.typeclass.purescript' + 'begin': '^\\s*\\b(class)(?!\')\\b' + 'end': '(\\bwhere\\b|(?=^\\S))' + 'beginCaptures': + '1': + 'name': 'storage.type.class.purescript' + 'endCaptures': + '1': + 'name': 'keyword.other.purescript' + 'patterns': [ + { + 'include': '#type_signature' + } + ] } + ] + 'instance_declaration': + 'patterns': [ { - 'name': 'invalid.purescript' - 'match': '[a-z]+' + 'name': 'meta.declaration.instance.purescript' + 'begin': '^\\s*\\b(else\\s+)?(newtype\\s+)?(instance)(?!\')\\b' + 'end': '(\\bwhere\\b|(?=^\\S))' + 'contentName': 'meta.type-signature.purescript' + 'beginCaptures': + '1': + 'name': 'keyword.other.purescript' + '2': + 'name': 'keyword.other.purescript' + '3': + 'name': 'keyword.other.purescript' + '4': + 'name': 'keyword.other.purescript' + 'endCaptures': + '1': + 'name': 'keyword.other.purescript' + 'patterns': [ + { + 'include': '#type_signature' + } + ] } ] - } - { - 'name': 'meta.declaration.typeclass.purescript' - 'begin': '^\\s*\\b(class)(?!\')\\b' - 'end': '\\b(where)\\b|$' - 'beginCaptures': - '1': - 'name': 'storage.type.class.purescript' - 'endCaptures': - '1': - 'name': 'keyword.other.purescript' + 'derive_declaration': 'patterns': [ { - 'include': '#type_signature' + 'name': 'meta.declaration.derive.purescript' + 'begin': '^\\s*\\b(derive)(\\s+newtype)?(\\s+instance)?(?!\')\\b' + 'end': '^(?=\\S)' + 'contentName': 'meta.type-signature.purescript' + 'beginCaptures': + '1': + 'name': 'keyword.other.purescript' + '2': + 'name': 'keyword.other.purescript' + '3': + 'name': 'keyword.other.purescript' + '4': + 'name': 'keyword.other.purescript' + 'endCaptures': + '1': + 'name': 'keyword.other.purescript' + 'patterns': [ + { + 'include': '#type_signature' + } + ] } ] - } - { - 'name': 'meta.declaration.instance.purescript' - 'begin': '^\\s*\\b(else\\s+)?(derive\\s+)?(newtype\\s+)?(instance)(?!\')\\b' - 'end': '\\b(where)\\b|$' - 'contentName': 'meta.type-signature.purescript' - 'beginCaptures': - '1': - 'name': 'keyword.other.purescript' - '2': - 'name': 'keyword.other.purescript' - '3': - 'name': 'keyword.other.purescript' - '4': - 'name': 'keyword.other.purescript' - 'endCaptures': - '1': - 'name': 'keyword.other.purescript' + 'foreign_import_data': 'patterns': [ { - 'include': '#type_signature' + 'name': 'meta.foreign.data.purescript' + 'begin': '^(\\s*)(foreign)\\s+(import)\\s+(data)(?:\\s+([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*((?:::|∷)))?' + 'end': '^(?!\\1[ \\t]|[ \\t]*$)' + 'contentName': 'meta.kind-signature.purescript' + 'beginCaptures': + '2': + 'name': 'keyword.other.purescript' + '3': + 'name': 'keyword.other.purescript' + '4': + 'name': 'keyword.other.purescript' + '5': + 'name': 'entity.name.type.purescript' + '6': + 'name': 'keyword.other.double-colon.purescript' + 'patterns': [ + { + 'include': '#comments' + } + { + 'include': '#type_signature' + } + { + 'include': '#record_types' + } + ] } ] - } - { - 'name': 'meta.foreign.data.purescript' - 'begin': '^(\\s*)(foreign)\\s+(import)\\s+(data)\\s+([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)' - 'end': '^(?!\\1[ \\t]|[ \\t]*$)' - 'contentName': 'meta.kind-signature.purescript' - 'beginCaptures': - '2': - 'name': 'keyword.other.purescript' - '3': - 'name': 'keyword.other.purescript' - '4': - 'name': 'keyword.other.purescript' - '5': - 'name': 'entity.name.type.purescript' - '6': - 'name': 'keyword.other.double-colon.purescript' + 'foreign_import': + 'patterns': [ + { + 'name': 'meta.foreign.purescript' + 'begin': '^(\\s*)(foreign)\\s+(import)\\s+([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)' + 'end': '^(?!\\1[ \\t]|[ \\t]*$)' + 'contentName': 'meta.type-signature.purescript' + 'beginCaptures': + '2': + 'name': 'keyword.other.purescript' + '3': + 'name': 'keyword.other.purescript' + '4': + 'name': 'entity.name.function.purescript' + 'patterns': [ + { + 'include': '#double_colon' + } + { + 'include': '#type_signature' + } + { + 'include': '#record_types' + } + ] + } + ] + 'module_import': 'patterns': [ { - 'include': '#double_colon' + 'name': 'meta.import.purescript' + 'begin': '^\\s*\\b(import)(?!\')\\b' + 'end': '^(?=\\S)' + 'beginCaptures': + '1': + 'name': 'keyword.other.purescript' + 'patterns': [ + { + 'include': '#module_name' + } + { + 'include': '#string_double_quoted' + } + { + 'include': '#comments' + } + { + 'include': '#module_exports' + } + { + 'match': '\\b(as|hiding)\\b' + 'captures': + '1': + 'name': 'keyword.other.purescript' + } + ] } + ] + 'type_kind_signature': + 'patterns': [ { - 'include': '#kind_signature' + 'name': 'meta.declaration.type.data.signature.purescript' + 'begin': '^(data|newtype)\\s+([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*((?:::|∷))' + 'end': '(?=^\\S)' + 'beginCaptures': + '1': + 'name': 'storage.type.data.purescript' + '2': + 'name': 'meta.type-signature.purescript' + 'patterns': [ + { + 'include': '#type_signature' + } + ] + '3': + 'name': 'keyword.other.double-colon.purescript' + 'patterns': [ + { + 'include': '#type_signature' + } + { + 'match': '=' + 'captures': + '0': + 'name': 'keyword.operator.assignment.purescript' + } + { + 'match': '(?:(?:\\b([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*)\\s+)(?:(?(?:(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*|(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|(?:(?:[\\w()\'→⇒\\[\\],]|->|=>)+\\s*)+))(?:\\s*(?:\\s+)\\s*(?:(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*|(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|(?:(?:[\\w()\'→⇒\\[\\],]|->|=>)+\\s*)+)))*)?))' + 'captures': + '1': + 'patterns': [ + { + 'include': '#data_ctor' + } + ] + '2': + 'name': 'meta.type-signature.purescript' + 'patterns': [ + { + 'include': '#type_signature' + } + ] + } + { + 'match': '\\|' + 'captures': + '0': + 'name': 'keyword.operator.pipe.purescript' + } + { + 'include': '#record_types' + } + ] } ] - } - { - 'name': 'meta.foreign.purescript' - 'begin': '^(\\s*)(foreign)\\s+(import)\\s+([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)' - 'end': '^(?!\\1[ \\t]|[ \\t]*$)' - 'contentName': 'meta.type-signature.purescript' - 'beginCaptures': - '2': - 'name': 'keyword.other.purescript' - '3': - 'name': 'keyword.other.purescript' - '4': - 'name': 'entity.name.function.purescript' + 'data_type_declaration': + 'patterns': [ + { + 'name': 'meta.declaration.type.data.purescript' + 'begin': '^(\\s)*(data|newtype)\\s+(.+?)\\s*(?=\\=|$)' + 'end': '^(?!\\1[ \\t]|[ \\t]*$)' + 'beginCaptures': + '2': + 'name': 'storage.type.data.purescript' + '3': + 'name': 'meta.type-signature.purescript' + 'patterns': [ + { + 'include': '#type_signature' + } + ] + 'patterns': [ + { + 'include': '#comments' + } + { + 'match': '(?<=(\\||=)\\s*)([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)' + 'captures': + '2': + 'patterns': [ + { + 'include': '#data_ctor' + } + ] + } + { + 'match': '\\|' + 'captures': + '0': + 'name': 'keyword.operator.pipe.purescript' + } + { + 'include': '#record_types' + } + { + 'include': '#type_signature' + } + ] + } + ] + 'type_synonym_declaration': 'patterns': [ { - 'include': '#double_colon' + 'name': 'meta.declaration.type.type.purescript' + 'begin': '^(\\s)*(type)\\s+(.+?)\\s*(?=\\=|$)' + 'end': '^(?!\\1[ \\t]|[ \\t]*$)' + 'contentName': 'meta.type-signature.purescript' + 'beginCaptures': + '2': + 'name': 'storage.type.data.purescript' + '3': + 'name': 'meta.type-signature.purescript' + 'patterns': [ + { + 'include': '#type_signature' + } + ] + 'patterns': [ + { + 'match': '=' + 'captures': + '0': + 'name': 'keyword.operator.assignment.purescript' + } + { + 'include': '#type_signature' + } + { + 'include': '#record_types' + } + { + 'include': '#row_types' + } + { + 'include': '#comments' + } + ] } + ] + 'infix_op_declaration': + 'patterns': [ { - 'include': '#type_signature' + 'name': 'meta.infix.declaration.purescript' + 'begin': '^\\b(infix[l|r]?)(?!\')\\b' + 'end': '($)' + 'beginCaptures': + '1': + 'name': 'keyword.other.purescript' + 'patterns': [ + { + 'include': '#comments' + } + { + 'include': '#data_ctor' + } + { + 'name': 'constant.numeric.purescript' + 'match': '\\d+' + } + { + 'match': '([\\p{S}\\p{P}&&[^(),;\\[\\]`{}_"\']]+)' + 'captures': + '1': + 'name': 'keyword.other.purescript' + } + { + 'match': '\\b(type)\\s+([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*)\\b' + 'captures': + '1': + 'name': 'keyword.other.purescript' + '2': + 'name': 'entity.name.type.purescript' + } + { + 'match': '\\b(as|type)\\b' + 'captures': + '1': + 'name': 'keyword.other.purescript' + } + ] } ] - } - { - 'name': 'meta.import.purescript' - 'begin': '^\\s*\\b(import)(?!\')\\b' - 'end': '($|(?=--))' - 'beginCaptures': - '1': + 'keywords_orphan': + 'patterns': [ + { 'name': 'keyword.other.purescript' + 'match': '^\\s*\\b(derive|where|data|type|newtype|foreign(\\s+import)?(\\s+data)?)(?!\')\\b' + } + ] + 'typed_hole': + 'patterns': [ + { + 'name': 'entity.name.function.typed-hole.purescript' + 'match': '\\?(?:[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)' + } + ] + 'control_keywords': 'patterns': [ { - 'include': '#module_name' + 'name': 'keyword.control.purescript' + 'match': '\\b(do|ado|if|then|else|case|of|let|in)(?!(\'|\\s*(:|=)))\\b' } + ] + 'constants_numeric_decimal': + 'patterns': [ { - 'include': '#module_exports' + 'name': 'constant.numeric.decimal.purescript' + 'match': '(?x)\n(?(?:(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*|(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|(?:(?:[\\w()\'→⇒\\[\\],]|->|=>)+\\s*)+))(?:\\s*(?:\\s+)\\s*\\g)?)?))' + 'match': '\\((?(?:[^()]|\\(\\g\\))*)(::|∷)(?(?:[^()]|\\(\\g\\))*)\\)' 'captures': '1': 'patterns': [ { - 'include': '#data_ctor' + 'include': '$self' } ] '2': + 'name': 'keyword.other.double-colon.purescript' + '3': 'name': 'meta.type-signature.purescript' 'patterns': [ { @@ -204,216 +652,66 @@ } ] } - { - 'match': '\\|' - 'captures': - '0': - 'name': 'punctuation.separator.pipe.purescript' - } - { - 'include': '#record_types' - } ] - } - { - 'name': 'meta.declaration.type.type.purescript' - 'begin': '^(\\s)*(type)\\s+(.+?)\\s*(?=\\=|$)' - 'end': '^(?!\\1[ \\t]|[ \\t]*$)' - 'contentName': 'meta.type-signature.purescript' - 'beginCaptures': - '2': - 'name': 'storage.type.data.purescript' - '3': - 'name': 'meta.type-signature.purescript' + 'double_colon_inlined': + 'patterns': [ + { 'patterns': [ { - 'include': '#type_signature' + 'match': '((?:::|∷))(.*)(?=<-|""")' + 'captures': + '1': + 'name': 'keyword.other.double-colon.purescript' + '2': + 'name': 'meta.type-signature.purescript' + 'patterns': [ + { + 'include': '#type_signature' + } + ] } ] - 'patterns': [ - { - 'match': '=' - 'captures': - '0': - 'name': 'keyword.operator.assignment.purescript' - } - { - 'include': '#type_signature' - } - { - 'include': '#record_types' - } - { - 'include': '#comments' - } - ] - } - { - 'name': 'keyword.other.purescript' - 'match': '^\\s*\\b(derive|where|data|type|newtype|infix[lr]?|foreign(\\s+import)?(\\s+data)?)(?!\')\\b' - } - { - 'name': 'entity.name.function.typed-hole.purescript' - 'match': '\\?(?:[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)' - } - { - 'name': 'storage.type.purescript' - 'match': '^\\s*\\b(data|type|newtype)(?!\')\\b' - } - { - 'name': 'keyword.control.purescript' - 'match': '\\b(do|ado|if|then|else|case|of|let|in)(?!(\'|\\s*(:|=)))\\b' - } - { - 'name': 'constant.numeric.hex.purescript' - 'match': '\\b(?(?:[^()]|\\(\\g\\))*)(::|∷)(?(?:[^()]|\\(\\g\\))*)\\)' - 'captures': - '1': - 'patterns': [ - { - 'include': '$self' - } - ] - '2': - 'name': 'keyword.other.double-colon.purescript' - '3': - 'name': 'meta.type-signature.purescript' + 'double_colon_orphan': + 'patterns': [ + { + 'begin': '(\\s*)(?:(::|∷))(\\s*)$' + 'beginCaptures': + '2': + 'name': 'keyword.other.double-colon.purescript' + 'end': '^(?!\\1[ \\t]*|[ \\t]*$)' 'patterns': [ { 'include': '#type_signature' } ] - } - { - 'begin': '^(\\s*)(?:(::|∷))' - 'beginCaptures': - '2': - 'name': 'keyword.other.double-colon.purescript' - 'end': '^(?!\\1[ \\t]*|[ \\t]*$)' + } + ] + 'markup_newline': 'patterns': [ { - 'include': '#type_signature' + 'name': 'markup.other.escape.newline.purescript' + 'match': '\\\\$' } ] - } - { - 'include': '#data_ctor' - } - { - 'include': '#comments' - } - { - 'include': '#infix_op' - } - { - 'name': 'keyword.other.arrow.purescript' - 'match': '\\<-|-\\>' - } - { - 'name': 'keyword.operator.purescript' - 'match': '[\\p{S}\\p{P}&&[^(),;\\[\\]`{}_"\']]+' - } - { - 'name': 'punctuation.separator.comma.purescript' - 'match': ',' - } -] -'repository': 'block_comment': 'patterns': [ { @@ -448,55 +746,10 @@ ] } ] - 'record_types': - 'patterns': [ - { - 'name': 'meta.type.record.purescript' - 'begin': '\\{' - 'beginCaptures': - '0': - 'name': 'keyword.operator.type.record.begin.purescript' - 'end': '\\}' - 'endCaptures': - '0': - 'name': 'keyword.operator.type.record.end.purescript' - 'patterns': [ - { - 'name': 'punctuation.separator.comma.purescript' - 'match': ',' - } - { - 'include': '#record_field_declaration' - } - { - 'include': '#comments' - } - ] - } - ] 'comments': 'patterns': [ { - 'begin': '(^[ \\t]+)?(?=--+\\s+\\|)' - 'end': '(?!\\G)' - 'beginCaptures': - '1': - 'name': 'punctuation.whitespace.comment.leading.purescript' - 'patterns': [ - { - 'name': 'comment.line.double-dash.documentation.purescript' - 'begin': '(--+)\\s+(\\|)' - 'end': '\\n' - 'beginCaptures': - '1': - 'name': 'punctuation.definition.comment.purescript' - '2': - 'name': 'punctuation.definition.comment.documentation.purescript' - } - ] - } - { - 'begin': '(^[ \\t]+)?(?=--+(?![\\p{S}\\p{P}&&[^(),;\\[\\]`{}_"\']]))' + 'begin': '(^[ \\t]+)?(?=--+)' 'end': '(?!\\G)' 'beginCaptures': '1': @@ -595,6 +848,64 @@ { 'include': '#type_signature' } + { + 'include': '#record_types' + } + { + 'include': '#row_types' + } + ] + } + ] + 'row_types': + 'patterns': [ + { + 'name': 'meta.type.row.purescript' + 'begin': '\\((?=\\s*([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|"[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*"|"[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*")\\s*(::|∷))' + 'end': '(?=^\\S)' + 'patterns': [ + { + 'name': 'punctuation.separator.comma.purescript' + 'match': ',' + } + { + 'include': '#comments' + } + { + 'include': '#record_field_declaration' + } + { + 'include': '#type_signature' + } + ] + } + ] + 'record_types': + 'patterns': [ + { + 'name': 'meta.type.record.purescript' + 'begin': '\\{(?!-)' + 'beginCaptures': + '0': + 'name': 'keyword.operator.type.record.begin.purescript' + 'end': '\\}' + 'endCaptures': + '0': + 'name': 'keyword.operator.type.record.end.purescript' + 'patterns': [ + { + 'name': 'punctuation.separator.comma.purescript' + 'match': ',' + } + { + 'include': '#comments' + } + { + 'include': '#record_field_declaration' + } + { + 'include': '#type_signature' + } ] } ] @@ -602,8 +913,8 @@ 'patterns': [ { 'name': 'meta.record-field.type-declaration.purescript' - 'begin': '([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*(::|∷)' - 'end': '(?=([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*(::|∷)|})' + 'begin': '((?:[ ,])(?:"(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*|[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)")|[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*(::|∷)' + 'end': '(?=((?:[ ,])(?:"(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*|[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)")|[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*(::|∷)|}| \\)|^(?!\\1[ \\t]|[ \\t]*$))' 'contentName': 'meta.type-signature.purescript' 'beginCaptures': '1': @@ -612,15 +923,22 @@ 'name': 'entity.other.attribute-name.purescript' 'match': '(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*' } + { + 'name': 'string.quoted.double.purescript' + 'match': '\\"([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*|[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\"' + } ] '2': 'name': 'keyword.other.double-colon.purescript' 'patterns': [ + { + 'include': '#record_types' + } { 'include': '#type_signature' } { - 'include': '#record_types' + 'include': '#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{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)(?:\\s*(?:\\s+)\\s*(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*|(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*))*))))\\s*(=>|<=|⇐|⇒)' 'captures': '1': 'patterns': [ @@ -674,11 +995,11 @@ } { 'name': 'keyword.other.arrow.purescript' - 'match': '->|→' + 'match': '(?|→)' } { 'name': 'keyword.other.big-arrow.purescript' - 'match': '=>|⇒' + 'match': '(?|⇒)' } { 'name': 'keyword.other.big-arrow-left.purescript' @@ -688,6 +1009,9 @@ 'name': 'keyword.other.forall.purescript' 'match': 'forall|∀' } + { + 'include': '#string_double_quoted' + } { 'include': '#generic_type' } @@ -697,6 +1021,10 @@ { 'include': '#comments' } + { + 'name': 'keyword.other.purescript' + 'match': '[\\p{S}\\p{P}&&[^(),;\\[\\]`{}_"\']]+' + } ] 'type_name': 'patterns': [ @@ -730,7 +1058,7 @@ 'patterns': [ { 'name': 'meta.class-constraint.purescript' - 'match': '(?:(?:([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*)\\s+)(?:(?(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{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escript.coffee index 78391f4..b7c7a9a 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -10,12 +10,10 @@ toString = (rx) -> rx list = (item,s,sep) -> - #recursive regexp, caution advised - "(?<#{item}>(?:#{toString s})(?:\\s*(?:#{toString sep})\\s*\\g<#{item}>)?)" + "(?<#{item}>(?:#{toString s})(?:\\s*(?:#{toString sep})\\s*(?:#{toString s}))*)" listMaybe = (item,s,sep) -> - #recursive regexp, caution advised - "(?<#{item}>(?:#{toString s})(?:\\s*(?:#{toString sep})\\s*\\g<#{item}>)?)?" + "(?<#{item}>(?:#{toString s})(?:\\s*(?:#{toString sep})\\s*(?:#{toString s}))*)?" concat = (list...) -> r=''.concat (list.map (i) -> "(?:#{toString i})")... @@ -866,7 +864,8 @@ purescriptGrammar = captures: 1: patterns: [{include: '#class_constraint'}] #2,3 are from classConstraint - 4: name: 'keyword.other.big-arrow' + #4,5 are from classConstraint being repeated * times + 6: name: 'keyword.other.big-arrow' , name: 'meta.class-constraints' match: /({classConstraint})\s*(=>|<=|⇐|⇒)/ From 63dcd42069b57fdbbb9ea25db45e877325b63851 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 7 Mar 2025 16:37:01 +0500 Subject: [PATCH 74/82] Updates from PR #63 in upstream --- grammars/purescript.cson | 14 ++++++++------ src/purescript.coffee | 8 ++++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index c412799..f980d1f 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -12,12 +12,12 @@ 'operator': '[\\p{S}\\p{P}&&[^(),;\\[\\]`{}_"\']]+' 'operatorFun': '(?:\\((?!--+\\))[\\p{S}\\p{P}&&[^(),;\\[\\]`{}_"\']]+\\))' 'character': '(?:[ -\\[\\]-~]|(\\\\(?:NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB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Nd}\']*)*|(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)(?:\\s*(?:\\s+)\\s*(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*|(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*))*)))' 'captures': '1': 'patterns': [ diff --git a/src/purescript.coffee b/src/purescript.coffee index 578f443..9c5de99 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -11,11 +11,13 @@ toString = (rx) -> list = (item,s,sep) -> #recursive regexp, caution advised - "(?<#{item}>(?:#{toString s})(?:\\s*(?:#{toString sep})\\s*\\g<#{item}>)?)" + # "(?<#{item}>(?:#{toString s})(?:\\s*(?:#{toString sep})\\s*\\g<#{item}>)?)" + "(?<#{item}>(?:#{toString s})(?:\\s*(?:#{toString sep})\\s*(?:#{toString s}))*)" listMaybe = (item,s,sep) -> #recursive regexp, caution advised - "(?<#{item}>(?:#{toString s})(?:\\s*(?:#{toString sep})\\s*\\g<#{item}>)?)?" + # "(?<#{item}>(?:#{toString s})(?:\\s*(?:#{toString sep})\\s*\\g<#{item}>)?)?" + "(?<#{item}>(?:#{toString s})(?:\\s*(?:#{toString sep})\\s*(?:#{toString s}))*)?" concat = (list...) -> r=''.concat (list.map (i) -> "(?:#{toString i})")... @@ -910,6 +912,8 @@ purescriptGrammar = 1: patterns: [{include: '#class_constraint'}] #2,3 are from classConstraint 4: name: 'keyword.other.big-arrow' + #4,5 are from classConstraint being repeated * times + 6: name: 'keyword.other.big-arrow' , name: 'meta.class-constraints' match: /({classConstraint})\s*(=>|<=|⇐|⇒)/ From 9edad89f76ae8505abfa2b2de4bd81f1c3453112 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 23 Aug 2022 20:27:18 +0500 Subject: [PATCH 75/82] Fix inline signature (triple quotes) --- src/purescript.coffee | 19 ++++++++----------- test/Main.purs | 1 + 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/purescript.coffee b/src/purescript.coffee index b7c7a9a..c79fc56 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -565,7 +565,7 @@ purescriptGrammar = # ] # , patterns: [ - match: '({doubleColon})(.*)(?=<-|""")' + match: '({doubleColon})(.*)(?=<-)' captures: 1: name: 'keyword.other.double-colon' 2: {name: 'meta.type-signature', patterns: [ @@ -575,17 +575,14 @@ purescriptGrammar = ] , patterns: [ - match: '({doubleColon})(.*)' - captures: + begin: '({doubleColon})' + end: /(?=^\S)/ + beginCaptures: 1: name: 'keyword.other.double-colon' - 2: { - name: 'meta.type-signature' - patterns: [ - include: "#record_types" - include: '#type_signature' - ] - } - + patterns: [ + include: "#record_types" + include: '#type_signature' + ] ] ] double_colon_orphan: diff --git a/test/Main.purs b/test/Main.purs index f102207..a068ad7 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -478,6 +478,7 @@ px = Proxy :: Proxy """fdsfsdf fdsfdsfsdf """ +px = Proxy :: Proxy """fdsfsdffdsfdsfsdf""" -- quotes after type def From a152a12b46452b52a80136bc378ce321eda30384 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 25 Dec 2023 09:39:51 +0500 Subject: [PATCH 76/82] Add purs output ignore --- .gitignore | 2 + package-lock.json | 767 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 769 insertions(+) create mode 100644 package-lock.json diff --git a/.gitignore b/.gitignore index ade14b9..495cf9d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ .DS_Store npm-debug.log node_modules +output +.psc-ide-port \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..bb05cae --- /dev/null +++ b/package-lock.json @@ -0,0 +1,767 @@ +{ + "name": "language-purescript", + "version": "0.9.6", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "language-purescript", + "version": "0.9.6", + "license": "MIT", + "devDependencies": { + "coffee-script": "~1.9.0", + "season": "~2.0.0" + }, + "engines": { + "atom": ">= 0.105.0" + } + }, + "node_modules/abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "dev": true + }, + "node_modules/amdefine": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", + "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", + "dev": true, + "optional": true, + "engines": { + "node": ">=0.4.2" + } + }, + "node_modules/async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", + "dev": true + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/coffee-script": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.9.3.tgz", + "integrity": "sha1-WW5ug/z8tnxZZKtw1ES+/wrASsc=", + "deprecated": "CoffeeScript on NPM has moved to \"coffeescript\" (no hyphen)", + "dev": true, + "bin": { + "cake": "bin/cake", + "coffee": "bin/coffee" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/coffee-script-redux": { + "version": "2.0.0-beta8", + "resolved": "https://registry.npmjs.org/coffee-script-redux/-/coffee-script-redux-2.0.0-beta8.tgz", + "integrity": "sha1-D9e4QXNA3Q0zno9v2LS4cWlW6NU=", + "dev": true, + "dependencies": { + "nopt": "~2.1.2", + "StringScanner": "~0.0.3" + }, + "bin": { + "coffee": "bin/coffee" + }, + "engines": { + "node": "0.8.x || 0.10.x" + }, + "optionalDependencies": { + "cscodegen": "git://github.com/michaelficarra/cscodegen.git#73fd7202ac086c26f18c9d56f025b18b3c6f5383", + "escodegen": "~0.0.24", + "esmangle": "~0.0.8", + "source-map": "0.1.11" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "node_modules/cscodegen": { + "version": "0.1.0", + "resolved": "git+ssh://git@github.com/michaelficarra/cscodegen.git#73fd7202ac086c26f18c9d56f025b18b3c6f5383", + "integrity": "sha512-g9WfZJ9PTUMIPoYkSbUw/MVqze8BNSPB+2wkDDhM8SClgHLHUC0ioIRnU1h9N8Zp34uMGIjristDMjUnghYJLQ==", + "dev": true, + "optional": true, + "bin": { + "cake": "bin/cscodegen" + }, + "engines": { + "node": ">=0.6.0" + } + }, + "node_modules/cson-safe": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/cson-safe/-/cson-safe-0.1.1.tgz", + "integrity": "sha1-XFa4BC2UhCqTIg+mWn81f83gwnM=", + "dev": true, + "dependencies": { + "coffee-script-redux": "2.0.0-beta8" + } + }, + "node_modules/escodegen": { + "version": "0.0.28", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-0.0.28.tgz", + "integrity": "sha1-Dk/xcV8yh3XWyrUaxEpAbNer/9M=", + "dev": true, + "optional": true, + "dependencies": { + "esprima": "~1.0.2", + "estraverse": "~1.3.0" + }, + "bin": { + "escodegen": "bin/escodegen.js", + "esgenerate": "bin/esgenerate.js" + }, + "engines": { + "node": ">=0.4.0" + }, + "optionalDependencies": { + "source-map": ">= 0.1.2" + } + }, + "node_modules/escope": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escope/-/escope-1.0.3.tgz", + "integrity": "sha1-dZ3OhJbEJI/sLQyq9BCLzz8af10=", + "dev": true, + "optional": true, + "dependencies": { + "estraverse": "^2.0.0" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/escope/node_modules/estraverse": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-2.0.0.tgz", + "integrity": "sha1-WuRpYyQ2ACBmdMyySgnhZnT83KE=", + "dev": true, + "optional": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/esmangle": { + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/esmangle/-/esmangle-0.0.17.tgz", + "integrity": "sha1-TFyTYHzeXRJ2utOW6DYinbpo2Qw=", + "dev": true, + "optional": true, + "dependencies": { + "escodegen": "~ 0.0.28", + "escope": "~ 1.0.0", + "esprima": "~ 1.0.2", + "esshorten": "~ 0.0.2", + "estraverse": "~ 1.3.2", + "optimist": "*", + "source-map": "~ 0.1.8" + }, + "bin": { + "esmangle": "bin/esmangle.js" + }, + "engines": { + "node": ">=0.6.0" + } + }, + "node_modules/esprima": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.0.4.tgz", + "integrity": "sha1-n1V+CPw7TSbs6d00+Pv0drYlha0=", + "dev": true, + "optional": true, + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/esshorten": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/esshorten/-/esshorten-0.0.2.tgz", + "integrity": "sha1-KKZS8e/UDI4if4xt59vmtWDugSk=", + "dev": true, + "optional": true, + "dependencies": { + "escope": "~ 1.0.0", + "estraverse": "~ 1.2.0" + }, + "engines": { + "node": ">=0.6.0" + } + }, + "node_modules/esshorten/node_modules/estraverse": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.2.0.tgz", + "integrity": "sha1-aj3IpGpdZ2blZoY5/Hgpds5WYP0=", + "dev": true, + "optional": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/estraverse": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.3.2.tgz", + "integrity": "sha1-N8K4k+8T1yPydth41g2FNRUqbEI=", + "dev": true, + "optional": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/fs-plus": { + "version": "2.10.1", + "resolved": "https://registry.npmjs.org/fs-plus/-/fs-plus-2.10.1.tgz", + "integrity": "sha1-MgR4HXhAYR5jZOe2+wWMljJ8WqU=", + "dev": true, + "dependencies": { + "async": "^1.5.2", + "mkdirp": "^0.5.1", + "rimraf": "^2.5.2", + "underscore-plus": "1.x" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "node_modules/glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true + }, + "node_modules/mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "dev": true, + "dependencies": { + "minimist": "^1.2.5" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/nopt": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-2.1.2.tgz", + "integrity": "sha1-bMzZd7gBMqB3MdbozljCyDA8+a8=", + "dev": true, + "dependencies": { + "abbrev": "1" + }, + "bin": { + "nopt": "bin/nopt.js" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/optimist": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.4.0.tgz", + "integrity": "sha1-y47Dfy/jqphky2eidSUOfhliCiU=", + "dev": true, + "dependencies": { + "wordwrap": "~0.0.2" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "dev": true, + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + } + }, + "node_modules/season": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/season/-/season-2.0.0.tgz", + "integrity": "sha1-EKjXvO4an/ji/qcCji7cfJGNK30=", + "dev": true, + "dependencies": { + "cson-safe": "~0.1.1", + "fs-plus": "2.x", + "optimist": "~0.4.0", + "underscore-plus": "1.x" + }, + "bin": { + "csonc": "bin/csonc" + } + }, + "node_modules/source-map": { + "version": "0.1.11", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.11.tgz", + "integrity": "sha1-Lu8v1lp0wXmICuXuaXXZnOIet7Q=", + "dev": true, + "optional": true, + "dependencies": { + "amdefine": ">=0.0.4" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/StringScanner": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/StringScanner/-/StringScanner-0.0.3.tgz", + "integrity": "sha1-vwbs/ckARnEfTmF1VJJDt4zrOKo=", + "dev": true, + "engines": { + "node": ">=0.6" + } + }, + "node_modules/underscore": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.1.tgz", + "integrity": "sha512-hzSoAVtJF+3ZtiFX0VgfFPHEDRm7Y/QPjGyNo4TVdnDTdft3tr8hEkD25a1jC+TjTuE7tkHGKkhwCgs9dgBB2g==", + "dev": true + }, + "node_modules/underscore-plus": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/underscore-plus/-/underscore-plus-1.7.0.tgz", + "integrity": "sha512-A3BEzkeicFLnr+U/Q3EyWwJAQPbA19mtZZ4h+lLq3ttm9kn8WC4R3YpuJZEXmWdLjYP47Zc8aLZm9kwdv+zzvA==", + "dev": true, + "dependencies": { + "underscore": "^1.9.1" + } + }, + "node_modules/wordwrap": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", + "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + } + }, + "dependencies": { + "abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "dev": true + }, + "amdefine": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", + "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", + "dev": true, + "optional": true + }, + "async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", + "dev": true + }, + "balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "coffee-script": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.9.3.tgz", + "integrity": "sha1-WW5ug/z8tnxZZKtw1ES+/wrASsc=", + "dev": true + }, + "coffee-script-redux": { + "version": "2.0.0-beta8", + "resolved": "https://registry.npmjs.org/coffee-script-redux/-/coffee-script-redux-2.0.0-beta8.tgz", + "integrity": "sha1-D9e4QXNA3Q0zno9v2LS4cWlW6NU=", + "dev": true, + "requires": { + "cscodegen": "git://github.com/michaelficarra/cscodegen.git#73fd7202ac086c26f18c9d56f025b18b3c6f5383", + "escodegen": "~0.0.24", + "esmangle": "~0.0.8", + "nopt": "~2.1.2", + "source-map": "0.1.11", + "StringScanner": "~0.0.3" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "cscodegen": { + "version": "git+ssh://git@github.com/michaelficarra/cscodegen.git#73fd7202ac086c26f18c9d56f025b18b3c6f5383", + "integrity": "sha512-g9WfZJ9PTUMIPoYkSbUw/MVqze8BNSPB+2wkDDhM8SClgHLHUC0ioIRnU1h9N8Zp34uMGIjristDMjUnghYJLQ==", + "dev": true, + "from": "cscodegen@git://github.com/michaelficarra/cscodegen.git#73fd7202ac086c26f18c9d56f025b18b3c6f5383", + "optional": true + }, + "cson-safe": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/cson-safe/-/cson-safe-0.1.1.tgz", + "integrity": "sha1-XFa4BC2UhCqTIg+mWn81f83gwnM=", + "dev": true, + "requires": { + "coffee-script-redux": "2.0.0-beta8" + } + }, + "escodegen": { + "version": "0.0.28", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-0.0.28.tgz", + "integrity": "sha1-Dk/xcV8yh3XWyrUaxEpAbNer/9M=", + "dev": true, + "optional": true, + "requires": { + "esprima": "~1.0.2", + "estraverse": "~1.3.0", + "source-map": ">= 0.1.2" + } + }, + "escope": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escope/-/escope-1.0.3.tgz", + "integrity": "sha1-dZ3OhJbEJI/sLQyq9BCLzz8af10=", + "dev": true, + "optional": true, + "requires": { + "estraverse": "^2.0.0" + }, + "dependencies": { + "estraverse": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-2.0.0.tgz", + "integrity": "sha1-WuRpYyQ2ACBmdMyySgnhZnT83KE=", + "dev": true, + "optional": true + } + } + }, + "esmangle": { + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/esmangle/-/esmangle-0.0.17.tgz", + "integrity": "sha1-TFyTYHzeXRJ2utOW6DYinbpo2Qw=", + "dev": true, + "optional": true, + "requires": { + "escodegen": "~ 0.0.28", + "escope": "~ 1.0.0", + "esprima": "~ 1.0.2", + "esshorten": "~ 0.0.2", + "estraverse": "~ 1.3.2", + "optimist": "*", + "source-map": "~ 0.1.8" + } + }, + "esprima": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.0.4.tgz", + "integrity": "sha1-n1V+CPw7TSbs6d00+Pv0drYlha0=", + "dev": true, + "optional": true + }, + "esshorten": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/esshorten/-/esshorten-0.0.2.tgz", + "integrity": "sha1-KKZS8e/UDI4if4xt59vmtWDugSk=", + "dev": true, + "optional": true, + "requires": { + "escope": "~ 1.0.0", + "estraverse": "~ 1.2.0" + }, + "dependencies": { + "estraverse": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.2.0.tgz", + "integrity": "sha1-aj3IpGpdZ2blZoY5/Hgpds5WYP0=", + "dev": true, + "optional": true + } + } + }, + "estraverse": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.3.2.tgz", + "integrity": "sha1-N8K4k+8T1yPydth41g2FNRUqbEI=", + "dev": true, + "optional": true + }, + "fs-plus": { + "version": "2.10.1", + "resolved": "https://registry.npmjs.org/fs-plus/-/fs-plus-2.10.1.tgz", + "integrity": "sha1-MgR4HXhAYR5jZOe2+wWMljJ8WqU=", + "dev": true, + "requires": { + "async": "^1.5.2", + "mkdirp": "^0.5.1", + "rimraf": "^2.5.2", + "underscore-plus": "1.x" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true + }, + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "dev": true, + "requires": { + "minimist": "^1.2.5" + } + }, + "nopt": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-2.1.2.tgz", + "integrity": "sha1-bMzZd7gBMqB3MdbozljCyDA8+a8=", + "dev": true, + "requires": { + "abbrev": "1" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "optimist": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.4.0.tgz", + "integrity": "sha1-y47Dfy/jqphky2eidSUOfhliCiU=", + "dev": true, + "requires": { + "wordwrap": "~0.0.2" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "season": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/season/-/season-2.0.0.tgz", + "integrity": "sha1-EKjXvO4an/ji/qcCji7cfJGNK30=", + "dev": true, + "requires": { + "cson-safe": "~0.1.1", + "fs-plus": "2.x", + "optimist": "~0.4.0", + "underscore-plus": "1.x" + } + }, + "source-map": { + "version": "0.1.11", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.11.tgz", + "integrity": "sha1-Lu8v1lp0wXmICuXuaXXZnOIet7Q=", + "dev": true, + "optional": true, + "requires": { + "amdefine": ">=0.0.4" + } + }, + "StringScanner": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/StringScanner/-/StringScanner-0.0.3.tgz", + "integrity": "sha1-vwbs/ckARnEfTmF1VJJDt4zrOKo=", + "dev": true + }, + "underscore": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.1.tgz", + "integrity": "sha512-hzSoAVtJF+3ZtiFX0VgfFPHEDRm7Y/QPjGyNo4TVdnDTdft3tr8hEkD25a1jC+TjTuE7tkHGKkhwCgs9dgBB2g==", + "dev": true + }, + "underscore-plus": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/underscore-plus/-/underscore-plus-1.7.0.tgz", + "integrity": "sha512-A3BEzkeicFLnr+U/Q3EyWwJAQPbA19mtZZ4h+lLq3ttm9kn8WC4R3YpuJZEXmWdLjYP47Zc8aLZm9kwdv+zzvA==", + "dev": true, + "requires": { + "underscore": "^1.9.1" + } + }, + "wordwrap": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", + "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + } + } +} From 8c37d0ef435596ab9728499c36ef4c78cdc3ab61 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 25 Dec 2023 09:41:09 +0500 Subject: [PATCH 77/82] fixes for inline signatures, fixes for infix function --- grammars/purescript.cson | 10 +++++----- src/purescript.coffee | 32 ++++++++++++++++++++------------ test/Main.purs | 27 ++++++++++++++++++++++++--- 3 files changed, 49 insertions(+), 20 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 0155018..dba95cc 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -155,7 +155,7 @@ 'patterns': [ { 'name': 'keyword.operator.function.infix.purescript' - 'match': '(`)(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(`)' + 'match': '(`)(?:[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*(?:\\.[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)*\\.)?[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*.*(`)' 'captures': '1': 'name': 'punctuation.definition.entity.purescript' @@ -482,7 +482,7 @@ } { 'name': 'constant.numeric.purescript' - 'match': '\\d+' + 'match': ' \\d+ ' } { 'match': '([\\p{S}\\p{P}&&[^(),;\\[\\]`{}_"\']]+)' @@ -634,7 +634,7 @@ 'double_colon_parens': 'patterns': [ { - 'match': '\\((?(?:[^()]|\\(\\g\\))*)(::|∷)(?(?:[^()]|\\(\\g\\))*)\\)' + 'match': '\\((?(?:[^()]|\\(\\g\\))*)(::|∷)(?(?:[^()}]|\\(\\g\\))*)\\)' 'captures': '1': 'patterns': [ @@ -658,7 +658,7 @@ { 'patterns': [ { - 'match': '((?:::|∷))(.*)(?=<-|""")' + 'match': '((?:::|∷))(.*)(?=<-| """| })' 'captures': '1': 'name': 'keyword.other.double-colon.purescript' @@ -675,7 +675,7 @@ { 'patterns': [ { - 'match': '((?:::|∷))(.*)' + 'match': '((?:::|∷))(.*)(?!<-| """| })' 'captures': '1': 'name': 'keyword.other.double-colon.purescript' diff --git a/src/purescript.coffee b/src/purescript.coffee index c79fc56..8889438 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -171,7 +171,7 @@ purescriptGrammar = function_infix: patterns: [ name: 'keyword.operator.function.infix' - match: /(`){functionName}(`)/ + match: /(`){functionName}.*(`)/ captures: 1: name: 'punctuation.definition.entity' 2: name: 'punctuation.definition.entity' @@ -404,7 +404,7 @@ purescriptGrammar = include: '#data_ctor' , name: 'constant.numeric' - match: /\d+/ + match: / \d+ / , match: /({operator})/ captures: @@ -541,7 +541,7 @@ purescriptGrammar = '\\(', '(?(?:[^()]|\\(\\g\\))*)', '(::|∷)', - '(?(?:[^()]|\\(\\g\\))*)', + '(?(?:[^()}]|\\(\\g\\))*)', '\\)' ].join('') captures: @@ -565,25 +565,33 @@ purescriptGrammar = # ] # , patterns: [ - match: '({doubleColon})(.*)(?=<-)' + match: '({doubleColon})(.*)(?=<-| """| })' captures: 1: name: 'keyword.other.double-colon' 2: {name: 'meta.type-signature', patterns: [ include: '#type_signature' - ]} ] , patterns: [ - begin: '({doubleColon})' - end: /(?=^\S)/ - beginCaptures: + match: '({doubleColon})(.*)(?!<-| """| })' + captures: 1: name: 'keyword.other.double-colon' - patterns: [ - include: "#record_types" - include: '#type_signature' - ] + 2: {name: 'meta.type-signature', patterns: [ + include: '#type_signature' + ]} ] + # , + # patterns: [ + # begin: '({doubleColon})' + # end: /(?=^\S)/ + # beginCaptures: + # 1: name: 'keyword.other.double-colon' + # patterns: [ + # include: "#record_types" + # include: '#type_signature' + # ] + # ] ] double_colon_orphan: patterns: [ diff --git a/test/Main.purs b/test/Main.purs index a068ad7..1095ad0 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -86,10 +86,10 @@ newtype MySub vnode msg = MySub (SubRec vnode msg) --- infix operators +-- infix operators (with numbers in hame) -- operators that contain -- within -infixr 0 apply as :--> -- comment as :--> -infixl 0 applyFlipped as <--: +infixr 0 apply2 as :--> -- comment as :--> +infixl 0 apply2Flipped as <--: --- @@ -385,6 +385,10 @@ foo = map ?myHole -- infix functions infixFun = 1 `add` 2 +-- infix function with params -- no proper +-- maybe no need because its weird +infixFun = 1 `flip add` 2 + -- function declaration, do, where toStr :: forall a. Functor a => { a :: a } -> Effect Unit --comment @@ -402,6 +406,17 @@ toStr x = do gotConfig :: AVar { a :: Unit } <- AVar.empty +-- no proper for params arrow first +_run + :: forall m + . Functor m + => Config + -> SpecT Aff Unit m Unit + -> m TestEvents + +-- no proper fro colons in string inside parens +x = ("func1 ::") + -- signatures in ide tooltips SomeType :: (a :: Int) @@ -481,6 +496,12 @@ px = Proxy :: Proxy """fdsfsdf px = Proxy :: Proxy """fdsfsdffdsfdsfsdf""" +px = + ({ x = Set.empty :: Set X { x :: Int } } /\ y) + where + y = 1 + + -- quotes after type def From 1054b5c40d4b68e7f0fdedb1baf31a3f5bbb1d2d Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 25 Dec 2023 09:47:11 +0500 Subject: [PATCH 78/82] fix foreign import data --- grammars/purescript.cson | 2 +- src/purescript.coffee | 2 +- test/Main.purs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index dba95cc..b42de8e 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -238,7 +238,7 @@ 'patterns': [ { 'name': 'meta.foreign.data.purescript' - 'begin': '^(\\s*)(foreign)\\s+(import)\\s+(data)(?:\\s+([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*((?:::|∷)))?' + 'begin': '^(\\s*)(foreign)\\s+(import)\\s+(data)\\s(?:\\s+([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\']*)\\s*((?:::|∷)))?' 'end': '^(?!\\1[ \\t]|[ \\t]*$)' 'contentName': 'meta.kind-signature.purescript' 'beginCaptures': diff --git a/src/purescript.coffee b/src/purescript.coffee index 8889438..6add387 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -236,7 +236,7 @@ purescriptGrammar = foreign_import_data: patterns: [ name: 'meta.foreign.data' - begin: /^(\s*)(foreign)\s+(import)\s+(data)(?:\s+({classNameOne})\s*({doubleColon}))?/ + begin: /^(\s*)(foreign)\s+(import)\s+(data)\s(?:\s+({classNameOne})\s*({doubleColon}))?/ end: /{indentBlockEnd}/ contentName: 'meta.kind-signature' beginCaptures: diff --git a/test/Main.purs b/test/Main.purs index 1095ad0..6dc35da 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -31,7 +31,7 @@ foreign import --comment foreign import data --comment foreign import calculateInterest :: Number -> Number --comment foreign import data F :: Type -> Type --comment - +foreign import databaseName :: Db -> Name -- import data with record type foreign import data R :: { prop :: String } From 4cddaea69e37160d071eafeafefafb70d216d8aa Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 27 Dec 2023 16:20:04 +0500 Subject: [PATCH 79/82] fix double colon in quotes, add arrow first signature support --- grammars/purescript.cson | 31 +++++++++++++++++++++++++++- src/purescript.coffee | 33 ++++++++++++++++++++++++++++-- test/Main.purs | 44 ++++++++++++++++++++-------------------- 3 files changed, 83 insertions(+), 25 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index b42de8e..9759bc1 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -57,6 +57,9 @@ { 'include': '#function_type_declaration' } + { + 'include': '#function_type_declaration_arrow_first' + } { 'include': '#typed_hole' } @@ -634,7 +637,7 @@ 'double_colon_parens': 'patterns': [ { - 'match': '\\((?(?:[^()]|\\(\\g\\))*)(::|∷)(?(?:[^()}]|\\(\\g\\))*)\\)' + 'match': '\\((?(?:[^()"]|\\(\\g\\))*)(::|∷)(?(?:[^()"}]|\\(\\g\\))*)\\)' 'captures': '1': 'patterns': [ @@ -857,6 +860,32 @@ ] } ] + 'function_type_declaration_arrow_first': + 'patterns': [ + { + 'name': 'meta.function.type-declaration.purescript' + 'begin': '^(\\s*)(?:\\s(::|∷)(?!.*<-))' + 'end': '^(?!\\1[ \\t]|[ \\t]*$)' + 'contentName': 'meta.type-signature.purescript' + 'beginCaptures': + '2': + 'name': 'keyword.other.double-colon.purescript' + 'patterns': [ + { + 'include': '#double_colon' + } + { + 'include': '#type_signature' + } + { + 'include': '#record_types' + } + { + 'include': '#row_types' + } + ] + } + ] 'row_types': 'patterns': [ { diff --git a/src/purescript.coffee b/src/purescript.coffee index 6add387..4d8b970 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -74,6 +74,10 @@ purescriptGrammar = listMaybe('ctorArgs',/{ctorArgs}/,/\s+/) typeDecl: /.+?/ indentChar: /[ \t]/ + # In indent block here \1 means first captured group, + # + # So if the first capture block is (\s*) then end of indent block will be the line + # with less spaced then in captured block. indentBlockEnd: /^(?!\1{indentChar}|{indentChar}*$)/ maybeBirdTrack: /^/ doubleColon: ///(?: :: | ∷ )/// @@ -100,6 +104,8 @@ purescriptGrammar = include: '#foreign_import' , include: '#function_type_declaration' + , + include: '#function_type_declaration_arrow_first' , include: '#typed_hole' , @@ -539,9 +545,9 @@ purescriptGrammar = # Note recursive regex matching nested parens match: [ '\\(', - '(?(?:[^()]|\\(\\g\\))*)', + '(?(?:[^()"]|\\(\\g\\))*)', '(::|∷)', - '(?(?:[^()}]|\\(\\g\\))*)', + '(?(?:[^()"}]|\\(\\g\\))*)', '\\)' ].join('') captures: @@ -745,7 +751,9 @@ purescriptGrammar = \s* (?: ( :: | ∷ ) (?! .* <- ) ) /// + end: /{indentBlockEnd}/ + # end: /(?=^\S)/ contentName: 'meta.type-signature' beginCaptures: 2: name: 'entity.name.function' @@ -760,6 +768,27 @@ purescriptGrammar = include: '#row_types' ] + function_type_declaration_arrow_first: + name: 'meta.function.type-declaration' + begin: /// + ^ + ( \s* ) + (?: \s ( :: | ∷ ) (?! .* <- ) ) + /// + end: /{indentBlockEnd}/ + # end: /(?=^\S)/ + contentName: 'meta.type-signature' + beginCaptures: + 2: name: 'keyword.other.double-colon' + patterns: [ + include: '#double_colon' + , + include: '#type_signature' + , + include: '#record_types' + , + include: '#row_types' + ] row_types: patterns: [ name: 'meta.type.row' diff --git a/test/Main.purs b/test/Main.purs index 6dc35da..5df18b5 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -340,7 +340,7 @@ quoted = { "A": "a" -- comment , "B": fn (1 :: Int) x 2 -- typed param in parens , "C": 1 :: Int -- typed param without parens - , "C": (1 :: Maybe (Array Int) ) x (1 :: Int) + , "C": (1 :: Maybe (Array Int) ) x (1 :: Proxy "xxx") , a: 2 } @@ -378,15 +378,10 @@ foo :: List Int -> List Int foo = map ?myHole - --- Function, forall - - -- infix functions infixFun = 1 `add` 2 --- infix function with params -- no proper --- maybe no need because its weird +-- infix function with params infixFun = 1 `flip add` 2 @@ -406,16 +401,11 @@ toStr x = do gotConfig :: AVar { a :: Unit } <- AVar.empty --- no proper for params arrow first -_run - :: forall m - . Functor m - => Config - -> SpecT Aff Unit m Unit - -> m TestEvents --- no proper fro colons in string inside parens +-- colons in string inside parens x = ("func1 ::") +-- code coloring after end of quotes +text = (" ::" + global) -- signatures in ide tooltips SomeType :: (a :: Int) @@ -431,13 +421,9 @@ AVar :: Type → Type addIf false = const [] --- double colon inside quoted string -text = (" ::" + global) - - --- fn type signature without :: in the same line lacks highlighting --- it seems to be a bit harder case for proper handling --- maybe it's also a sign that it is better not to have it in the code :-) +-- fn type signature without (arrow first style) :: in the same line lacks +-- highlighting it seems to be a bit harder case for proper handling maybe it's +-- also a sign that it is better not to have it in the code :-) fn -- line orphan signature :: forall a. a -> String @@ -448,6 +434,20 @@ fn a = "1" -> b + "1" _ -> b + a +-- arrow first signature multiline +_run + :: forall m + . Functor m + => Config + -> SpecT Aff Unit m Unit + -> m TestEvents +_run c s = some + where + -- arrow first signature indented + some + :: Int + some = 1 + -- if' fn and if statement with if' = if true then "false" else "true" From 55f84f1984a819e151310d9e7ebcd615289e670c Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 8 May 2024 17:27:33 +0500 Subject: [PATCH 80/82] fixes for inline signature in colons --- grammars/purescript.cson | 46 ++++++++++---- src/purescript.coffee | 55 +++++++++------- test/Main.purs | 134 ++++++++++++++++++++------------------- 3 files changed, 132 insertions(+), 103 deletions(-) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 9759bc1..0834122 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -100,13 +100,13 @@ 'include': '#markup_newline' } { - 'include': '#double_colon_parens' + 'include': '#string_double_colon_parens' } { - 'include': '#double_colon_inlined' + 'include': '#double_colon_parens' } { - 'include': '#double_colon_orphan' + 'include': '#double_colon_inlined' } { 'include': '#comments' @@ -585,6 +585,25 @@ 'name': 'punctuation.definition.string.end.purescript' } ] + 'string_double_colon_parens': + 'patterns': [ + { + 'match': '\\((.*?)("(?:[ -\\[\\]-~]|(\\\\(?: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\\\\\\"\'\\&]))|(\\\\o[0-7]+)|(\\\\x[0-9A-Fa-f]+)|(\\^[A-Z@\\[\\]\\\\\\^_]))*(::|∷)((?:[ -\\[\\]-~]|(\\\\(?:NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS|US|SP|DEL|[abfnrtv\\\\\\"\'\\&]))|(\\\\o[0-7]+)|(\\\\x[0-9A-Fa-f]+)|(\\^[A-Z@\\[\\]\\\\\\^_])))*")' + 'captures': + '1': + 'patterns': [ + { + 'include': '$self' + } + ] + '2': + 'patterns': [ + { + 'include': '$self' + } + ] + } + ] 'string_double_quoted': 'patterns': [ { @@ -637,7 +656,7 @@ 'double_colon_parens': 'patterns': [ { - 'match': '\\((?(?:[^()"]|\\(\\g\\))*)(::|∷)(?(?:[^()"}]|\\(\\g\\))*)\\)' + 'match': '\\((?(?:[^()]|\\(\\g\\))*)(::|∷)(?(?:[^()}]|\\(\\g\\))*)\\)' 'captures': '1': 'patterns': [ @@ -661,7 +680,7 @@ { 'patterns': [ { - 'match': '((?:::|∷))(.*)(?=<-| """| })' + 'match': '((?:::|∷))(.*?)(?=<-| """)' 'captures': '1': 'name': 'keyword.other.double-colon.purescript' @@ -678,17 +697,16 @@ { 'patterns': [ { - 'match': '((?:::|∷))(.*)(?!<-| """| })' - 'captures': + 'begin': '((?:::|∷))' + 'end': '(?=^(\\s|\\S))' + 'beginCaptures': '1': 'name': 'keyword.other.double-colon.purescript' - '2': - 'name': 'meta.type-signature.purescript' - 'patterns': [ - { - 'include': '#type_signature' - } - ] + 'patterns': [ + { + 'include': '#type_signature' + } + ] } ] } diff --git a/src/purescript.coffee b/src/purescript.coffee index 4d8b970..d547336 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -133,12 +133,14 @@ purescriptGrammar = include: '#string_double_quoted' , include: '#markup_newline' + , + include: '#string_double_colon_parens' , include: '#double_colon_parens' , include: '#double_colon_inlined' - , - include: '#double_colon_orphan' + # , + # include: '#double_colon_orphan' , include: '#comments' , @@ -502,7 +504,23 @@ purescriptGrammar = # {character} macro has 4 capture groups, here 3-6 7: name: 'punctuation.definition.string.end' ] - + # To match string that containt double colon as string, to play well with + # #double_colon_parens rule. + string_double_colon_parens: + patterns: [ + match: [ + '\\(', + '(.*?)' + '("{character}*(::|∷)({character})*")', + ].join('') + captures: + 1: patterns: [ + include: '$self' + ] + 2: patterns: [ + include: '$self' + ] + ] string_double_quoted: patterns: [ name: 'string.quoted.double' @@ -545,9 +563,9 @@ purescriptGrammar = # Note recursive regex matching nested parens match: [ '\\(', - '(?(?:[^()"]|\\(\\g\\))*)', + '(?(?:[^()]|\\(\\g\\))*)', '(::|∷)', - '(?(?:[^()"}]|\\(\\g\\))*)', + '(?(?:[^()}]|\\(\\g\\))*)', '\\)' ].join('') captures: @@ -571,7 +589,7 @@ purescriptGrammar = # ] # , patterns: [ - match: '({doubleColon})(.*)(?=<-| """| })' + match: '({doubleColon})(.*?)(?=<-| """)' captures: 1: name: 'keyword.other.double-colon' 2: {name: 'meta.type-signature', patterns: [ @@ -580,24 +598,15 @@ purescriptGrammar = ] , patterns: [ - match: '({doubleColon})(.*)(?!<-| """| })' - captures: + begin: '({doubleColon})' + end: /(?=^(\s|\S))/ + beginCaptures: 1: name: 'keyword.other.double-colon' - 2: {name: 'meta.type-signature', patterns: [ - include: '#type_signature' - ]} + patterns: [ + include: "#record_types" + include: '#type_signature' + ] ] - # , - # patterns: [ - # begin: '({doubleColon})' - # end: /(?=^\S)/ - # beginCaptures: - # 1: name: 'keyword.other.double-colon' - # patterns: [ - # include: "#record_types" - # include: '#type_signature' - # ] - # ] ] double_colon_orphan: patterns: [ @@ -620,9 +629,9 @@ purescriptGrammar = # double_colon_orphan: # patterns: [ # begin: /// - # ^ # ( \s* ) # (?: ( :: | ∷ ) ) + # ( \s* ) # /// # beginCaptures: # 2: name: 'keyword.other.double-colon' diff --git a/test/Main.purs b/test/Main.purs index 5df18b5..187e0e9 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -33,22 +33,20 @@ foreign import calculateInterest :: Number -> Number --comment foreign import data F :: Type -> Type --comment foreign import databaseName :: Db -> Name + -- import data with record type foreign import data R :: { prop :: String } - -- line comments with no space between first char --| some - -- comments with operators after --# some --! some - -- Containers @@ -111,7 +109,6 @@ infixl 2 Inl as $% infixr 2 Inr as %$ - -- type class signatures @@ -190,7 +187,6 @@ instance functorA :: Functor A where map = split -- comment - -- chained instances @@ -211,7 +207,6 @@ else instance showA :: MyShow a where else newtype instance showA :: MyShow a where - -- Records with fields that are reserved words @@ -328,23 +323,6 @@ type Quoted = } --- inlined record type def -quoted :: - { "A" :: Int -- comment - , a :: Boolean - , "B" :: Number - , b :: Int -- comment - , "x" :: SmallCap - } -quoted = - { "A": "a" -- comment - , "B": fn (1 :: Int) x 2 -- typed param in parens - , "C": 1 :: Int -- typed param without parens - , "C": (1 :: Maybe (Array Int) ) x (1 :: Proxy "xxx") - , a: 2 - } - - -- inlined record type def inside foreign import foreign import createSource :: String -> @@ -356,23 +334,6 @@ foreign import createSource :: Effect EventSource --- proxy -proxy = Proxy :: Proxy Int -- k is Type - - --- orphan inline signature -x = 1 - :: - Int -x = {a: 1} :: - { | (a :: Int) } - - --- row type -intAtFoo :: forall r. Variant ( foo :: Int | r ) -intAtFoo = inj (Proxy :: Proxy "foo") 42 - - -- typed hole foo :: List Int -> List Int foo = map ?myHole @@ -381,6 +342,7 @@ foo = map ?myHole -- infix functions infixFun = 1 `add` 2 + -- infix function with params infixFun = 1 `flip add` 2 @@ -401,11 +363,74 @@ toStr x = do gotConfig :: AVar { a :: Unit } <- AVar.empty +-- INLINE SIGNATURES + + +-- inlined record type def +quoted :: + { "A" :: Int -- comment + , a :: Boolean + , "B" :: Number + , b :: Int -- comment + , "x" :: SmallCap + } +quoted = + { "A": "a" -- comment + , "B": fn (1 :: Int) x 2 -- typed param in parens + , "C": 1 :: Proxy "xxx" -- typed param without parens + , "C": (1 :: Maybe (Array Int) ) x (1 :: Proxy "xxx") + , a: 2 + } + + +-- proxy +p :: Proxy "xxx" +p = Proxy + --- colons in string inside parens -x = ("func1 ::") +proxy = Proxy :: Proxy Int -- k is Type + + +-- orphan inline signature +x = 1 + :: + Int +x = {a: 1} :: + { | (a :: Int) } + + +-- row type +-- no proper for ctor variant tag value (double_colon_inlined) +injFoo :: forall r. Variant ( foo :: Int | r ) +injFoo = inj (Proxy :: Proxy "foo") P.ddd Cons (some) + + +-- operators inside type signature ==> +type Schema + = { widgets :: { id :: Int } ==> Array Widget --comment + } + + +px = Proxy :: Proxy "fdsfsdf" + + +-- quotes after type def +px = Proxy :: Proxy """fdsfsdf + fdsfdsfsdf + """ +px = Proxy :: Proxy """fdsfsdffdsfdsfsdf""" +px = + ({ x = Set.empty :: Set X { x :: Int } } /\ X) + where + y = 1 + + +-- double colons in string inside parens +x = ((x :: Int) "func1 ::" <> "func1 ::" <> ((show 1) :: Proxy "x" )) -- code coloring after end of quotes text = (" ::" + global) +text = (""" ::""" + global) + -- signatures in ide tooltips SomeType :: (a :: Int) @@ -434,6 +459,7 @@ fn a = "1" -> b + "1" _ -> b + a + -- arrow first signature multiline _run :: forall m @@ -466,13 +492,6 @@ case' = if true else "true" --- operators inside type signature ==> -type Schema - = { widgets :: { id :: Int } ==> Array Widget --comment - } - - - -- constants @@ -485,23 +504,6 @@ decimal = 41.0 hex = 0xE0 -px = Proxy :: Proxy "fdsfsdf" - - --- quotes after type def -px = Proxy :: Proxy """fdsfsdf - fdsfdsfsdf - """ - -px = Proxy :: Proxy """fdsfsdffdsfdsfsdf""" - - -px = - ({ x = Set.empty :: Set X { x :: Int } } /\ y) - where - y = 1 - - -- quotes after type def From 1959d9fba58aceace33dd323f94d42a0dee4c3ee Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 27 Oct 2024 14:47:12 +0500 Subject: [PATCH 81/82] add no proper case --- test/Main.purs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/Main.purs b/test/Main.purs index 187e0e9..66108d9 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -334,6 +334,13 @@ foreign import createSource :: Effect EventSource +-- no proper after quote +wow'X2 = 1 + +wow_X = 1 + +wow_2 = 1 + -- typed hole foo :: List Int -> List Int foo = map ?myHole @@ -519,3 +526,12 @@ multiStringOneLine = """ "WOW" text """ -- after mult-line string class Foo (a :: Symbol) + + +replaceUnicode :: String -> String +replaceUnicode text = + text + (Pattern ":: forall") (Replacement ":: ∀") + + +--no proper after this \ No newline at end of file From fa8201e3b1ab95706693953a1e9a6b18e68d0363 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 7 Mar 2025 16:37:01 +0500 Subject: [PATCH 82/82] Updates from PR #63 in upstream --- grammars/purescript.cson | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 0834122..b8c4186 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -1026,6 +1026,8 @@ ] '6': 'name': 'keyword.other.big-arrow.purescript' + '6': + 'name': 'keyword.other.big-arrow.purescript' } { 'name': 'meta.class-constraints.purescript'