Skip to content

Commit

Permalink
Add asm syntax highlighting (#238)
Browse files Browse the repository at this point in the history
* Add asm syntax highlighting
* Remove unused @escapes

---------

Co-authored-by: David Souther <[email protected]>
  • Loading branch information
netalondon and DavidSouther authored Mar 11, 2024
1 parent 7bd3270 commit 525dc83
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
13 changes: 5 additions & 8 deletions web/src/languages/asm.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import * as monaco from "monaco-editor/esm/vs/editor/editor.api";
import { base } from "./base";

export const CmpLanguage: monaco.languages.IMonarchLanguage = {
export const AsmLanguage: monaco.languages.IMonarchLanguage = {
tokenizer: {
root: [
// identifiers and keywords
[/@[\w_]+/, "identifier"],
[/\([\w_]+)/, "identifier"],
[
/([AMD]+=)?(0|-?1|!?[ADM][-+&|][ADM])(;J(GT|EQ|LT|NE|LE|MP))?/,
"identifier",
],
[/(JGT|JLT|JGE|JLE|JEQ|JMP|[AMD]{1,3}|R\d+)/, "keyword"],
[/(\+|-|!|=|&&|\|\|)/, "operators"],
[/[\d]+/, "number"],
[/[\w_]+/, "identifier"],

// whitespace
{ include: "@whitespace" },
Expand Down
1 change: 0 additions & 1 deletion web/src/languages/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export const base: monaco.languages.IMonarchLanguage = {

string: [
[/[^\\"]+/, "string"],
[/@escapes/, "string.escape"],
[/\\./, "string.escape.invalid"],
[/"/, { token: "string.quote", bracket: "@close", next: "@pop" }],
],
Expand Down
1 change: 1 addition & 0 deletions web/src/languages/hdl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export const HdlLanguage: monaco.languages.IMonarchLanguage = {
// characters
[/'[^\\']'/, "string"],
[/(')(@escapes)(')/, ["string", "string.escape", "string"]],
[/@escapes/, "string.escape"],
[/'/, "string.invalid"],
],

Expand Down
2 changes: 2 additions & 0 deletions web/src/languages/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import { loader } from "@monaco-editor/react";
import { CmpLanguage } from "./cmp";
import { HdlLanguage } from "./hdl";
import { TstLanguage } from "./tst";
import { AsmLanguage } from "./asm";

const LANGUAGES = {
hdl: HdlLanguage,
cmp: CmpLanguage,
tst: TstLanguage,
asm: AsmLanguage,
};

export async function registerLanguages() {
Expand Down

0 comments on commit 525dc83

Please sign in to comment.