Implemented simple VSCode extension providing syntax highlighting for xyw files.
h3rald h3rald@h3rald.com
Wed, 04 Feb 2026 13:57:08 +0100
4 files changed,
288 insertions(+),
0 deletions(-)
A
xyw-vscode/README.md
@@ -0,0 +1,49 @@
+# XYW Language Support for VS Code + +Syntax highlighting for the XYW assembly language. + +## Features + +- Syntax highlighting for `.xyw` and `.xim` files +- Comment support (`;` line comments) +- Highlights: + - Directives (`.include`, `.label`, `.macro`, `.string`, etc.) + - Instructions (stack, arithmetic, logic, memory, control flow) + - Labels and label references + - Numeric literals (`$hex`, `%binary`, decimal) + - Strings with escape sequences + +## Installation + +### Option 1: Install from VSIX (Recommended) + +1. Package the extension: + ```bash + cd xyw-vscode + npx @vscode/vsce package + ``` +2. Install the generated `.vsix` file: + - Open VS Code + - Press `Ctrl+Shift+P` → "Extensions: Install from VSIX..." + - Select the `.vsix` file + +### Option 2: Development Mode + +1. Open the `xyw-vscode` folder in VS Code +2. Press `F5` to launch an Extension Development Host with the extension loaded + +### Option 3: Symlink to Extensions Folder + +Create a symlink from your VS Code extensions folder to this directory: + +**Windows (PowerShell as Admin):** +```powershell +cmd /c mklink /D "$env:USERPROFILE\.vscode\extensions\xyw-language" "C:\path\to\xyw\xyw-vscode" +``` + +**macOS/Linux:** +```bash +ln -s /path/to/xyw/xyw-vscode ~/.vscode/extensions/xyw-language +``` + +Then restart VS Code.
A
xyw-vscode/language-configuration.json
@@ -0,0 +1,18 @@
+{ + "comments": { + "lineComment": ";" + }, + "brackets": [], + "autoClosingPairs": [ + { + "open": "\"", + "close": "\"" + } + ], + "surroundingPairs": [ + { + "open": "\"", + "close": "\"" + } + ] +}
A
xyw-vscode/package.json
@@ -0,0 +1,51 @@
+{ + "name": "xyw-language", + "displayName": "XYW Assembly Language", + "description": "Syntax highlighting for the xyw assembly language", + "version": "0.1.0", + "publisher": "xyw", + "engines": { + "vscode": "^1.60.0" + }, + "categories": [ + "Programming Languages" + ], + "contributes": { + "languages": [ + { + "id": "xyw", + "aliases": [ + "XYW", + "xyw" + ], + "extensions": [ + ".xyw" + ], + "configuration": "./language-configuration.json" + }, + { + "id": "xim", + "aliases": [ + "XIM", + "xim" + ], + "extensions": [ + ".xim" + ], + "configuration": "./language-configuration.json" + } + ], + "grammars": [ + { + "language": "xyw", + "scopeName": "source.xyw", + "path": "./syntaxes/xyw.tmLanguage.json" + }, + { + "language": "xim", + "scopeName": "source.xyw", + "path": "./syntaxes/xyw.tmLanguage.json" + } + ] + } +}
A
xyw-vscode/syntaxes/xyw.tmLanguage.json
@@ -0,0 +1,170 @@
+{ + "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", + "name": "XYW Assembly", + "scopeName": "source.xyw", + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#directives" + }, + { + "include": "#labels" + }, + { + "include": "#strings" + }, + { + "include": "#numbers" + }, + { + "include": "#instructions" + }, + { + "include": "#identifiers" + } + ], + "repository": { + "comments": { + "patterns": [ + { + "name": "comment.line.semicolon.xyw", + "match": ";.*$" + } + ] + }, + "directives": { + "patterns": [ + { + "name": "keyword.control.directive.xyw", + "match": "\\.(include|label|macro|string|byte)\\b" + } + ] + }, + "labels": { + "patterns": [ + { + "comment": "Label definition: .label <name> where name starts with letter/underscore, can contain letters, numbers, underscores, dashes, or dots", + "name": "support.function.label.xyw", + "match": "(?<=\\.label\\s+)[a-zA-Z_][a-zA-Z0-9_.\\-]*" + }, + { + "comment": "Macro definition: .macro <name> <args...> - name followed by space-separated arguments", + "match": "(?<=\\.macro\\s+)([a-zA-Z_][a-zA-Z0-9_.\\-]*)(.*)$", + "captures": { + "1": { + "name": "support.function.macro.xyw" + }, + "2": { + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#strings" + }, + { + "include": "#numbers" + }, + { + "include": "#instructions" + }, + { + "include": "#identifiers" + } + ] + } + } + } + ] + }, + "strings": { + "patterns": [ + { + "name": "string.quoted.double.xyw", + "begin": "\"", + "end": "\"", + "patterns": [ + { + "name": "constant.character.escape.xyw", + "match": "\\\\." + } + ] + } + ] + }, + "numbers": { + "patterns": [ + { + "name": "constant.numeric.hex.xyw", + "match": "\\$[0-9a-fA-F]+" + }, + { + "name": "constant.numeric.binary.xyw", + "match": "%[01]+" + } + ] + }, + "instructions": { + "comment": "All 32 instructions from xyw_instructions with optional modifiers", + "patterns": [ + { + "comment": "BRK and RTS have no modifiers", + "name": "variable.other.instruction.xyw", + "match": "\\b(BRK|RTS)\\b" + }, + { + "comment": "OVR and ROT only support w modifier", + "match": "\\b(OVR|ROT)(w?)\\b", + "captures": { + "1": { + "name": "variable.other.instruction.xyw" + }, + "2": { + "name": "storage.modifier.mode.xyw" + } + } + }, + { + "comment": "JMP, JCN, JSR support x or y (not both) and w", + "match": "\\b(JMP|JCN|JSR)([xy]?w?)\\b", + "captures": { + "1": { + "name": "variable.other.instruction.xyw" + }, + "2": { + "name": "storage.modifier.mode.xyw" + } + } + }, + { + "comment": "All other instructions with optional xyw modifiers", + "match": "\\b(PSH|POP|CLR|LDB|LDW|STB|STW|INC|DEC|SHL|SHR|ADD|SUB|MUL|DIV|EQU|NEQ|GTH|LTH|AND|IOR|XOR|NOT|SWP|DUP)([xyw]*)\\b", + "captures": { + "1": { + "name": "variable.other.instruction.xyw" + }, + "2": { + "name": "storage.modifier.mode.xyw" + } + } + } + ] + }, + "identifiers": { + "patterns": [ + { + "comment": "Device identifiers: system.*, terminal.*, file.*, clock.*, beeper.*", + "name": "support.type.device.xyw", + "match": "\\b(system|terminal|file|clock|beeper)\\.[a-zA-Z0-9_.\\-]*\\b" + }, + { + "comment": "Label/macro references: starts with letter/underscore, can contain letters, numbers, underscores, dashes, or dots", + "name": "entity.name.function.xyw", + "match": "\\b[a-zA-Z_][a-zA-Z0-9_.\\-]*\\b" + } + ] + } + } +}