Add Rockstar syntax highlighting
This commit is contained in:
parent
8d979ef111
commit
21df6fa0f1
@ -7,7 +7,7 @@ export const sampleProgram = [
|
||||
``,
|
||||
`Give back your heart`,
|
||||
``,
|
||||
``,
|
||||
`(♬ FizzBuzz riff plays ♬)`, // :)
|
||||
`Desire is a lovestruck ladykiller`,
|
||||
`My world is nothing `,
|
||||
`Fire is ice`,
|
||||
@ -29,21 +29,88 @@ export const sampleProgram = [
|
||||
`Whisper my world`,
|
||||
].join("\n");
|
||||
|
||||
// prettier-ignore
|
||||
const MAYBE_EQ_COMPARE_WORDS = ["high", "great", "big", "strong", "low", "little", "small", "weak"]
|
||||
const MAYBE_EQ_COMPARE_REGEX = MAYBE_EQ_COMPARE_WORDS.join("|");
|
||||
|
||||
// prettier-ignore
|
||||
const NON_EQ_COMPARE_WORDS = ["higher", "greater", "bigger", "stronger", "lower", "less", "smaller", "weaker"];
|
||||
const NON_EQ_COMPARE_REGEX = NON_EQ_COMPARE_WORDS.join("|");
|
||||
|
||||
/** Syntax highlighting */
|
||||
export const editorTokensProvider: MonacoTokensProvider = {
|
||||
ignoreCase: true,
|
||||
|
||||
// prettier-ignore
|
||||
varPronouns: ["it", "he", "she", "him", "her", "they", "them",
|
||||
"ze", "hir", "zie", "zir", "xe", "xem", "ve", "ver"],
|
||||
|
||||
// prettier-ignore
|
||||
operators: ["plus", "with", "minus", "without", "times", "of", "over", "between",
|
||||
"build", "knock", "up", "down", "is", "are", "was", "were", "ain't", "aren't",
|
||||
"wasn't", "weren't", "and", "or", "nor", "not"],
|
||||
|
||||
// prettier-ignore
|
||||
inbuiltFns: ["say", "shout", "whisper", "scream", "cast", "burn", "rock", "push",
|
||||
"roll", "pop", "cut", "split", "shatter", "join", "unite"],
|
||||
|
||||
// prettier-ignore
|
||||
keywords: ["if", "else", "while", "until", "break", "continue", "put", "let", "be",
|
||||
"into", "give", "return", "back"],
|
||||
|
||||
// prettier-ignore
|
||||
constants: ["mysterious", "null", "nothing", "nowhere", "nobody", "gone", "true",
|
||||
"right", "yes", "ok", "false", "wrong", "no", "lies", "empty", "silent", "silence"],
|
||||
|
||||
tokenizer: {
|
||||
root: [
|
||||
[/\([^\)]*\)/, "comment"],
|
||||
[/\b(takes|wants|taking)\b/, "red"],
|
||||
[/\b(mysterious|null|nothing|nowhere|nobody|gone)\b/, "orange"],
|
||||
[/\b(true|right|yes|ok|false|wrong|no|lies)\b/, "orange"],
|
||||
[/\b(empty|silent|silence|".+")\b/, "green"],
|
||||
[/\b(if|else|while|until)/, "violet"],
|
||||
[/\b(break|break it down|continue|take it to the top)\b/, "violet"],
|
||||
[/\b(shout|say|whisper|scream)\b/, "blue"],
|
||||
[/\b(it|he|she|him|her|they|them|ze|hir|zie|zir|xe|xem|ve|ver)\b/, "red"],
|
||||
[/\(/, { token: "comment", next: "@comment" }],
|
||||
[/"/, { token: "string", next: "@string" }],
|
||||
[/,|\./, ""],
|
||||
// Function usage
|
||||
[
|
||||
// Allowing multi-word fn names here leads to too greedy rule,
|
||||
// so for syntax highlighting, we use only one-word functions
|
||||
/([a-zA-Z]+)( )(takes|wants|taking)( )/,
|
||||
["variable.function", "", "keyword", ""],
|
||||
],
|
||||
// Comparator clauses
|
||||
[
|
||||
/(is as )([a-zA-Z]+)( as)/,
|
||||
{ cases: { [`$2~${MAYBE_EQ_COMPARE_REGEX}`]: "operators" } },
|
||||
],
|
||||
[
|
||||
/(is )([a-zA-Z]+)( than)/,
|
||||
{ cases: { [`$2~${NON_EQ_COMPARE_REGEX}`]: "operators" } },
|
||||
],
|
||||
// Poetic string literals
|
||||
[/(says )(.+$)/, ["keyword", "string"]],
|
||||
// Multi-word keywords (can't be captured by keyword catchall)
|
||||
[/turn (up|down|round|around)\b/, "operators"],
|
||||
[/(break it down|take it to the top)/, "keyword"],
|
||||
[/listen to/, "constant.function"],
|
||||
// Catchall for keywords
|
||||
[
|
||||
/[^ \s]+/,
|
||||
{
|
||||
cases: {
|
||||
"@constants": "constant",
|
||||
"@keywords": "keyword",
|
||||
"@varPronouns": "variable",
|
||||
"@operators": "operators",
|
||||
"@inbuiltFns": "constant.function",
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
comment: [
|
||||
[/\)/, { token: "comment", next: "@pop" }],
|
||||
[/[^\)]*/, "comment"],
|
||||
],
|
||||
string: [
|
||||
[/"/, { token: "string", next: "@pop" }],
|
||||
[/[^"]*/, "string"],
|
||||
],
|
||||
},
|
||||
defaultToken: "plain",
|
||||
defaultToken: "variable",
|
||||
};
|
||||
|
@ -77,7 +77,9 @@
|
||||
{ "token": "strong", "fontStyle": "bold" },
|
||||
{ "token": "identifier", "foreground": "EC9A3C", "note": "orange" },
|
||||
{ "token": "variable", "foreground": "EF596F", "note": "red" },
|
||||
{ "token": "variable.function", "foreground": "61AFEF", "note": "blue" },
|
||||
{ "token": "constant", "foreground": "F0B726", "note": "gold" },
|
||||
{ "token": "constant.function", "foreground": "BDADFF", "note": "indigo" },
|
||||
{ "token": "number", "foreground": "F0B726", "note": "gold" },
|
||||
{ "token": "annotation", "foreground": "13C9BA", "note": "turquoise" },
|
||||
{ "token": "type", "foreground": "EC9A3C", "note": "orange" },
|
||||
|
@ -80,7 +80,9 @@
|
||||
{ "token": "strong", "fontStyle": "bold" },
|
||||
{ "token": "identifier", "foreground": "C87619", "note": "orange" },
|
||||
{ "token": "variable", "foreground": "CD4246", "note": "red" },
|
||||
{ "token": "variable.function", "foreground": "2D72D2", "note": "blue" },
|
||||
{ "token": "constant", "foreground": "D1980B", "note": "gold" },
|
||||
{ "token": "constant.function", "foreground": "634DBF", "note": "indigo" },
|
||||
{ "token": "number", "foreground": "D1980B", "note": "gold" },
|
||||
{ "token": "annotation", "foreground": "00A396", "note": "turquoise" },
|
||||
{ "token": "type", "foreground": "C87619", "note": "orange" },
|
||||
|
Loading…
x
Reference in New Issue
Block a user