Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add asm syntax highlighting #238

Merged
merged 2 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 0 additions & 1 deletion web/src/pages/vm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ const VM = () => {
tst={[tst, setTst, state.test.highlight]}
out={[out, setOut]}
cmp={[cmp, setCmp]}
onLoadTest={actions.loadTest}
onSpeedChange={onSpeedChange}
/>
)}
Expand Down
Loading