From 21055f16fc2527a1ad158ffb1313ccef3f0c7e7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Fri, 19 Jul 2024 21:26:26 +0200 Subject: [PATCH 01/34] Rework comment syntax --- syntaxes/effekt.tmLanguage.json | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index 2dba4f1..5130e09 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -14,13 +14,29 @@ "comments": { "patterns": [ { - "match": "//.*$\n?", - "name": "comment.line.double-slash.syntax" + "begin": "//", + "end": "\\n", + "beginCaptures": { + "0": { + "name": "punctuation.definition.comment.effekt" + } + }, + "name": "comment.line.double-slash.effekt" }, { - "begin": "\\s*+(\\/\\*)", - "end": "\\*\\/", - "name": "comment.multiline.syntax" + "begin": "/\\*", + "beginCaptures": { + "0": { + "name": "punctuation.definition.comment.effekt" + } + }, + "end": "\\*/", + "endCaptures": { + "0": { + "name": "punctuation.definition.comment.effekt" + } + }, + "name": "comment.block.effekt" } ] }, From 3802d3c7b38a1c509a85ec94306207da5cf8140f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Fri, 19 Jul 2024 21:35:44 +0200 Subject: [PATCH 02/34] Rework strings, add splices, add characters --- syntaxes/effekt.tmLanguage.json | 53 +++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index 5130e09..80dc3da 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -108,11 +108,54 @@ }] }, "strings": { - "patterns": [{ - "begin": "\"", - "end": "\"", - "name": "string.quoted.double.literal" - }] + "patterns": [ + { + "begin": "\"", + "end": "\"", + "name": "string.quoted.double.literal", + "patterns": [ + { "include": "#stringTemplates" }, + { + "match": "\\\\.", + "name": "constant.character.escape.effekt" + } + ] + }, + { + "begin": "\"\"\"", + "end": "\"\"\"", + "name": "string.quoted.triple.literal", + "patterns": [ + { "include": "#stringTemplates" }, + { + "match": "\\\\.", + "name": "constant.character.escape.effekt" + } + ] + } + ] + }, + "stringTemplates": { + "begin": "\\$\\{", + "beginCaptures": { + "0": { "name": "punctuation.definition.template-expression.begin.effekt" } + }, + "end": "\\}", + "endCaptures": { + "0": { "name": "punctuation.definition.template-expression.end.effekt" } + }, + "name": "meta.embedded.line.effekt", + "patterns": [ + { "include": "$self" } + ] + }, + "characters": { + "patterns": [ + { + "match": "'(\\\\.|[^'\\\\])'", + "name": "string.quoted.single.char.effekt" + } + ] }, "numbers": { "patterns": [{ From f6198d8d7b778d86c5b824fc3c311d17ec74eeea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Fri, 19 Jul 2024 21:40:12 +0200 Subject: [PATCH 03/34] Reformat file to conform to the current style --- syntaxes/effekt.tmLanguage.json | 106 +++++++++++++++----------------- 1 file changed, 48 insertions(+), 58 deletions(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index 80dc3da..5c7a7d8 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -12,33 +12,30 @@ ], "repository": { "comments": { - "patterns": [ - { - "begin": "//", - "end": "\\n", - "beginCaptures": { - "0": { - "name": "punctuation.definition.comment.effekt" - } - }, - "name": "comment.line.double-slash.effekt" + "patterns": [{ + "begin": "//", + "end": "\\n", + "beginCaptures": { + "0": { + "name": "punctuation.definition.comment.effekt" + } }, - { - "begin": "/\\*", - "beginCaptures": { - "0": { - "name": "punctuation.definition.comment.effekt" - } - }, - "end": "\\*/", - "endCaptures": { - "0": { - "name": "punctuation.definition.comment.effekt" - } - }, - "name": "comment.block.effekt" - } - ] + "name": "comment.line.double-slash.effekt" + }, { + "begin": "/\\*", + "beginCaptures": { + "0": { + "name": "punctuation.definition.comment.effekt" + } + }, + "end": "\\*/", + "endCaptures": { + "0": { + "name": "punctuation.definition.comment.effekt" + } + }, + "name": "comment.block.effekt" + }] }, "definitions": { "patterns": [{ @@ -108,32 +105,27 @@ }] }, "strings": { - "patterns": [ - { - "begin": "\"", - "end": "\"", - "name": "string.quoted.double.literal", - "patterns": [ - { "include": "#stringTemplates" }, - { - "match": "\\\\.", - "name": "constant.character.escape.effekt" - } - ] - }, - { - "begin": "\"\"\"", - "end": "\"\"\"", - "name": "string.quoted.triple.literal", - "patterns": [ - { "include": "#stringTemplates" }, - { - "match": "\\\\.", - "name": "constant.character.escape.effekt" - } - ] - } - ] + "patterns": [{ + "begin": "\"", + "end": "\"", + "name": "string.quoted.double.literal", + "patterns": [{ + "include": "#stringTemplates" + }, { + "match": "\\\\.", + "name": "constant.character.escape.effekt" + }] + }, { + "begin": "\"\"\"", + "end": "\"\"\"", + "name": "string.quoted.triple.literal", + "patterns": [{ + "include": "#stringTemplates" + }, { + "match": "\\\\.", + "name": "constant.character.escape.effekt" + }] + }] }, "stringTemplates": { "begin": "\\$\\{", @@ -150,12 +142,10 @@ ] }, "characters": { - "patterns": [ - { - "match": "'(\\\\.|[^'\\\\])'", - "name": "string.quoted.single.char.effekt" - } - ] + "patterns": [{ + "match": "'(\\\\.|[^'\\\\])'", + "name": "string.quoted.single.char.effekt" + }] }, "numbers": { "patterns": [{ From e7af33d7e27a7b0ebdddf7434b83c76988b8b44c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Fri, 19 Jul 2024 21:41:52 +0200 Subject: [PATCH 04/34] Make a separate class for capabilities --- syntaxes/effekt.tmLanguage.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index 5c7a7d8..64b0f67 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -43,7 +43,7 @@ "end" : "[=\\n]", "beginCaptures": { "1": { "name": "keyword.declaration.type" }, - "2": { "name": "entity.name.type" }, + "2": { "name": "variable.other.capability.effekt" }, "3": { "name": "keyword.declaration.function" }, "4": { "name": "entity.name.function" } }, From a078110d13776691d446ded1ea87dff4906a38a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Fri, 19 Jul 2024 21:45:19 +0200 Subject: [PATCH 05/34] Parse namespace declarations --- syntaxes/effekt.tmLanguage.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index 64b0f67..f44e125 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -67,6 +67,12 @@ "2": { "name": "keyword.declaration.type" }, "3": { "name": "entity.name.type" } } + }, { + "match": "\\s*(namespace)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", + "captures": { + "1": { "name": "keyword.declaration.namespace" }, + "2": { "name": "entity.name.namespace" } + } }] }, "parameters": { From f6a6d2a44ef68efc3ea8c000f8251b133a09e813 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Fri, 19 Jul 2024 21:56:26 +0200 Subject: [PATCH 06/34] Support capability sets precisely --- syntaxes/effekt.tmLanguage.json | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index f44e125..112601e 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -43,7 +43,7 @@ "end" : "[=\\n]", "beginCaptures": { "1": { "name": "keyword.declaration.type" }, - "2": { "name": "variable.other.capability.effekt" }, + "2": { "patterns": [{ "include": "#capabilities" }] }, "3": { "name": "keyword.declaration.function" }, "4": { "name": "entity.name.function" } }, @@ -84,6 +84,18 @@ "name": "entity.name.type" }] }, + "capabilities": { + "patterns": [{ + "match": "\\b(pure)\\b", + "name": "keyword.other.capability" + }, { + "match": "\\b([a-z][a-zA-Z0-9_]*)\\b", + "name": "variable.other.capability" + }, { + "match": ",", + "name": "punctuation.capability-set.comma" + }] + }, "keywords": { "patterns": [{ "match": "\\b(module|import|def|fun|val|var|effect|type|match|case|record|extern|include|box|unbox|in|region|new|resource|interface|namespace|module|include|export|as)\\b", From 5765516adc9fd0baaa42cdc48b0036db95a32c2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Fri, 19 Jul 2024 22:05:35 +0200 Subject: [PATCH 07/34] Add folding markers --- syntaxes/effekt.tmLanguage.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index 112601e..a8595bb 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -1,6 +1,8 @@ { "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", "name": "Effekt", + "foldingStartMarker": "(? Date: Fri, 19 Jul 2024 22:05:48 +0200 Subject: [PATCH 08/34] Try to keep a common style throughout the file --- syntaxes/effekt.tmLanguage.json | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index a8595bb..f32dfa9 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -18,17 +18,13 @@ "begin": "//", "end": "\\n", "beginCaptures": { - "0": { - "name": "punctuation.definition.comment.effekt" - } + "0": { "name": "punctuation.definition.comment.effekt" } }, "name": "comment.line.double-slash.effekt" }, { "begin": "/\\*", "beginCaptures": { - "0": { - "name": "punctuation.definition.comment.effekt" - } + "0": { "name": "punctuation.definition.comment.effekt" } }, "end": "\\*/", "endCaptures": { From cb491efeff357e13ac38e3e44fe8750268e8dd3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Fri, 19 Jul 2024 22:17:55 +0200 Subject: [PATCH 09/34] Characters can be top-level, escapes synced with lexer --- syntaxes/effekt.tmLanguage.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index f32dfa9..b87d179 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -9,6 +9,7 @@ { "include": "#keywords" }, { "include": "#names" }, { "include": "#strings" }, + { "include": "#characters" }, { "include": "#numbers" }, { "include": "#holes" } ], @@ -159,7 +160,10 @@ }, "characters": { "patterns": [{ - "match": "'(\\\\.|[^'\\\\])'", + "match": "'(\\\\[nrt\\\\']|[^'\\\\])'", + "name": "string.quoted.single.char.effekt" + }, { + "match": "\\\\u[0-9A-Fa-f]{4}", "name": "string.quoted.single.char.effekt" }] }, From d82dc8574ecf841fb0a68c78fbe1eacff312778f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Fri, 19 Jul 2024 22:37:52 +0200 Subject: [PATCH 10/34] Fix multi-line strings parsed as single-line --- syntaxes/effekt.tmLanguage.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index b87d179..e65e071 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -123,9 +123,9 @@ }, "strings": { "patterns": [{ - "begin": "\"", - "end": "\"", - "name": "string.quoted.double.literal", + "begin": "\"\"\"", + "end": "\"\"\"", + "name": "string.quoted.triple.literal", "patterns": [{ "include": "#stringTemplates" }, { @@ -133,9 +133,9 @@ "name": "constant.character.escape.effekt" }] }, { - "begin": "\"\"\"", - "end": "\"\"\"", - "name": "string.quoted.triple.literal", + "begin": "\"", + "end": "\"", + "name": "string.quoted.double.literal", "patterns": [{ "include": "#stringTemplates" }, { From 45e11730384138901f7413adee6c202c05a4a0e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Fri, 19 Jul 2024 22:41:17 +0200 Subject: [PATCH 11/34] Add float literals --- syntaxes/effekt.tmLanguage.json | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index e65e071..fde7be2 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -168,10 +168,16 @@ }] }, "numbers": { - "patterns": [{ - "match": "\\b[0-9]+", - "name": "constant.numeric" - }] + "patterns": [ + { + "match": "\\b([0-9]+\\.[0-9]+)\\b", + "name": "constant.numeric.float.effekt" + }, + { + "match": "\\b([0-9]+)\\b", + "name": "constant.numeric.integer.effekt" + } + ] }, "punctuation": { "patterns": [{ From 2739c2782ae68c4d489d3e986064e296cd3e0216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Fri, 19 Jul 2024 22:45:03 +0200 Subject: [PATCH 12/34] Try to parse extern defs properly --- syntaxes/effekt.tmLanguage.json | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index fde7be2..8577f21 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -38,13 +38,21 @@ }, "definitions": { "patterns": [{ - "begin": "\\s*(extern)?\\s*(\\{[^\\}]*\\}|[a-zA-Z][a-z-A-Z0-9_$]*)\\s*(def)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", - "end" : "[=\\n]", - "beginCaptures": { - "1": { "name": "keyword.declaration.type" }, - "2": { "patterns": [{ "include": "#capabilities" }] }, - "3": { "name": "keyword.declaration.function" }, - "4": { "name": "entity.name.function" } + "begin": "\\s*(extern)\\s+((?:(?:\\{[^\\}]*\\}|[a-zA-Z][a-z-A-Z0-9_$]*)\\s+)?)\\s*(def)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", + "end": "[=\\n]", + "captures": { + "1": { "name": "keyword.declaration.type" }, + "2": { "patterns": [{ "include": "#capabilities" }] }, + "3": { "name": "keyword.declaration.function.extern" }, + "4": { "name": "entity.name.function" } + }, + "patterns": [{ "include": "#parameters" }] + }, { + "begin": "\\s*(def)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", + "end": "[=\\n]", + "captures": { + "1": { "name": "keyword.declaration.function" }, + "2": { "name": "entity.name.function" } }, "patterns": [{ "include": "#parameters" }] }, { From 93c019ebd2289b10d69969a98c11df75caafe0d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Fri, 19 Jul 2024 22:47:34 +0200 Subject: [PATCH 13/34] Improve typed hole parsing --- syntaxes/effekt.tmLanguage.json | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index 8577f21..daef0e2 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -194,13 +194,11 @@ }] }, "holes": { + "begin": "<{", + "end": "}>", + "name": "meta.hole.effekt", "patterns": [{ - "begin": "<{", - "end" : "}>", - "name": "effekt.hole", - "patterns": [{ - "include": "source.effekt" - }] + "include": "$self" }] } }, From 9c2b2d353cd99081be9655fc419f51be1b09891c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Fri, 19 Jul 2024 23:00:06 +0200 Subject: [PATCH 14/34] Simplify and extract literals --- syntaxes/effekt.tmLanguage.json | 83 ++++++++++++++++----------------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index daef0e2..0880d3e 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -8,9 +8,7 @@ { "include": "#definitions" }, { "include": "#keywords" }, { "include": "#names" }, - { "include": "#strings" }, - { "include": "#characters" }, - { "include": "#numbers" }, + { "include": "#literals" }, { "include": "#holes" } ], "repository": { @@ -112,46 +110,68 @@ "name": "keyword.control" }] }, - "names": { + "literals": { "patterns": [{ "match": "\\b(true|false)\\b", - "name": "constant.language" + "name": "constant.language.boolean.effekt" }, { - "match": "\\b([a-z][a-zA-Z0-9_]*)\\b[\\s]*[({\\[]", - "captures": { - "1": { "name": "entity.name.function" } - } + "match": "\\b([0-9]+\\.[0-9]+)\\b", + "name": "constant.numeric.float.effekt" }, { - "match": "\\b[a-z][a-zA-Z0-9_]*\\b", - "name": "variable" + "match": "\\b([0-9]+)\\b", + "name": "constant.numeric.integer.effekt" }, { - "match": "\\b[A-Z][a-zA-Z0-9_]*\\b", - "name": "entity.name.type" + "include": "#characters" + }, { + "include": "#strings" + }] + }, + "characters": { + "name": "string.quoted.single.effekt", + "begin": "'", + "end": "'", + "patterns": [{ + "name": "constant.character.escape.effekt", + "match": "\\\\((u[0-9a-fA-F]{4})|.)" }] }, "strings": { "patterns": [{ + "name": "string.quoted.triple.effekt", "begin": "\"\"\"", "end": "\"\"\"", - "name": "string.quoted.triple.literal", "patterns": [{ - "include": "#stringTemplates" + "name": "constant.character.escape.effekt", + "match": "\\\\((u[0-9a-fA-F]{4})|.)" }, { - "match": "\\\\.", - "name": "constant.character.escape.effekt" + "include": "#stringTemplates" }] }, { + "name": "string.quoted.double.effekt", "begin": "\"", "end": "\"", - "name": "string.quoted.double.literal", "patterns": [{ - "include": "#stringTemplates" + "name": "constant.character.escape.effekt", + "match": "\\\\((u[0-9a-fA-F]{4})|.)" }, { - "match": "\\\\.", - "name": "constant.character.escape.effekt" + "include": "#stringTemplates" }] }] }, + "names": { + "patterns": [{ + "match": "\\b([a-z][a-zA-Z0-9_]*)\\b[\\s]*[({\\[]", + "captures": { + "1": { "name": "entity.name.function" } + } + }, { + "match": "\\b[a-z][a-zA-Z0-9_]*\\b", + "name": "variable" + }, { + "match": "\\b[A-Z][a-zA-Z0-9_]*\\b", + "name": "entity.name.type" + }] + }, "stringTemplates": { "begin": "\\$\\{", "beginCaptures": { @@ -166,27 +186,6 @@ { "include": "$self" } ] }, - "characters": { - "patterns": [{ - "match": "'(\\\\[nrt\\\\']|[^'\\\\])'", - "name": "string.quoted.single.char.effekt" - }, { - "match": "\\\\u[0-9A-Fa-f]{4}", - "name": "string.quoted.single.char.effekt" - }] - }, - "numbers": { - "patterns": [ - { - "match": "\\b([0-9]+\\.[0-9]+)\\b", - "name": "constant.numeric.float.effekt" - }, - { - "match": "\\b([0-9]+)\\b", - "name": "constant.numeric.integer.effekt" - } - ] - }, "punctuation": { "patterns": [{ "match": "[{}\\(\\)\\[\\];,]", From 23d911fb6da3364a21f66fe036f117c1ef4a0666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Fri, 19 Jul 2024 23:16:47 +0200 Subject: [PATCH 15/34] Add supported operators --- syntaxes/effekt.tmLanguage.json | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index 0880d3e..2285323 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -9,7 +9,8 @@ { "include": "#keywords" }, { "include": "#names" }, { "include": "#literals" }, - { "include": "#holes" } + { "include": "#holes" }, + { "include": "#operators" } ], "repository": { "comments": { @@ -199,6 +200,27 @@ "patterns": [{ "include": "$self" }] + }, + "operators": { + "patterns": [{ + "match": "\\|\\||&&", + "name": "keyword.operator.logical.effekt" + }, { + "match": "==|!=|<=|>=|<|>", + "name": "keyword.operator.comparison.effekt" + }, { + "match": "\\+\\+", + "name": "keyword.operator.concatenation.effekt" + }, { + "match": "\\+\\+|\\+|-|\\*|/", + "name": "keyword.operator.arithmetic.effekt" + }, { + "match": "::", + "name": "keyword.operator.namespace.effekt" + }, { + "match": "=>", + "name": "keyword.operator.arrow.effekt" + }] } }, "scopeName": "source.effekt" From b2cfffb46e824055a654fe1690735983896faef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Fri, 19 Jul 2024 23:19:24 +0200 Subject: [PATCH 16/34] Ensure naming conventions are consistent --- syntaxes/effekt.tmLanguage.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index 2285323..3dbfa1b 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -105,10 +105,10 @@ "keywords": { "patterns": [{ "match": "\\b(module|import|def|fun|val|var|effect|type|match|case|record|extern|include|box|unbox|in|region|new|resource|interface|namespace|module|include|export|as)\\b", - "name": "keyword.syntax" + "name": "keyword.syntax.effekt" }, { "match": "\\b(resume|while|try|with|if|else|do|return|is|and)\\b", - "name": "keyword.control" + "name": "keyword.control.effekt" }] }, "literals": { @@ -163,14 +163,14 @@ "patterns": [{ "match": "\\b([a-z][a-zA-Z0-9_]*)\\b[\\s]*[({\\[]", "captures": { - "1": { "name": "entity.name.function" } + "1": { "name": "entity.name.function.effekt" } } }, { "match": "\\b[a-z][a-zA-Z0-9_]*\\b", - "name": "variable" + "name": "variable.effekt" }, { "match": "\\b[A-Z][a-zA-Z0-9_]*\\b", - "name": "entity.name.type" + "name": "entity.name.type.effekt" }] }, "stringTemplates": { From daaecec1e5892fd1dcb299bf0880a63bc9e18719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Fri, 19 Jul 2024 23:52:04 +0200 Subject: [PATCH 17/34] Reformat --- syntaxes/effekt.tmLanguage.json | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index 3dbfa1b..187c6b4 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -28,9 +28,7 @@ }, "end": "\\*/", "endCaptures": { - "0": { - "name": "punctuation.definition.comment.effekt" - } + "0": { "name": "punctuation.definition.comment.effekt" } }, "name": "comment.block.effekt" }] @@ -40,11 +38,11 @@ "begin": "\\s*(extern)\\s+((?:(?:\\{[^\\}]*\\}|[a-zA-Z][a-z-A-Z0-9_$]*)\\s+)?)\\s*(def)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", "end": "[=\\n]", "captures": { - "1": { "name": "keyword.declaration.type" }, - "2": { "patterns": [{ "include": "#capabilities" }] }, - "3": { "name": "keyword.declaration.function.extern" }, - "4": { "name": "entity.name.function" } - }, + "1": { "name": "keyword.declaration.type" }, + "2": { "patterns": [{ "include": "#capabilities" }] }, + "3": { "name": "keyword.declaration.function.extern" }, + "4": { "name": "entity.name.function" } + }, "patterns": [{ "include": "#parameters" }] }, { "begin": "\\s*(def)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", From dc5fc7f24fb42a7d22944b0c3374407a739b3aa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Sat, 20 Jul 2024 00:12:29 +0200 Subject: [PATCH 18/34] Reorganize keywords --- syntaxes/effekt.tmLanguage.json | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index 187c6b4..c958dc5 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -102,11 +102,20 @@ }, "keywords": { "patterns": [{ - "match": "\\b(module|import|def|fun|val|var|effect|type|match|case|record|extern|include|box|unbox|in|region|new|resource|interface|namespace|module|include|export|as)\\b", + "match": "\\b(module|import|def|fun|val|var|effect|type|record|extern|include|box|unbox|in|region|new|resource|interface|namespace|module|include|export|as)\\b", "name": "keyword.syntax.effekt" }, { - "match": "\\b(resume|while|try|with|if|else|do|return|is|and)\\b", - "name": "keyword.control.effekt" + "match": "\\b(resume|return)\\b", + "name": "keyword.control.flow.jump.effekt" + }, { + "match": "\\b(do|try|with)\\b", + "name": "keyword.control.flow.effects.effekt" + }, { + "match": "\\b(while|match|case|if|else)\\b", + "name": "keyword.control.flow.effekt" + }, { + "match": "\\b(is|and)\\b", + "name": "keyword.operator.effekt" }] }, "literals": { From 94ce3e19f77d43dc4ae86227a4bb3379fecd0c2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Sat, 20 Jul 2024 10:57:48 +0200 Subject: [PATCH 19/34] Make 'in' a conditional keyword only --- syntaxes/effekt.tmLanguage.json | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index c958dc5..8b22bba 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -59,11 +59,19 @@ "2": { "name": "variable" } } }, { - "match": "\\s*(var)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", - "captures": { + "begin": "\\s*(var)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", + "beginCaptures": { "1": { "name": "keyword.declaration.var" }, "2": { "name": "variable" } - } + }, + "end": "[=\\n]", + "patterns": [{ + "match": "\\s+(in)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", + "captures": { + "1": { "name": "keyword.syntax.in.effekt" }, + "2": { "name": "entity.name.region.effekt" } + } + }] }, { "match": "\\s*(extern)?\\s*(type|effect|interface|resource)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", "captures": { @@ -102,7 +110,7 @@ }, "keywords": { "patterns": [{ - "match": "\\b(module|import|def|fun|val|var|effect|type|record|extern|include|box|unbox|in|region|new|resource|interface|namespace|module|include|export|as)\\b", + "match": "\\b(module|import|def|fun|val|var|effect|type|record|extern|include|box|unbox|region|new|resource|interface|namespace|module|include|export|as)\\b", "name": "keyword.syntax.effekt" }, { "match": "\\b(resume|return)\\b", From 974f89d5dcb4a48854927410dec102b5dbaea5bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Sat, 20 Jul 2024 13:52:25 +0200 Subject: [PATCH 20/34] Definitions shouldn't be stopped by '=>' --- syntaxes/effekt.tmLanguage.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index 8b22bba..4269e5d 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -36,7 +36,7 @@ "definitions": { "patterns": [{ "begin": "\\s*(extern)\\s+((?:(?:\\{[^\\}]*\\}|[a-zA-Z][a-z-A-Z0-9_$]*)\\s+)?)\\s*(def)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", - "end": "[=\\n]", + "end": "(?=\\=|\\n)", "captures": { "1": { "name": "keyword.declaration.type" }, "2": { "patterns": [{ "include": "#capabilities" }] }, @@ -46,7 +46,7 @@ "patterns": [{ "include": "#parameters" }] }, { "begin": "\\s*(def)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", - "end": "[=\\n]", + "end": "(?=\\=|\\n)", "captures": { "1": { "name": "keyword.declaration.function" }, "2": { "name": "entity.name.function" } @@ -64,7 +64,7 @@ "1": { "name": "keyword.declaration.var" }, "2": { "name": "variable" } }, - "end": "[=\\n]", + "end": "(?=\\=|\\n)", "patterns": [{ "match": "\\s+(in)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", "captures": { From 1d7d3650ec0441a25e9966340ef2837d72df6c4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Sat, 20 Jul 2024 14:40:33 +0200 Subject: [PATCH 21/34] More sofisticated end-stops for definitions --- syntaxes/effekt.tmLanguage.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index 4269e5d..f08c2b6 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -36,7 +36,7 @@ "definitions": { "patterns": [{ "begin": "\\s*(extern)\\s+((?:(?:\\{[^\\}]*\\}|[a-zA-Z][a-z-A-Z0-9_$]*)\\s+)?)\\s*(def)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", - "end": "(?=\\=|\\n)", + "end": "(?:(?=\\n)|(?=\\b(?:(?!=>)[^=]>\\b)|(?:(?!>)\\=)))", "captures": { "1": { "name": "keyword.declaration.type" }, "2": { "patterns": [{ "include": "#capabilities" }] }, @@ -46,7 +46,7 @@ "patterns": [{ "include": "#parameters" }] }, { "begin": "\\s*(def)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", - "end": "(?=\\=|\\n)", + "end": "(?:(?=\\n)|(?=\\b(?:(?!=>)[^=]>\\b)|(?:(?!>)\\=)))", "captures": { "1": { "name": "keyword.declaration.function" }, "2": { "name": "entity.name.function" } @@ -64,7 +64,7 @@ "1": { "name": "keyword.declaration.var" }, "2": { "name": "variable" } }, - "end": "(?=\\=|\\n)", + "end": "(?:(?=\\n)|(?=\\b(?:(?!=>)[^=]>\\b)|(?:(?!>)\\=)))", "patterns": [{ "match": "\\s+(in)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", "captures": { From 812bb8194139dac5a93fe13008c2ef86cb1ee0c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Sat, 20 Jul 2024 14:41:08 +0200 Subject: [PATCH 22/34] Support boxed types: 'at {io, global}' --- syntaxes/effekt.tmLanguage.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index f08c2b6..cceb235 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -7,6 +7,7 @@ { "include": "#comments" }, { "include": "#definitions" }, { "include": "#keywords" }, + { "include": "#boxed_types" }, { "include": "#names" }, { "include": "#literals" }, { "include": "#holes" }, @@ -87,8 +88,23 @@ } }] }, + "boxed_types": { + "comment": "Used for boxed types like 'at {}', 'at {io}', 'at {io, global}', etc.", + "patterns": [{ + "begin": "\\b(at)\\s*\\{", + "beginCaptures": { + "1": { "name": "keyword.syntax.at.effekt" } + }, + "end": "\\}", + "patterns": [{ + "include": "#capabilities" + }] + }] + }, "parameters": { "patterns": [{ + "include": "#boxed_types" + }, { "match": "\\b([a-z][a-zA-Z0-9_$]*)(?:)", "name": "variable.parameter" }, { From 1df2a1b4eb7e1034f5d4f7faca304a31e5c18d2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Sat, 20 Jul 2024 14:47:02 +0200 Subject: [PATCH 23/34] Fix highlighting type annotations in variables --- syntaxes/effekt.tmLanguage.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index cceb235..58c2fb6 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -72,6 +72,8 @@ "1": { "name": "keyword.syntax.in.effekt" }, "2": { "name": "entity.name.region.effekt" } } + }, { + "include": "#parameters" }] }, { "match": "\\s*(extern)?\\s*(type|effect|interface|resource)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", From 7dc2c36e19884654c7798cee79b33ba8f2270d4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Sat, 20 Jul 2024 17:41:21 +0200 Subject: [PATCH 24/34] Simplify end patterns further --- syntaxes/effekt.tmLanguage.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index 58c2fb6..7a02bff 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -37,7 +37,7 @@ "definitions": { "patterns": [{ "begin": "\\s*(extern)\\s+((?:(?:\\{[^\\}]*\\}|[a-zA-Z][a-z-A-Z0-9_$]*)\\s+)?)\\s*(def)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", - "end": "(?:(?=\\n)|(?=\\b(?:(?!=>)[^=]>\\b)|(?:(?!>)\\=)))", + "end": "(?=\\n)|(?<=\\S)\\s*(?==(?!>))", "captures": { "1": { "name": "keyword.declaration.type" }, "2": { "patterns": [{ "include": "#capabilities" }] }, @@ -47,7 +47,7 @@ "patterns": [{ "include": "#parameters" }] }, { "begin": "\\s*(def)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", - "end": "(?:(?=\\n)|(?=\\b(?:(?!=>)[^=]>\\b)|(?:(?!>)\\=)))", + "end": "(?=\\n)|(?<=\\S)\\s*(?==(?!>))", "captures": { "1": { "name": "keyword.declaration.function" }, "2": { "name": "entity.name.function" } @@ -65,7 +65,7 @@ "1": { "name": "keyword.declaration.var" }, "2": { "name": "variable" } }, - "end": "(?:(?=\\n)|(?=\\b(?:(?!=>)[^=]>\\b)|(?:(?!>)\\=)))", + "end": "(?:;|(?=\\n)|(?<=\\S)\\s*(?==(?!>)))", "patterns": [{ "match": "\\s+(in)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", "captures": { From e00c1546b4e029f2823b8acf9a42a8a59b7c4d3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Sat, 20 Jul 2024 18:16:59 +0200 Subject: [PATCH 25/34] Refactor escapes, highlight invalid escapes --- syntaxes/effekt.tmLanguage.json | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index 7a02bff..42d38c8 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -165,8 +165,9 @@ "begin": "'", "end": "'", "patterns": [{ - "name": "constant.character.escape.effekt", - "match": "\\\\((u[0-9a-fA-F]{4})|.)" + "include": "#escapes" + }, { + "include": "#invalidEscapes" }] }, "strings": { @@ -174,10 +175,8 @@ "name": "string.quoted.triple.effekt", "begin": "\"\"\"", "end": "\"\"\"", + "comment": "Important: only single-line strings can have escapes!", "patterns": [{ - "name": "constant.character.escape.effekt", - "match": "\\\\((u[0-9a-fA-F]{4})|.)" - }, { "include": "#stringTemplates" }] }, { @@ -185,13 +184,23 @@ "begin": "\"", "end": "\"", "patterns": [{ - "name": "constant.character.escape.effekt", - "match": "\\\\((u[0-9a-fA-F]{4})|.)" + "include": "#escapes" + }, { + "include": "#invalidEscapes" }, { "include": "#stringTemplates" }] }] }, + "escapes": { + "match": "\\\\([btnfr\\\\\"']|u[0-9A-Fa-f]{4})", + "name": "constant.character.escape.effekt" + }, + "invalidEscapes": { + "match": "\\\\.", + "name": "invalid.illegal.unknown-escape.effekt", + "comment": "Represents any possible escape, therefore should always be used _after_ #escapes!" + }, "names": { "patterns": [{ "match": "\\b([a-z][a-zA-Z0-9_]*)\\b[\\s]*[({\\[]", From edb6a54fed28520c733cb2374b935b3dc002f39b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Sun, 21 Jul 2024 17:11:28 +0200 Subject: [PATCH 26/34] Literals have a priority over names --- syntaxes/effekt.tmLanguage.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index 42d38c8..42586dc 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -8,8 +8,8 @@ { "include": "#definitions" }, { "include": "#keywords" }, { "include": "#boxed_types" }, - { "include": "#names" }, { "include": "#literals" }, + { "include": "#names" }, { "include": "#holes" }, { "include": "#operators" } ], From 4ae4bdb8d7aff5aca84565198418fa7da7f900a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Sun, 21 Jul 2024 17:35:37 +0200 Subject: [PATCH 27/34] Clarify TextMate scopes, fix bugs, add 'module' --- syntaxes/effekt.tmLanguage.json | 61 +++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index 42586dc..216f77a 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -39,31 +39,31 @@ "begin": "\\s*(extern)\\s+((?:(?:\\{[^\\}]*\\}|[a-zA-Z][a-z-A-Z0-9_$]*)\\s+)?)\\s*(def)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", "end": "(?=\\n)|(?<=\\S)\\s*(?==(?!>))", "captures": { - "1": { "name": "keyword.declaration.type" }, + "1": { "name": "storage.modifier.extern.effekt" }, "2": { "patterns": [{ "include": "#capabilities" }] }, - "3": { "name": "keyword.declaration.function.extern" }, - "4": { "name": "entity.name.function" } + "3": { "name": "keyword.declaration.function.extern.effekt" }, + "4": { "name": "entity.name.function.effekt" } }, "patterns": [{ "include": "#parameters" }] }, { "begin": "\\s*(def)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", "end": "(?=\\n)|(?<=\\S)\\s*(?==(?!>))", "captures": { - "1": { "name": "keyword.declaration.function" }, - "2": { "name": "entity.name.function" } + "1": { "name": "keyword.declaration.function.effekt" }, + "2": { "name": "entity.name.function.effekt" } }, "patterns": [{ "include": "#parameters" }] }, { "match": "\\s*(val)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", "captures": { - "1": { "name": "keyword.declaration.val" }, - "2": { "name": "variable" } + "1": { "name": "keyword.declaration.val.effekt" }, + "2": { "name": "variable.other.effekt" } } }, { "begin": "\\s*(var)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", "beginCaptures": { - "1": { "name": "keyword.declaration.var" }, - "2": { "name": "variable" } + "1": { "name": "keyword.declaration.var.effekt" }, + "2": { "name": "variable.other.effekt" } }, "end": "(?:;|(?=\\n)|(?<=\\S)\\s*(?==(?!>)))", "patterns": [{ @@ -78,15 +78,21 @@ }, { "match": "\\s*(extern)?\\s*(type|effect|interface|resource)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", "captures": { - "1": { "name": "keyword.declaration.type" }, - "2": { "name": "keyword.declaration.type" }, - "3": { "name": "entity.name.type" } + "1": { "name": "storage.modifier.extern.effekt" }, + "2": { "name": "keyword.declaration.type.effekt" }, + "3": { "name": "entity.name.type.effekt" } } }, { "match": "\\s*(namespace)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", "captures": { - "1": { "name": "keyword.declaration.namespace" }, - "2": { "name": "entity.name.namespace" } + "1": { "name": "keyword.declaration.namespace.effekt" }, + "2": { "name": "entity.name.namespace.effekt" } + } + }, { + "match": "\\s*(module)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", + "captures": { + "1": { "name": "keyword.declaration.module.effekt" }, + "2": { "name": "entity.name.module.effekt" } } }] }, @@ -95,7 +101,7 @@ "patterns": [{ "begin": "\\b(at)\\s*\\{", "beginCaptures": { - "1": { "name": "keyword.syntax.at.effekt" } + "1": { "name": "keyword.other.at.effekt" } }, "end": "\\}", "patterns": [{ @@ -108,40 +114,43 @@ "include": "#boxed_types" }, { "match": "\\b([a-z][a-zA-Z0-9_$]*)(?:)", - "name": "variable.parameter" + "name": "variable.parameter.effekt" }, { "match": "\\b([A-Z][a-zA-Z0-9_$]*)(?:)", - "name": "entity.name.type" + "name": "entity.name.type.effekt" }] }, "capabilities": { "patterns": [{ "match": "\\b(pure)\\b", - "name": "keyword.other.capability" + "name": "keyword.other.capability.pure.effekt" }, { "match": "\\b([a-z][a-zA-Z0-9_]*)\\b", - "name": "variable.other.capability" + "name": "variable.other.capability.effekt" }, { "match": ",", - "name": "punctuation.capability-set.comma" + "name": "punctuation.separator.capability.effekt" }] }, "keywords": { "patterns": [{ - "match": "\\b(module|import|def|fun|val|var|effect|type|record|extern|include|box|unbox|region|new|resource|interface|namespace|module|include|export|as)\\b", + "match": "\\b(module|import|def|fun|val|var|effect|type|record|include|box|unbox|region|new|resource|interface|namespace|module|include|export|as)\\b", "name": "keyword.syntax.effekt" }, { "match": "\\b(resume|return)\\b", - "name": "keyword.control.flow.jump.effekt" + "name": "keyword.control.jump.effekt" }, { "match": "\\b(do|try|with)\\b", - "name": "keyword.control.flow.effects.effekt" + "name": "keyword.control.effect.effekt" }, { "match": "\\b(while|match|case|if|else)\\b", "name": "keyword.control.flow.effekt" }, { "match": "\\b(is|and)\\b", "name": "keyword.operator.effekt" + }, { + "match": "\\b(extern)\\b", + "name": "storage.modifier.extern.effekt" }] }, "literals": { @@ -209,7 +218,7 @@ } }, { "match": "\\b[a-z][a-zA-Z0-9_]*\\b", - "name": "variable.effekt" + "name": "variable.other.effekt" }, { "match": "\\b[A-Z][a-zA-Z0-9_]*\\b", "name": "entity.name.type.effekt" @@ -232,7 +241,7 @@ "punctuation": { "patterns": [{ "match": "[{}\\(\\)\\[\\];,]", - "name": "punctuation.separator" + "name": "punctuation.separator.effekt" }] }, "holes": { @@ -254,7 +263,7 @@ "match": "\\+\\+", "name": "keyword.operator.concatenation.effekt" }, { - "match": "\\+\\+|\\+|-|\\*|/", + "match": "\\+|-|\\*|/", "name": "keyword.operator.arithmetic.effekt" }, { "match": "::", From 2a30140abbd039616d8d3f59da20ea9e253409f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Sun, 21 Jul 2024 17:43:53 +0200 Subject: [PATCH 28/34] Add first-class support for regions --- syntaxes/effekt.tmLanguage.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index 216f77a..b09d43a 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -6,6 +6,7 @@ "patterns": [ { "include": "#comments" }, { "include": "#definitions" }, + { "include": "#regions" }, { "include": "#keywords" }, { "include": "#boxed_types" }, { "include": "#literals" }, @@ -272,6 +273,15 @@ "match": "=>", "name": "keyword.operator.arrow.effekt" }] + }, + "regions": { + "patterns": [{ + "match": "\\b(region)\\s+([a-zA-Z][a-zA-Z0-9_]*)\\b", + "captures": { + "1": { "name": "keyword.syntax.region.effekt" }, + "2": { "name": "entity.name.region.effekt" } + } + }] } }, "scopeName": "source.effekt" From 65bc391ceeacbbad462f42305f5f253136ee9682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Sun, 21 Jul 2024 18:06:51 +0200 Subject: [PATCH 29/34] Add proper support for modules and imports --- syntaxes/effekt.tmLanguage.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index b09d43a..182831c 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -90,11 +90,17 @@ "2": { "name": "entity.name.namespace.effekt" } } }, { - "match": "\\s*(module)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", + "match": "\\s*(module)\\s+((?:[a-zA-Z][a-zA-Z0-9_]*(?:/[a-zA-Z][a-zA-Z0-9_]*)*))\\b", "captures": { "1": { "name": "keyword.declaration.module.effekt" }, "2": { "name": "entity.name.module.effekt" } } + }, { + "match": "\\s*(import)\\s+((?:[a-zA-Z][a-zA-Z0-9_]*(?:/[a-zA-Z][a-zA-Z0-9_]*)*))\\b", + "captures": { + "1": { "name": "keyword.syntax.import.effekt" }, + "2": { "name": "entity.name.module.import.effekt" } + } }] }, "boxed_types": { From 9052cf57412155b2e23cf4e20b18f5521e8c3190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Sun, 21 Jul 2024 18:11:01 +0200 Subject: [PATCH 30/34] Use 'keyword.other' to comply with standard TextMate scopes --- syntaxes/effekt.tmLanguage.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index 182831c..a8d88e1 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -70,7 +70,7 @@ "patterns": [{ "match": "\\s+(in)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", "captures": { - "1": { "name": "keyword.syntax.in.effekt" }, + "1": { "name": "keyword.other.in.effekt" }, "2": { "name": "entity.name.region.effekt" } } }, { @@ -98,7 +98,7 @@ }, { "match": "\\s*(import)\\s+((?:[a-zA-Z][a-zA-Z0-9_]*(?:/[a-zA-Z][a-zA-Z0-9_]*)*))\\b", "captures": { - "1": { "name": "keyword.syntax.import.effekt" }, + "1": { "name": "keyword.other.import.effekt" }, "2": { "name": "entity.name.module.import.effekt" } } }] @@ -142,7 +142,7 @@ "keywords": { "patterns": [{ "match": "\\b(module|import|def|fun|val|var|effect|type|record|include|box|unbox|region|new|resource|interface|namespace|module|include|export|as)\\b", - "name": "keyword.syntax.effekt" + "name": "keyword.other.effekt" }, { "match": "\\b(resume|return)\\b", "name": "keyword.control.jump.effekt" @@ -284,7 +284,7 @@ "patterns": [{ "match": "\\b(region)\\s+([a-zA-Z][a-zA-Z0-9_]*)\\b", "captures": { - "1": { "name": "keyword.syntax.region.effekt" }, + "1": { "name": "keyword.other.region.effekt" }, "2": { "name": "entity.name.region.effekt" } } }] From f6188ecbfb92ecbf79cbae7614cdf728da83fa4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Mon, 22 Jul 2024 10:48:51 +0200 Subject: [PATCH 31/34] Region references are also capabilities --- syntaxes/effekt.tmLanguage.json | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index a8d88e1..d9514c3 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -71,8 +71,7 @@ "match": "\\s+(in)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", "captures": { "1": { "name": "keyword.other.in.effekt" }, - "2": { "name": "entity.name.region.effekt" } - } + "2": { "name": "variable.other.capability.effekt entity.name.region.effekt" } } }, { "include": "#parameters" }] @@ -131,6 +130,9 @@ "patterns": [{ "match": "\\b(pure)\\b", "name": "keyword.other.capability.pure.effekt" + }, { + "match": "\\b(io|global)\\b", + "name": "support.constant.effekt variable.other.capability.effekt" }, { "match": "\\b([a-z][a-zA-Z0-9_]*)\\b", "name": "variable.other.capability.effekt" @@ -285,7 +287,7 @@ "match": "\\b(region)\\s+([a-zA-Z][a-zA-Z0-9_]*)\\b", "captures": { "1": { "name": "keyword.other.region.effekt" }, - "2": { "name": "entity.name.region.effekt" } + "2": { "name": "variable.other.capability.effekt entity.name.region.effekt" } } }] } From 35dc0f6383458b41781a687aa83ba14054875671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Mon, 22 Jul 2024 10:56:28 +0200 Subject: [PATCH 32/34] Distinguish the 'global' region as a builtin --- syntaxes/effekt.tmLanguage.json | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index d9514c3..ff7a37f 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -71,7 +71,16 @@ "match": "\\s+(in)\\s+([a-zA-Z][a-z-A-Z0-9_$]*)\\b", "captures": { "1": { "name": "keyword.other.in.effekt" }, - "2": { "name": "variable.other.capability.effekt entity.name.region.effekt" } } + "2": { + "patterns": [{ + "match": "global", + "name": "support.constant.effekt variable.other.capability.effekt entity.name.region.effekt" + }, { + "match": "[a-zA-Z][a-z-A-Z0-9_$]*", + "name": "variable.other.capability.effekt entity.name.region.effekt" + }] + } + } }, { "include": "#parameters" }] @@ -131,8 +140,11 @@ "match": "\\b(pure)\\b", "name": "keyword.other.capability.pure.effekt" }, { - "match": "\\b(io|global)\\b", + "match": "\\b(io)\\b", "name": "support.constant.effekt variable.other.capability.effekt" + }, { + "match": "\\b(global)\\b", + "name": "support.constant.effekt variable.other.capability.effekt entity.name.region.effekt" }, { "match": "\\b([a-z][a-zA-Z0-9_]*)\\b", "name": "variable.other.capability.effekt" From 00ec30b29f0b31a60e25a115acf754fb356e75b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Mon, 22 Jul 2024 11:30:30 +0200 Subject: [PATCH 33/34] Remove duplicate keyword --- syntaxes/effekt.tmLanguage.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index ff7a37f..87d88db 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -155,7 +155,7 @@ }, "keywords": { "patterns": [{ - "match": "\\b(module|import|def|fun|val|var|effect|type|record|include|box|unbox|region|new|resource|interface|namespace|module|include|export|as)\\b", + "match": "\\b(module|import|def|fun|val|var|effect|type|record|box|unbox|region|new|resource|interface|namespace|module|include|export|as)\\b", "name": "keyword.other.effekt" }, { "match": "\\b(resume|return)\\b", From 2d69df2adcde1f831a1927560edd75ea41e86ecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bene=C5=A1?= Date: Tue, 23 Jul 2024 21:05:17 +0200 Subject: [PATCH 34/34] Resolve keywords, remove 'as' --- syntaxes/effekt.tmLanguage.json | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/syntaxes/effekt.tmLanguage.json b/syntaxes/effekt.tmLanguage.json index 87d88db..cbcb51d 100644 --- a/syntaxes/effekt.tmLanguage.json +++ b/syntaxes/effekt.tmLanguage.json @@ -155,20 +155,17 @@ }, "keywords": { "patterns": [{ - "match": "\\b(module|import|def|fun|val|var|effect|type|record|box|unbox|region|new|resource|interface|namespace|module|include|export|as)\\b", + "match": "\\b(module|import|def|fun|val|var|effect|type|record|box|unbox|region|new|resource|interface|namespace|module|include|export)\\b", "name": "keyword.other.effekt" }, { - "match": "\\b(resume|return)\\b", + "match": "\\b(return)\\b", "name": "keyword.control.jump.effekt" }, { - "match": "\\b(do|try|with)\\b", + "match": "\\b(do|resume|try|with)\\b", "name": "keyword.control.effect.effekt" }, { - "match": "\\b(while|match|case|if|else)\\b", + "match": "\\b(while|match|case|if|else|is|and)\\b", "name": "keyword.control.flow.effekt" - }, { - "match": "\\b(is|and)\\b", - "name": "keyword.operator.effekt" }, { "match": "\\b(extern)\\b", "name": "storage.modifier.extern.effekt"