From 8d979ef111a144517a857c8b293682bc59cbe659 Mon Sep 17 00:00:00 2001 From: Nilay Majorwar Date: Thu, 3 Feb 2022 22:39:02 +0530 Subject: [PATCH] Adapt languages to new syntax token scheme --- languages/befunge93/constants.ts | 14 ++++++------ languages/brainfuck/common.ts | 8 +++---- languages/brainfuck/renderer.tsx | 4 ---- languages/chef/constants.ts | 37 ++++++++++++++++++++++++++------ languages/deadfish/constants.ts | 8 +++---- 5 files changed, 45 insertions(+), 26 deletions(-) diff --git a/languages/befunge93/constants.ts b/languages/befunge93/constants.ts index 360480a..4e951d6 100644 --- a/languages/befunge93/constants.ts +++ b/languages/befunge93/constants.ts @@ -66,13 +66,13 @@ export const sampleProgram = [ export const editorTokensProvider: MonacoTokensProvider = { tokenizer: { root: [ - [/[\>\^\^]/, "green"], - [/[\[\]]/, "violet"], - [/[\,\.]/, "orange"], + [/[-\+]/, ""], + [/[<>]/, "tag"], + [/[\[\]]/, "keyword"], + [/[\,\.]/, "identifier"], ], }, defaultToken: "comment", diff --git a/languages/brainfuck/renderer.tsx b/languages/brainfuck/renderer.tsx index a0274e1..73e5aa0 100644 --- a/languages/brainfuck/renderer.tsx +++ b/languages/brainfuck/renderer.tsx @@ -27,10 +27,6 @@ const styles: { [k: string]: CSSProperties } = { justifyContent: "center", alignItems: "center", }, - activeCell: { - background: "#CED9E0", - color: "#182026", - }, }; /** Component for displaying a single tape cell */ diff --git a/languages/chef/constants.ts b/languages/chef/constants.ts index 9ea606c..0c68e6d 100644 --- a/languages/chef/constants.ts +++ b/languages/chef/constants.ts @@ -17,7 +17,8 @@ export const isSyntaxError = (error: any): error is SyntaxError => { export const sampleProgram = [ "Hello World Souffle.", "", - 'This recipe prints the immortal words "Hello world!", in a basically brute force way. It also makes a lot of food for one person.', + 'This recipe prints the immortal words "Hello world!", in a basically ', + "brute force way. It also makes a lot of food for one person.", "", "Ingredients.", "72 g haricot beans", @@ -49,15 +50,37 @@ export const sampleProgram = [ "Serves 1.", ].join("\n"); +/** Syntax highlighting provider */ export const editorTokensProvider: MonacoTokensProvider = { tokenizer: { root: [ - [/Ingredients./, "red"], - [/Method./, "red"], - [/mixing bowl/, "green"], - [/baking dish/, "blue"], - [/\d(st|nd|rd|th)?/, "orange"], + [/^\s*$/, { token: "" }], + [/^.+$/, { token: "variable.function", next: "@recipe" }], + ], + recipe: [ + [/^\s*Ingredients\.\s*$/, { token: "annotation", next: "@ingredients" }], + [/^\s*Method\.\s*$/, { token: "annotation", next: "@method" }], + [ + /(^\s*)(Serves )(\d+)(\.\s*$)/, + ["", "", "number", { token: "", next: "@popall" }] as any, + ], + [/^.+$/, { token: "comment" }], + ], + ingredients: [ + [/\d+/, "number"], + [/ (g|kg|pinch(?:es)?|ml|l|dash(?:es)?) /, "type"], + [/ ((heaped|level) )?(cups?|teaspoons?|tablespoons?) /, "type"], + [/^\s*$/, { token: "", next: "@pop" }], + ], + method: [ + [/mixing bowl/, "tag"], + [/baking dish/, "meta"], + [ + /(^|\.\s*)(Take|Put|Fold|Add|Remove|Combine|Divide|Liquefy|Stir|Mix|Clean|Pour|Set aside|Serve with|Refrigerate)($| )/, + ["", "keyword", ""], + ], + [/^\s*$/, { token: "", next: "@pop" }], ], }, - defaultToken: "plain", + defaultToken: "", }; diff --git a/languages/deadfish/constants.ts b/languages/deadfish/constants.ts index 6459e6a..883d116 100644 --- a/languages/deadfish/constants.ts +++ b/languages/deadfish/constants.ts @@ -35,10 +35,10 @@ export const sampleProgram = [ export const editorTokensProvider: MonacoTokensProvider = { tokenizer: { root: [ - [/i/, "orange"], - [/d/, "red"], - [/s/, "blue"], - [/o/, "green"], + [/i/, "identifier"], + [/d/, "variable"], + [/s/, "meta"], + [/o/, "tag"], ], }, defaultToken: "comment",