From 2ce6f733d7207d58c7dee80f14b0899127d9a379 Mon Sep 17 00:00:00 2001 From: Francesco Cozzuto Date: Wed, 15 Oct 2025 12:10:56 +0200 Subject: [PATCH] Add syntax highlighting --- README.md | 11 +- .../wl-language/language-configuration.json | 30 ++ ide/vscode/wl-language/package.json | 41 ++ .../wl-language/syntaxes/wl.tmLanguage.json | 359 ++++++++++++++++++ ide/vscode/wl-language/themes/wl-theme.json | 113 ++++++ 5 files changed, 553 insertions(+), 1 deletion(-) create mode 100644 ide/vscode/wl-language/language-configuration.json create mode 100644 ide/vscode/wl-language/package.json create mode 100644 ide/vscode/wl-language/syntaxes/wl.tmLanguage.json create mode 100644 ide/vscode/wl-language/themes/wl-theme.json diff --git a/README.md b/README.md index 24376e3..90815f4 100644 --- a/README.md +++ b/README.md @@ -450,4 +450,13 @@ The caller then needs to push the return value of the call on top of the stack u ## Building -To build WL with your program, just drop the `wl.c` and `wl.h` files in your own source tree and compile them as any other file. \ No newline at end of file +To build WL with your program, just drop the `wl.c` and `wl.h` files in your own source tree and compile them as any other file. + +## Syntax Highlighting + +We have a WL extension for vscode in `ide/vscode/` which offers basic syntax highlighting. + +To install it, drop it in your extension folder and reload vscode. The specific folder depends on your platform: +* Windows: `%USERPROFILE%\.vscode\extensions` +* macOS: `~/.vscode/extensions` +* Linux: `~/.vscode/extensions` diff --git a/ide/vscode/wl-language/language-configuration.json b/ide/vscode/wl-language/language-configuration.json new file mode 100644 index 0000000..630f08b --- /dev/null +++ b/ide/vscode/wl-language/language-configuration.json @@ -0,0 +1,30 @@ +{ + "comments": { + "blockComment": [""] + }, + "brackets": [ + ["{", "}"], + ["[", "]"], + ["(", ")"] + ], + "autoClosingPairs": [ + { "open": "{", "close": "}" }, + { "open": "[", "close": "]" }, + { "open": "(", "close": ")" }, + { "open": "\"", "close": "\"" }, + { "open": "'", "close": "'" } + ], + "surroundingPairs": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + ["\"", "\""], + ["'", "'"] + ], + "folding": { + "markers": { + "start": "^\\s*", + "patterns": [] + } + ] + }, + "keywords": { + "patterns": [ + { + "name": "keyword.control.wl", + "match": "\\b(if|else|while|for|in)\\b" + }, + { + "name": "keyword.other.wl", + "match": "\\b(procedure|let|include)\\b" + }, + { + "name": "keyword.operator.wl", + "match": "\\b(len|escape)\\b" + } + ] + }, + "constants": { + "patterns": [ + { + "name": "constant.language.wl", + "match": "\\b(none|true|false)\\b" + } + ] + }, + "strings": { + "patterns": [ + { + "name": "string.quoted.double.wl", + "begin": "\"", + "end": "\"", + "patterns": [ + { + "name": "constant.character.escape.wl", + "match": "\\\\(n|t|r|\"|'|\\\\|x[0-9A-Fa-f]{2})" + } + ] + }, + { + "name": "string.quoted.single.wl", + "begin": "'", + "end": "'", + "patterns": [ + { + "name": "constant.character.escape.wl", + "match": "\\\\(n|t|r|\"|'|\\\\|x[0-9A-Fa-f]{2})" + } + ] + } + ] + }, + "numbers": { + "patterns": [ + { + "name": "constant.numeric.float.wl", + "match": "\\b[0-9]+\\.[0-9]+\\b" + }, + { + "name": "constant.numeric.integer.wl", + "match": "\\b[0-9]+\\b" + } + ] + }, + "operators": { + "patterns": [ + { + "name": "keyword.operator.append.wl", + "match": "<<" + }, + { + "name": "keyword.operator.comparison.wl", + "match": "(==|!=|<=|>=)" + }, + { + "name": "keyword.operator.relational.wl", + "match": "(<|>)" + }, + { + "name": "keyword.operator.assignment.wl", + "match": "=" + }, + { + "name": "keyword.operator.arithmetic.wl", + "match": "(\\+|-|\\*|/|%)" + } + ] + }, + "system-variables": { + "patterns": [ + { + "name": "variable.other.system.wl", + "match": "\\$[a-zA-Z_][a-zA-Z0-9_]*" + } + ] + }, + "functions": { + "patterns": [ + { + "name": "entity.name.function.wl", + "match": "\\b[a-zA-Z_][a-zA-Z0-9_]*(?=\\s*\\()" + } + ] + }, + "html-tags": { + "patterns": [ + { + "name": "meta.tag.html.wl", + "begin": "(<)([a-zA-Z][a-zA-Z0-9]*)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.tag.begin.wl" + }, + "2": { + "name": "entity.name.tag.wl" + } + }, + "end": "(/>)|(>)", + "endCaptures": { + "1": { + "name": "punctuation.definition.tag.self-closing.wl" + }, + "2": { + "name": "punctuation.definition.tag.end.wl" + } + }, + "patterns": [ + { + "name": "string.quoted.double.html.wl", + "begin": "\"", + "end": "\"", + "patterns": [ + { + "include": "#embedded-expression" + } + ] + }, + { + "name": "string.quoted.single.html.wl", + "begin": "'", + "end": "'", + "patterns": [ + { + "include": "#embedded-expression" + } + ] + }, + { + "include": "#embedded-expression" + } + ] + }, + { + "name": "meta.tag.closing.html.wl", + "match": "()", + "captures": { + "1": { + "name": "punctuation.definition.tag.begin.wl" + }, + "2": { + "name": "entity.name.tag.wl" + }, + "3": { + "name": "punctuation.definition.tag.end.wl" + } + } + } + ] + }, + "embedded-expression": { + "patterns": [ + { + "name": "meta.embedded.block.wl", + "begin": "\\\\\\{", + "end": "\\}", + "patterns": [ + { + "include": "#expression-contents" + } + ] + }, + { + "name": "meta.embedded.wl", + "begin": "\\\\", + "end": "(?=[\\s\"'/>])", + "patterns": [ + { + "include": "#expression-contents" + } + ] + } + ] + }, + "expression-contents": { + "patterns": [ + { + "include": "#keywords" + }, + { + "include": "#strings" + }, + { + "include": "#numbers" + }, + { + "include": "#operators" + }, + { + "include": "#system-variables" + }, + { + "include": "#functions" + }, + { + "include": "#constants" + }, + { + "include": "#brackets" + } + ] + }, + "brackets": { + "patterns": [ + { + "begin": "\\[", + "end": "\\]", + "patterns": [ + { + "include": "#keywords" + }, + { + "include": "#strings" + }, + { + "include": "#numbers" + }, + { + "include": "#operators" + }, + { + "include": "#system-variables" + }, + { + "include": "#functions" + }, + { + "include": "#constants" + }, + { + "include": "#brackets" + } + ] + }, + { + "begin": "\\{", + "end": "\\}", + "patterns": [ + { + "include": "#keywords" + }, + { + "include": "#strings" + }, + { + "include": "#numbers" + }, + { + "include": "#operators" + }, + { + "include": "#system-variables" + }, + { + "include": "#functions" + }, + { + "include": "#constants" + }, + { + "include": "#brackets" + } + ] + }, + { + "begin": "\\(", + "end": "\\)", + "patterns": [ + { + "include": "#keywords" + }, + { + "include": "#strings" + }, + { + "include": "#numbers" + }, + { + "include": "#operators" + }, + { + "include": "#system-variables" + }, + { + "include": "#functions" + }, + { + "include": "#constants" + }, + { + "include": "#brackets" + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/ide/vscode/wl-language/themes/wl-theme.json b/ide/vscode/wl-language/themes/wl-theme.json new file mode 100644 index 0000000..4bc328a --- /dev/null +++ b/ide/vscode/wl-language/themes/wl-theme.json @@ -0,0 +1,113 @@ +{ + "name": "WL Enhanced", + "type": "dark", + "colors": { + "editor.background": "#1e1e1e", + "editor.foreground": "#d4d4d4" + }, + "tokenColors": [ + { + "name": "WL Control Keywords", + "scope": "keyword.control.wl", + "settings": { + "foreground": "#C586C0", + "fontStyle": "bold" + } + }, + { + "name": "WL Declaration Keywords (let, include, procedure)", + "scope": "keyword.other.wl", + "settings": { + "foreground": "#569CD6", + "fontStyle": "bold" + } + }, + { + "name": "WL Operator Keywords (len, escape)", + "scope": "keyword.operator.wl", + "settings": { + "foreground": "#4EC9B0" + } + }, + { + "name": "WL HTML Tags", + "scope": "entity.name.tag.wl", + "settings": { + "foreground": "#4EC9B0" + } + }, + { + "name": "WL HTML Tag Punctuation", + "scope": "punctuation.definition.tag.wl", + "settings": { + "foreground": "#808080" + } + }, + { + "name": "WL Constants", + "scope": "constant.language.wl", + "settings": { + "foreground": "#569CD6" + } + }, + { + "name": "WL Strings", + "scope": "string.quoted.double.wl, string.quoted.single.wl, string.quoted.double.html.wl, string.quoted.single.html.wl", + "settings": { + "foreground": "#CE9178" + } + }, + { + "name": "WL Numbers", + "scope": "constant.numeric.wl", + "settings": { + "foreground": "#B5CEA8" + } + }, + { + "name": "WL System Variables", + "scope": "variable.other.system.wl", + "settings": { + "foreground": "#9CDCFE", + "fontStyle": "italic" + } + }, + { + "name": "WL Functions", + "scope": "entity.name.function.wl", + "settings": { + "foreground": "#DCDCAA" + } + }, + { + "name": "WL Operators", + "scope": "keyword.operator.wl", + "settings": { + "foreground": "#D4D4D4" + } + }, + { + "name": "WL Append Operator", + "scope": "keyword.operator.append.wl", + "settings": { + "foreground": "#C586C0", + "fontStyle": "bold" + } + }, + { + "name": "WL Comments", + "scope": "comment.block.html.wl", + "settings": { + "foreground": "#6A9955", + "fontStyle": "italic" + } + }, + { + "name": "WL Embedded Expressions", + "scope": "meta.embedded.wl", + "settings": { + "background": "#2d2d30" + } + } + ] +} \ No newline at end of file