messing around.

This commit is contained in:
ed
2026-08-14 22:43:27 -04:00
parent 7ec778a68e
commit d23b6a2a36
8 changed files with 35 additions and 23 deletions
Binary file not shown.
+10
View File
@@ -22,6 +22,7 @@ const TOKEN_TYPES = [
"tapeCop2Register",
"tapeDuffleType",
"tapeAttribute",
"keyword",
];
const TOKEN_MODIFIERS = ["declaration", "tapeRead", "tapeWrite", "tapeAuto"];
@@ -36,6 +37,14 @@ const ANNOTATIONS = new Set([
"atom_auto_reg", "phase_auto_reg", "atom_dbg_skip",
]);
const DSL_KEYWORDS = new Set([
"FI_", "I_", "NI_", "Relative_", "Struct_", "Enum_", "Union_",
"TypeR_", "TypeV_", "align_", "internal", "local_persist", "global",
"O_", "S_", "C_", "T_", "tmpl", "glue", "r_", "v_", "tr_", "tv_",
"rgcc", "rlit", "r_use", "r_set", "r_mod", "r_imm", "r_mem",
"enc_op", "enc_rs", "enc_rt", "enc_rd", "enc_imm", "enc_i", "enc_r",
]);
const DELAY_SLOT_KEYWORDS = new Set(["LdSlot_", "BdSlot_"]);
const CONTROL_FLOW_PREFIXES = /^(?:branch_|jump_|call_)/;
@@ -151,6 +160,7 @@ function classifyDocument(source, filePath, workspaceIndex, shouldCancel = () =>
if (!type && index.bindTypes.has(token.text)) type = "tapeBindType";
if (!type && index.types.has(token.text)) type = "tapeDuffleType";
if (!type && DSL_KEYWORDS.has(token.text)) type = "keyword";
if (!type && index.attributes.has(token.text)) type = "tapeAttribute";
if (!type) type = registerType(token.text, index);
if (!type && DELAY_SLOT_KEYWORDS.has(token.text)) type = "tapeDelaySlot";
+9 -7
View File
@@ -1,9 +1,9 @@
{
"name": "tape-atom-syntax",
"displayName": "Tape Atom DSL",
"description": "Source-derived semantic highlighting for the Tape/Atom MIPS macro DSL",
"name": "atomasm-psx",
"displayName": "AtomAsm-PSX",
"description": "Semantic highlighting for the PS1 Tape/Atom MIPS macro DSL",
"publisher": "local",
"version": "0.2.0",
"version": "0.3.0",
"engines": { "vscode": "^1.80.0" },
"categories": ["Programming Languages"],
"activationEvents": ["onLanguage:c", "onLanguage:cpp"],
@@ -17,7 +17,7 @@
],
"scripts": {
"test": "node --test test/*.test.js",
"package": "npx --yes @vscode/vsce@3.6.1 package --allow-missing-repository --skip-license --out tape-atom-syntax-0.2.0.vsix"
"package": "npx --yes @vscode/vsce@3.6.1 package --allow-missing-repository --skip-license --out atomasm-psx-0.3.0.vsix"
},
"contributes": {
"semanticTokenTypes": [
@@ -38,7 +38,8 @@
{ "id": "tapeGprRegister", "superType": "variable", "description": "MIPS GPR alias" },
{ "id": "tapeCop2Register", "superType": "variable", "description": "COP2 data or control register alias" },
{ "id": "tapeDuffleType", "superType": "type", "description": "Duffle type or type constructor" },
{ "id": "tapeAttribute", "superType": "keyword", "description": "Duffle linkage or storage attribute" }
{ "id": "tapeAttribute", "superType": "keyword", "description": "Duffle linkage or storage attribute" },
{ "id": "keyword", "description": "Standard keyword (DSL built-in macros)" }
],
"semanticTokenModifiers": [
{ "id": "tapeRead", "description": "Register declared in atom_reads" },
@@ -66,7 +67,8 @@
"tapeGprRegister": ["variable.other.constant.duffle.gpr"],
"tapeCop2Register": ["variable.other.constant.duffle.cop2"],
"tapeDuffleType": ["storage.type.duffle.type"],
"tapeAttribute": ["storage.modifier.duffle.attr"]
"tapeAttribute": ["storage.modifier.duffle.attr"],
"keyword": ["keyword"]
}
}
],
+3
View File
@@ -11,6 +11,9 @@ const BASE_TYPES = [
const BASE_ATTRIBUTES = [
"FI_", "I_", "NI_", "Relative_", "Struct_", "Enum_", "Union_",
"TypeR_", "TypeV_", "align_", "internal", "local_persist", "global",
"O_", "S_", "C_", "T_", "tmpl", "glue", "r_", "v_", "tr_", "tv_",
"rgcc", "rlit", "r_use", "r_set", "r_mod", "r_imm", "r_mem",
"enc_op", "enc_rs", "enc_rt", "enc_rd", "enc_imm", "enc_i", "enc_r",
];
function createIndex() {
@@ -64,8 +64,8 @@
"name": "storage.type.duffle.type"
},
"attributes": {
"match": "\\b(?:FI_|I_|NI_|Relative_|align_|internal|local_persist|global)\\b",
"name": "storage.modifier.duffle.attr"
"match": "\\b(?:FI_|I_|NI_|Relative_|align_|internal|local_persist|global|O_|S_|C_|T_|tmpl|glue|r_|v_|tr_|tv_|rgcc|rlit|r_use|r_set|r_mod|r_imm|r_mem|enc_op|enc_rs|enc_rt|enc_rd|enc_imm|enc_i|enc_r)\\b",
"name": "keyword"
}
}
}
+2 -5
View File
@@ -31,7 +31,7 @@ test("package semantic legend matches classifier exports", () => {
const contributedTypes = packageJson.contributes.semanticTokenTypes.map((entry) => entry.id);
const contributedModifiers = packageJson.contributes.semanticTokenModifiers.map((entry) => entry.id);
assert.equal(packageJson.version, "0.2.0");
assert.equal(packageJson.version, "0.3.0");
assert.deepEqual(contributedTypes, TOKEN_TYPES);
assert.deepEqual(contributedModifiers, TOKEN_MODIFIERS.filter((name) => name !== "declaration"));
});
@@ -59,7 +59,7 @@ test("every semantic token has a scope mapping; DSL-specific tokens also have gr
const grammarRequired = new Set([
"tapeAtomKeyword", "tapeAtomName", "tapeComponentKeyword", "tapeComponentName",
"tapeAnnotation", "tapeBindType", "tapePhase", "tapeLabel",
"tapeDelaySlot", "tapeDuffleType", "tapeAttribute",
"tapeDelaySlot", "tapeDuffleType", "keyword",
]);
for (const tokenType of TOKEN_TYPES) {
@@ -84,8 +84,5 @@ test("TextMate offset labels stay scoped to atom_offset calls", () => {
test("workspace enables semantic highlighting", () => {
const settings = readJson(path.resolve(ROOT, "..", "settings.json"));
assert.equal(settings["editor.semanticHighlighting.enabled"], true);
const semantic = settings["editor.semanticTokenColorCustomizations"];
assert.equal(semantic.enabled, true);
});