aboutsummaryrefslogtreecommitdiff
path: root/pu2/p2m-syntax
diff options
context:
space:
mode:
authorGravatar Moon Flower <moon@coffin.ir> 2025-08-11 11:34:18 +0330
committerGravatar Moon Flower <moon@coffin.ir> 2025-08-11 11:34:18 +0330
commit2fc20ad0b11e60ecfacc653024f2b582acad6e86 (patch)
treed7e3f793f32928e40a18c56d00875a5b8e74dc62 /pu2/p2m-syntax
parentvscode theme extension (diff)
ir2 initial release!
Diffstat (limited to 'pu2/p2m-syntax')
-rw-r--r--pu2/p2m-syntax/README.md9
-rw-r--r--pu2/p2m-syntax/language-configuration.json30
-rw-r--r--pu2/p2m-syntax/p2m-asm-syntax-0.0.1.vsixbin0 -> 3130 bytes
-rw-r--r--pu2/p2m-syntax/package.json30
-rw-r--r--pu2/p2m-syntax/syntaxes/p2m.tmLanguage105
5 files changed, 174 insertions, 0 deletions
diff --git a/pu2/p2m-syntax/README.md b/pu2/p2m-syntax/README.md
new file mode 100644
index 0000000..4dab972
--- /dev/null
+++ b/pu2/p2m-syntax/README.md
@@ -0,0 +1,9 @@
+# P2M Assembly - VSCode Syntax Extension
+
+This extension provides basic TextMate-based highlighting for PU2 / `.p2m` assembly files.
+
+## Install for development
+
+1. Run this script to create the files.
+2. Open the `p2m-syntax` folder in VS Code and press `F5` to run an Extension Development Host with the grammar.
+3. Optionally pack with `vsce package` to create a .vsix.
diff --git a/pu2/p2m-syntax/language-configuration.json b/pu2/p2m-syntax/language-configuration.json
new file mode 100644
index 0000000..92ebca0
--- /dev/null
+++ b/pu2/p2m-syntax/language-configuration.json
@@ -0,0 +1,30 @@
+{
+ "comments": {
+ "lineComment": "#"
+ },
+ "brackets": [
+ ["{", "}"],
+ ["[", "]"],
+ ["(", ")"]
+ ],
+ "autoClosingPairs": [
+ { "open": "{", "close": "}" },
+ { "open": "[", "close": "]" },
+ { "open": "(", "close": ")" },
+ { "open": "'", "close": "'", "notIn": ["string"] },
+ { "open": "\"", "close": "\"", "notIn": ["string"] }
+ ],
+ "surroundingPairs": [
+ { "open": "{", "close": "}" },
+ { "open": "[", "close": "]" },
+ { "open": "(", "close": ")" },
+ { "open": "'", "close": "'" },
+ { "open": "\"", "close": "\"" }
+ ],
+ "folding": {
+ "markers": {
+ "start": "^\\s*\\{",
+ "end": "^\\s*\\}"
+ }
+ }
+}
diff --git a/pu2/p2m-syntax/p2m-asm-syntax-0.0.1.vsix b/pu2/p2m-syntax/p2m-asm-syntax-0.0.1.vsix
new file mode 100644
index 0000000..65e5608
--- /dev/null
+++ b/pu2/p2m-syntax/p2m-asm-syntax-0.0.1.vsix
Binary files differ
diff --git a/pu2/p2m-syntax/package.json b/pu2/p2m-syntax/package.json
new file mode 100644
index 0000000..71b10a7
--- /dev/null
+++ b/pu2/p2m-syntax/package.json
@@ -0,0 +1,30 @@
+{
+ "name": "p2m-asm-syntax",
+ "displayName": "P2M Assembly (p2m)",
+ "description": "TextMate grammar for the PU2 / .p2m assembly + small language config for VS Code.",
+ "version": "0.0.1",
+ "publisher": "moonflower",
+ "engines": {
+ "vscode": "^1.50.0"
+ },
+ "categories": [
+ "Programming Languages"
+ ],
+ "contributes": {
+ "languages": [
+ {
+ "id": "p2m",
+ "aliases": ["p2m", "P2M", "p2m-asm"],
+ "extensions": [".p2m"],
+ "configuration": "./language-configuration.json"
+ }
+ ],
+ "grammars": [
+ {
+ "language": "p2m",
+ "scopeName": "source.p2m",
+ "path": "./syntaxes/p2m.tmLanguage"
+ }
+ ]
+ }
+}
diff --git a/pu2/p2m-syntax/syntaxes/p2m.tmLanguage b/pu2/p2m-syntax/syntaxes/p2m.tmLanguage
new file mode 100644
index 0000000..3aa35e0
--- /dev/null
+++ b/pu2/p2m-syntax/syntaxes/p2m.tmLanguage
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
+ "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+ <dict>
+ <key>name</key>
+ <string>P2M Assembly</string>
+
+ <key>scopeName</key>
+ <string>source.p2m</string>
+
+ <key>fileTypes</key>
+ <array>
+ <string>p2m</string>
+ </array>
+
+ <key>patterns</key>
+ <array>
+
+ <!-- comments -->
+ <dict>
+ <key>name</key>
+ <string>comment.line.number-sign.p2m</string>
+ <key>match</key>
+ <string>#.*$</string>
+ </dict>
+
+ <!-- block braces -->
+ <dict>
+ <key>name</key>
+ <string>punctuation.section.block.p2m</string>
+ <key>match</key>
+ <string>[\{\}]</string>
+ </dict>
+
+ <!-- mnemonics / instructions -->
+ <dict>
+ <key>name</key>
+ <string>keyword.control.mnemonic.p2m</string>
+ <key>match</key>
+ <string>\b(?:hlt|imm|lod|str|swp|add|sub|and|nnd)\b</string>
+ </dict>
+
+ <!-- registers (single-letter a b c v) -->
+ <dict>
+ <key>name</key>
+ <string>variable.other.register.p2m</string>
+ <key>match</key>
+ <string>\b(?:a|b|c|v)\b</string>
+ </dict>
+
+ <!-- memory references like m[10] -->
+ <dict>
+ <key>name</key>
+ <string>variable.other.memory.p2m</string>
+ <key>match</key>
+ <string>\bm\[\s*\d+\s*\]</string>
+ </dict>
+
+ <!-- at-index references like @0 -->
+ <dict>
+ <key>name</key>
+ <string>variable.parameter.memory-index.p2m</string>
+ <key>match</key>
+ <string>@\d+</string>
+ </dict>
+
+ <!-- numeric literals -->
+ <dict>
+ <key>name</key>
+ <string>constant.numeric.hex.p2m</string>
+ <key>match</key>
+ <string>\b0x[0-9A-Fa-f]+\b</string>
+ </dict>
+ <dict>
+ <key>name</key>
+ <string>constant.numeric.decimal.p2m</string>
+ <key>match</key>
+ <string>\b\d+\b</string>
+ </dict>
+
+ <!-- quoted chars -->
+ <dict>
+ <key>name</key>
+ <string>string.quoted.single.p2m</string>
+ <key>match</key>
+ <string>'(.)</string>
+ </dict>
+
+ <!-- inline annotations -->
+ <dict>
+ <key>name</key>
+ <string>comment.block.annotation.p2m</string>
+ <key>match</key>
+ <string>\([^\)]*\)</string>
+ </dict>
+
+ </array>
+
+ <key>repository</key>
+ <dict/>
+ <key>scope</key>
+ <string>source.p2m</string>
+ </dict>
+</plist>