Skip to content

Commit

Permalink
Reformatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgodbolt committed Jan 21, 2025
1 parent bceaafc commit e8f392d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
27 changes: 17 additions & 10 deletions src/bbcbasic.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ const allTokensForAsmRegex = keywords
.map(escape)
.join("|");

const allByteTokensRegex = "[" + keywords
.map(kw => String.fromCodePoint(kw.token < 160 ? kw.token + 0x100 : kw.token))
.join("") + "]";
const allByteTokensRegex =
"[" +
keywords
.map(kw => String.fromCodePoint(kw.token < 160 ? kw.token + 0x100 : kw.token))
.join("") +
"]";

function allAbbreviations(tokens) {
const prefixes = new Set();
Expand Down Expand Up @@ -116,7 +119,11 @@ export function registerBbcBasicLanguage() {
[/(\bREM|\xf4)$/, {token: "keyword"}], // A REM on its own line
[/(\bREM|\xf4)/, {token: "keyword", next: "@remStatement"}], // A REM consumes to EOL
[/(FN|PROC|\xa4|\xf2)/, {token: "keyword", next: "@fnProcName"}],
[/THEN|THE\.|TH\.|ELSE|ELS\.|EL\.|ERROR|ERRO\.|ERR\.|\u018c|\u018b|\u0185/, "keyword", "@pop"], // THEN, ELSE, ERROR end a statement
[
/THEN|THE\.|TH\.|ELSE|ELS\.|EL\.|ERROR|ERRO\.|ERR\.|\u018c|\u018b|\u0185/,
"keyword",
"@pop",
], // THEN, ELSE, ERROR end a statement
// This is slower than using the "tokens" built in to monarch but
// doesn't require whitespace delimited tokens.
[allTokensRegex, "keyword"],
Expand Down Expand Up @@ -271,12 +278,12 @@ export function registerBbcBasicLanguage() {
const LowerCaseTokenRegex = new RegExp(`^(${allTokensRegex.toLowerCase()})(?![%$])`);

const InvalidOperatorMap = new Map([
['==', '='],
['!=', '<>'],
['**', '^'],
['><', '<>'],
['=<', '<='],
['=>', '>='],
["==", "="],
["!=", "<>"],
["**", "^"],
["><", "<>"],
["=<", "<="],
["=>", ">="],
]);

export function getWarnings(lineNum, line, lineTokens) {
Expand Down
7 changes: 1 addition & 6 deletions test/bbcbasic_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,12 +472,7 @@ describe("Tokenisation", () => {
});
it("should highlight invalid operators from other languages", () => {
checkTokens(
[
"INVALID=1==2OR8!=2**3",
"IFA><1ORB=<2ORB=>6GOTO10",
"A+=2",
"A=B<<C OR D>>E"
],
["INVALID=1==2OR8!=2**3", "IFA><1ORB=<2ORB=>6GOTO10", "A+=2", "A=B<<C OR D>>E"],
[
{offset: 0, type: "variable"},
{offset: 7, type: "operator"},
Expand Down

0 comments on commit e8f392d

Please sign in to comment.