Skip to content

Commit

Permalink
Improve highlighting of assembler index
Browse files Browse the repository at this point in the history
Previously all of `,X` or `,Y` was highlighted as `keyword`.  Now
the `,` is highlighted as `symbol`.
ojwb committed Jan 29, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent d57076b commit e00eded
Showing 2 changed files with 33 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/bbcbasic.js
Original file line number Diff line number Diff line change
@@ -203,7 +203,7 @@ export function registerBbcBasicLanguage() {
],
[/OPT|EQU[BDSW]/, "keyword.directive"],
[/\\[^:]*/, "comment"],
[/,\s*[XY]/, "keyword"],
[/,(?= *[XY]\b)/, {token: "symbol", switchTo: "@asmIndex"}],
["#", "symbol"], // Immediate addressing
// labels
[/\.([a-zA-Z_][\w]*%?|@%)/, "type.identifier"],
@@ -212,6 +212,10 @@ export function registerBbcBasicLanguage() {
{include: "@common"},
["]", {token: "delimiter.square", next: "@pop"}],
],
asmIndex: [
{include: "@whitespace"},
[/[XY]/, {token: "keyword", switchTo: "@asm"}],
],
},
});

29 changes: 28 additions & 1 deletion test/bbcbasic_test.js
Original file line number Diff line number Diff line change
@@ -183,10 +183,37 @@ describe("Tokenisation", () => {
],
);
checkTokens(
["[LDA"],
["[LDA(&70,X)"],
[
{offset: 0, type: "delimiter.square"},
{offset: 1, type: "keyword"},
{offset: 4, type: "delimiter.parenthesis"},
{offset: 5, type: "number.hex"},
{offset: 8, type: "symbol"},
{offset: 9, type: "keyword"},
{offset: 10, type: "delimiter.parenthesis"},
],
);
checkTokens(
["[STA(&80),Y"],
[
{offset: 0, type: "delimiter.square"},
{offset: 1, type: "keyword"},
{offset: 4, type: "delimiter.parenthesis"},
{offset: 5, type: "number.hex"},
{offset: 8, type: "delimiter.parenthesis"},
{offset: 9, type: "symbol"},
{offset: 10, type: "keyword"},
],
);
checkTokens(
["[ORA@%,X"],
[
{offset: 0, type: "delimiter.square"},
{offset: 1, type: "keyword"},
{offset: 4, type: "variable"},
{offset: 6, type: "symbol"},
{offset: 7, type: "keyword"},
],
);
checkTokens(

0 comments on commit e00eded

Please sign in to comment.