Adapt languages to new syntax token scheme

This commit is contained in:
Nilay Majorwar 2022-02-03 22:39:02 +05:30
parent 24c384c4a8
commit 8d979ef111
5 changed files with 45 additions and 26 deletions

View File

@ -66,13 +66,13 @@ export const sampleProgram = [
export const editorTokensProvider: MonacoTokensProvider = {
tokenizer: {
root: [
[/[\>\^<v\?]/, "red"],
[/[\+\-\*\/%!`]/, "orange"],
[/[|_]/, "blue"],
[/[":\\#]/, "green"],
[/[\$\.,]/, "violet"],
[/[gp@]/, "indigo"],
[/[&~0-9]/, "turquoise"],
[/[\>\^<v\?]/, "variable"],
[/[\+\-\*\/%!`]/, "operators"],
[/[|_]/, "meta"],
[/[":\\#]/, "tag"],
[/[\$\.,]/, "keyword"],
[/[gp@]/, "attribute"],
[/[&~0-9]/, "string"],
],
},
defaultToken: "plain",

View File

@ -71,10 +71,10 @@ export const sampleProgram = [
export const editorTokensProvider: MonacoTokensProvider = {
tokenizer: {
root: [
[/[-\+]/, "plain"],
[/[<>]/, "green"],
[/[\[\]]/, "violet"],
[/[\,\.]/, "orange"],
[/[-\+]/, ""],
[/[<>]/, "tag"],
[/[\[\]]/, "keyword"],
[/[\,\.]/, "identifier"],
],
},
defaultToken: "comment",

View File

@ -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 */

View File

@ -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: "",
};

View File

@ -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",