123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461 |
- /*!-----------------------------------------------------------------------------
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Version: 0.31.1(337587859b1c171314b40503171188b6cea6a32a)
- * Released under the MIT license
- * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
- *-----------------------------------------------------------------------------*/
- define("vs/basic-languages/ruby/ruby",[],()=>{
- var moduleExports = (() => {
- var __defProp = Object.defineProperty;
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
- var __export = (target, all) => {
- __markAsModule(target);
- for (var name in all)
- __defProp(target, name, { get: all[name], enumerable: true });
- };
- // src/basic-languages/ruby/ruby.ts
- var ruby_exports = {};
- __export(ruby_exports, {
- conf: () => conf,
- language: () => language
- });
- var conf = {
- comments: {
- lineComment: "#",
- blockComment: ["=begin", "=end"]
- },
- brackets: [
- ["(", ")"],
- ["{", "}"],
- ["[", "]"]
- ],
- autoClosingPairs: [
- { open: "{", close: "}" },
- { open: "[", close: "]" },
- { open: "(", close: ")" },
- { open: '"', close: '"' },
- { open: "'", close: "'" }
- ],
- surroundingPairs: [
- { open: "{", close: "}" },
- { open: "[", close: "]" },
- { open: "(", close: ")" },
- { open: '"', close: '"' },
- { open: "'", close: "'" }
- ],
- indentationRules: {
- increaseIndentPattern: new RegExp(`^\\s*((begin|class|(private|protected)\\s+def|def|else|elsif|ensure|for|if|module|rescue|unless|until|when|while|case)|([^#]*\\sdo\\b)|([^#]*=\\s*(case|if|unless)))\\b([^#\\{;]|("|'|/).*\\4)*(#.*)?$`),
- decreaseIndentPattern: new RegExp("^\\s*([}\\]]([,)]?\\s*(#|$)|\\.[a-zA-Z_]\\w*\\b)|(end|rescue|ensure|else|elsif|when)\\b)")
- }
- };
- var language = {
- tokenPostfix: ".ruby",
- keywords: [
- "__LINE__",
- "__ENCODING__",
- "__FILE__",
- "BEGIN",
- "END",
- "alias",
- "and",
- "begin",
- "break",
- "case",
- "class",
- "def",
- "defined?",
- "do",
- "else",
- "elsif",
- "end",
- "ensure",
- "for",
- "false",
- "if",
- "in",
- "module",
- "next",
- "nil",
- "not",
- "or",
- "redo",
- "rescue",
- "retry",
- "return",
- "self",
- "super",
- "then",
- "true",
- "undef",
- "unless",
- "until",
- "when",
- "while",
- "yield"
- ],
- keywordops: ["::", "..", "...", "?", ":", "=>"],
- builtins: [
- "require",
- "public",
- "private",
- "include",
- "extend",
- "attr_reader",
- "protected",
- "private_class_method",
- "protected_class_method",
- "new"
- ],
- declarations: [
- "module",
- "class",
- "def",
- "case",
- "do",
- "begin",
- "for",
- "if",
- "while",
- "until",
- "unless"
- ],
- linedecls: ["def", "case", "do", "begin", "for", "if", "while", "until", "unless"],
- operators: [
- "^",
- "&",
- "|",
- "<=>",
- "==",
- "===",
- "!~",
- "=~",
- ">",
- ">=",
- "<",
- "<=",
- "<<",
- ">>",
- "+",
- "-",
- "*",
- "/",
- "%",
- "**",
- "~",
- "+@",
- "-@",
- "[]",
- "[]=",
- "`",
- "+=",
- "-=",
- "*=",
- "**=",
- "/=",
- "^=",
- "%=",
- "<<=",
- ">>=",
- "&=",
- "&&=",
- "||=",
- "|="
- ],
- brackets: [
- { open: "(", close: ")", token: "delimiter.parenthesis" },
- { open: "{", close: "}", token: "delimiter.curly" },
- { open: "[", close: "]", token: "delimiter.square" }
- ],
- symbols: /[=><!~?:&|+\-*\/\^%\.]+/,
- escape: /(?:[abefnrstv\\"'\n\r]|[0-7]{1,3}|x[0-9A-Fa-f]{1,2}|u[0-9A-Fa-f]{4})/,
- escapes: /\\(?:C\-(@escape|.)|c(@escape|.)|@escape)/,
- decpart: /\d(_?\d)*/,
- decimal: /0|@decpart/,
- delim: /[^a-zA-Z0-9\s\n\r]/,
- heredelim: /(?:\w+|'[^']*'|"[^"]*"|`[^`]*`)/,
- regexpctl: /[(){}\[\]\$\^|\-*+?\.]/,
- regexpesc: /\\(?:[AzZbBdDfnrstvwWn0\\\/]|@regexpctl|c[A-Z]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4})?/,
- tokenizer: {
- root: [
- [
- /^(\s*)([a-z_]\w*[!?=]?)/,
- [
- "white",
- {
- cases: {
- "for|until|while": {
- token: "keyword.$2",
- next: "@dodecl.$2"
- },
- "@declarations": {
- token: "keyword.$2",
- next: "@root.$2"
- },
- end: { token: "keyword.$S2", next: "@pop" },
- "@keywords": "keyword",
- "@builtins": "predefined",
- "@default": "identifier"
- }
- }
- ]
- ],
- [
- /[a-z_]\w*[!?=]?/,
- {
- cases: {
- "if|unless|while|until": {
- token: "keyword.$0x",
- next: "@modifier.$0x"
- },
- for: { token: "keyword.$2", next: "@dodecl.$2" },
- "@linedecls": { token: "keyword.$0", next: "@root.$0" },
- end: { token: "keyword.$S2", next: "@pop" },
- "@keywords": "keyword",
- "@builtins": "predefined",
- "@default": "identifier"
- }
- }
- ],
- [/[A-Z][\w]*[!?=]?/, "constructor.identifier"],
- [/\$[\w]*/, "global.constant"],
- [/@[\w]*/, "namespace.instance.identifier"],
- [/@@@[\w]*/, "namespace.class.identifier"],
- [/<<[-~](@heredelim).*/, { token: "string.heredoc.delimiter", next: "@heredoc.$1" }],
- [/[ \t\r\n]+<<(@heredelim).*/, { token: "string.heredoc.delimiter", next: "@heredoc.$1" }],
- [/^<<(@heredelim).*/, { token: "string.heredoc.delimiter", next: "@heredoc.$1" }],
- { include: "@whitespace" },
- [/"/, { token: "string.d.delim", next: '@dstring.d."' }],
- [/'/, { token: "string.sq.delim", next: "@sstring.sq" }],
- [/%([rsqxwW]|Q?)/, { token: "@rematch", next: "pstring" }],
- [/`/, { token: "string.x.delim", next: "@dstring.x.`" }],
- [/:(\w|[$@])\w*[!?=]?/, "string.s"],
- [/:"/, { token: "string.s.delim", next: '@dstring.s."' }],
- [/:'/, { token: "string.s.delim", next: "@sstring.s" }],
- [/\/(?=(\\\/|[^\/\n])+\/)/, { token: "regexp.delim", next: "@regexp" }],
- [/[{}()\[\]]/, "@brackets"],
- [
- /@symbols/,
- {
- cases: {
- "@keywordops": "keyword",
- "@operators": "operator",
- "@default": ""
- }
- }
- ],
- [/[;,]/, "delimiter"],
- [/0[xX][0-9a-fA-F](_?[0-9a-fA-F])*/, "number.hex"],
- [/0[_oO][0-7](_?[0-7])*/, "number.octal"],
- [/0[bB][01](_?[01])*/, "number.binary"],
- [/0[dD]@decpart/, "number"],
- [
- /@decimal((\.@decpart)?([eE][\-+]?@decpart)?)/,
- {
- cases: {
- $1: "number.float",
- "@default": "number"
- }
- }
- ]
- ],
- dodecl: [
- [/^/, { token: "", switchTo: "@root.$S2" }],
- [
- /[a-z_]\w*[!?=]?/,
- {
- cases: {
- end: { token: "keyword.$S2", next: "@pop" },
- do: { token: "keyword", switchTo: "@root.$S2" },
- "@linedecls": {
- token: "@rematch",
- switchTo: "@root.$S2"
- },
- "@keywords": "keyword",
- "@builtins": "predefined",
- "@default": "identifier"
- }
- }
- ],
- { include: "@root" }
- ],
- modifier: [
- [/^/, "", "@pop"],
- [
- /[a-z_]\w*[!?=]?/,
- {
- cases: {
- end: { token: "keyword.$S2", next: "@pop" },
- "then|else|elsif|do": {
- token: "keyword",
- switchTo: "@root.$S2"
- },
- "@linedecls": {
- token: "@rematch",
- switchTo: "@root.$S2"
- },
- "@keywords": "keyword",
- "@builtins": "predefined",
- "@default": "identifier"
- }
- }
- ],
- { include: "@root" }
- ],
- sstring: [
- [/[^\\']+/, "string.$S2"],
- [/\\\\|\\'|\\$/, "string.$S2.escape"],
- [/\\./, "string.$S2.invalid"],
- [/'/, { token: "string.$S2.delim", next: "@pop" }]
- ],
- dstring: [
- [/[^\\`"#]+/, "string.$S2"],
- [/#/, "string.$S2.escape", "@interpolated"],
- [/\\$/, "string.$S2.escape"],
- [/@escapes/, "string.$S2.escape"],
- [/\\./, "string.$S2.escape.invalid"],
- [
- /[`"]/,
- {
- cases: {
- "$#==$S3": { token: "string.$S2.delim", next: "@pop" },
- "@default": "string.$S2"
- }
- }
- ]
- ],
- heredoc: [
- [
- /^(\s*)(@heredelim)$/,
- {
- cases: {
- "$2==$S2": ["string.heredoc", { token: "string.heredoc.delimiter", next: "@pop" }],
- "@default": ["string.heredoc", "string.heredoc"]
- }
- }
- ],
- [/.*/, "string.heredoc"]
- ],
- interpolated: [
- [/\$\w*/, "global.constant", "@pop"],
- [/@\w*/, "namespace.class.identifier", "@pop"],
- [/@@@\w*/, "namespace.instance.identifier", "@pop"],
- [
- /[{]/,
- {
- token: "string.escape.curly",
- switchTo: "@interpolated_compound"
- }
- ],
- ["", "", "@pop"]
- ],
- interpolated_compound: [
- [/[}]/, { token: "string.escape.curly", next: "@pop" }],
- { include: "@root" }
- ],
- pregexp: [
- { include: "@whitespace" },
- [
- /[^\(\{\[\\]/,
- {
- cases: {
- "$#==$S3": { token: "regexp.delim", next: "@pop" },
- "$#==$S2": { token: "regexp.delim", next: "@push" },
- "~[)}\\]]": "@brackets.regexp.escape.control",
- "~@regexpctl": "regexp.escape.control",
- "@default": "regexp"
- }
- }
- ],
- { include: "@regexcontrol" }
- ],
- regexp: [
- { include: "@regexcontrol" },
- [/[^\\\/]/, "regexp"],
- ["/[ixmp]*", { token: "regexp.delim" }, "@pop"]
- ],
- regexcontrol: [
- [
- /(\{)(\d+(?:,\d*)?)(\})/,
- [
- "@brackets.regexp.escape.control",
- "regexp.escape.control",
- "@brackets.regexp.escape.control"
- ]
- ],
- [
- /(\[)(\^?)/,
- ["@brackets.regexp.escape.control", { token: "regexp.escape.control", next: "@regexrange" }]
- ],
- [/(\()(\?[:=!])/, ["@brackets.regexp.escape.control", "regexp.escape.control"]],
- [/\(\?#/, { token: "regexp.escape.control", next: "@regexpcomment" }],
- [/[()]/, "@brackets.regexp.escape.control"],
- [/@regexpctl/, "regexp.escape.control"],
- [/\\$/, "regexp.escape"],
- [/@regexpesc/, "regexp.escape"],
- [/\\\./, "regexp.invalid"],
- [/#/, "regexp.escape", "@interpolated"]
- ],
- regexrange: [
- [/-/, "regexp.escape.control"],
- [/\^/, "regexp.invalid"],
- [/\\$/, "regexp.escape"],
- [/@regexpesc/, "regexp.escape"],
- [/[^\]]/, "regexp"],
- [/\]/, "@brackets.regexp.escape.control", "@pop"]
- ],
- regexpcomment: [
- [/[^)]+/, "comment"],
- [/\)/, { token: "regexp.escape.control", next: "@pop" }]
- ],
- pstring: [
- [/%([qws])\(/, { token: "string.$1.delim", switchTo: "@qstring.$1.(.)" }],
- [/%([qws])\[/, { token: "string.$1.delim", switchTo: "@qstring.$1.[.]" }],
- [/%([qws])\{/, { token: "string.$1.delim", switchTo: "@qstring.$1.{.}" }],
- [/%([qws])</, { token: "string.$1.delim", switchTo: "@qstring.$1.<.>" }],
- [/%([qws])(@delim)/, { token: "string.$1.delim", switchTo: "@qstring.$1.$2.$2" }],
- [/%r\(/, { token: "regexp.delim", switchTo: "@pregexp.(.)" }],
- [/%r\[/, { token: "regexp.delim", switchTo: "@pregexp.[.]" }],
- [/%r\{/, { token: "regexp.delim", switchTo: "@pregexp.{.}" }],
- [/%r</, { token: "regexp.delim", switchTo: "@pregexp.<.>" }],
- [/%r(@delim)/, { token: "regexp.delim", switchTo: "@pregexp.$1.$1" }],
- [/%(x|W|Q?)\(/, { token: "string.$1.delim", switchTo: "@qqstring.$1.(.)" }],
- [/%(x|W|Q?)\[/, { token: "string.$1.delim", switchTo: "@qqstring.$1.[.]" }],
- [/%(x|W|Q?)\{/, { token: "string.$1.delim", switchTo: "@qqstring.$1.{.}" }],
- [/%(x|W|Q?)</, { token: "string.$1.delim", switchTo: "@qqstring.$1.<.>" }],
- [/%(x|W|Q?)(@delim)/, { token: "string.$1.delim", switchTo: "@qqstring.$1.$2.$2" }],
- [/%([rqwsxW]|Q?)./, { token: "invalid", next: "@pop" }],
- [/./, { token: "invalid", next: "@pop" }]
- ],
- qstring: [
- [/\\$/, "string.$S2.escape"],
- [/\\./, "string.$S2.escape"],
- [
- /./,
- {
- cases: {
- "$#==$S4": { token: "string.$S2.delim", next: "@pop" },
- "$#==$S3": { token: "string.$S2.delim", next: "@push" },
- "@default": "string.$S2"
- }
- }
- ]
- ],
- qqstring: [[/#/, "string.$S2.escape", "@interpolated"], { include: "@qstring" }],
- whitespace: [
- [/[ \t\r\n]+/, ""],
- [/^\s*=begin\b/, "comment", "@comment"],
- [/#.*$/, "comment"]
- ],
- comment: [
- [/[^=]+/, "comment"],
- [/^\s*=begin\b/, "comment.invalid"],
- [/^\s*=end\b.*/, "comment", "@pop"],
- [/[=]/, "comment"]
- ]
- }
- };
- return ruby_exports;
- })();
- return moduleExports;
- });
|