From 16ecd28dd93e5d223c4d877d6e16cb7f9ffb9d9d Mon Sep 17 00:00:00 2001 From: cozis Date: Wed, 7 Dec 2022 14:35:57 +0100 Subject: [PATCH] better syntax highlighting for vscode --- examples/utils.noja | 37 ------------------- .../vscode/noja/syntaxes/noja.tmLanguage.json | 18 +++++---- 2 files changed, 11 insertions(+), 44 deletions(-) delete mode 100644 examples/utils.noja diff --git a/examples/utils.noja b/examples/utils.noja deleted file mode 100644 index 8af29fd..0000000 --- a/examples/utils.noja +++ /dev/null @@ -1,37 +0,0 @@ - -fun compareAny(A, B) { - - fun compareLists(A: List, B: List) { - n = count(A); - if n != count(B): - return false; - - i = 0; - while i < n: { - if not compareAny(A[i], B[i]): - return false; - i = i + 1; - } - return true; - } - - T = type(A); - - if T != type(B): - return false; - - if T == List: - return compareLists(A, B); - - if T == Map: - error("Maps aren't supported yet!"); - - return A == B; -} - -assert(compareAny(1, 2) == false); -assert(compareAny([], []) == true); -assert(compareAny([], [1]) == false); -assert(compareAny([1, 2, 3], [1, 2, 3]) == true); -assert(compareAny([1, 2, 3], [1, 2, 4]) == false); -assert(compareAny([1, 2, 3], [1, 2, 3, 4]) == false); diff --git a/support/vscode/noja/syntaxes/noja.tmLanguage.json b/support/vscode/noja/syntaxes/noja.tmLanguage.json index 80bf761..5a56f31 100644 --- a/support/vscode/noja/syntaxes/noja.tmLanguage.json +++ b/support/vscode/noja/syntaxes/noja.tmLanguage.json @@ -9,18 +9,18 @@ { "match": "\\b(fun)\\b[ \\t\\n]*([a-zA-Z_][a-zA-Z0-9_]*)?\\b", "captures": { - "1": {"name": "keyword.control.noja"}, + "1": {"name": "storage.type.function.noja"}, "2": {"name": "entity.name.function"} } }, - { - "name": "keyword.operator.word.noja", - "match": "\\b(and|or|not)\\b" - }, { "name": "keyword.operator.noja", "match": "(\\+|-|\\*|\\/|=|==|!=|\\>|\\<|\\>=|\\<=|\\|)" }, + { + "name": "keyword.operator.logical.noja", + "match": "\\b(and|or|not)\\b" + }, { "name": "constant.language.noja", "match": "\\b(none|any|true|false)\\b" @@ -56,13 +56,17 @@ "match": "[0-9]+" }, { - "name": "storage.type.noja", + "name": "support.type.noja", "match": "\\b(int|float|bool|[_A-Z][A-Za-z0-9_]*)\\b" }, + { + "name": "support.function.builtin.noja", + "match": "\\b(import|type|istypeof|print|input|count|error|assert|keysof)\\b" + }, { "match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)[ \\t\\n]*\\(", "captures": { - "1": {"name": "variable.function.noja"} + "1": {"name": "variable.other.function"} } }, {