From 5fb6a32be9a15663eeca431f07e368a7abd47cab Mon Sep 17 00:00:00 2001 From: Oscar Spencer Date: Mon, 4 Mar 2024 10:16:10 -0600 Subject: [PATCH] feat: Support operator identifiers (#174) --- editor-extensions/vscode/syntaxes/grain.json | 29 ++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/editor-extensions/vscode/syntaxes/grain.json b/editor-extensions/vscode/syntaxes/grain.json index 393ca72..74f609c 100644 --- a/editor-extensions/vscode/syntaxes/grain.json +++ b/editor-extensions/vscode/syntaxes/grain.json @@ -681,7 +681,7 @@ "name": "punctuation.support.grain" }, { - "match": "\\b(type)\\b\\s*([A-Z]\\w*)\\b", + "match": "\\b(type|exception)\\b\\s*([A-Z]\\w*)\\b", "captures": { "1": { "patterns": [{ "include": "#keywords" }] }, "2": { "patterns": [{ "include": "#type" }] } @@ -694,12 +694,7 @@ "match": "\\b[A-Z]\\w*\\b", "name": "entity.name.module.grain" }, - { - "match": "(\\b\\w+\\b)", - "captures": { - "1": { "patterns": [{ "include": "#identifier" }] } - } - } + { "include": "#identifier" } ] }, { @@ -733,7 +728,7 @@ } ] }, - "identifier": { + "operator": { "patterns": [ { "match": "(==|!=|<|>|\\^|\\+|-|\\*|%|/|&|\\||\\?\\?)[$&\\*/\\+\\-=><\\^\\|\\!\\?%:\\.]*", @@ -747,6 +742,24 @@ "match": "\\bis(nt)?\\b", "name": "keyword.operator.grain" }, + { + "begin": "(\\()", + "end": "(\\))", + "beginCaptures": { + "1": { "name": "punctuation.definition.parameters.begin.grain" } + }, + "endCaptures": { + "1": { "name": "punctuation.definition.parameters.end.grain" } + }, + "patterns": [{ "include": "#operator" }] + } + ] + }, + "identifier": { + "patterns": [ + { + "include": "#operator" + }, { "match": "(\\.\\.\\.|\\.)", "name": "keyword.operator.grain"