scala.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. "use strict";
  2. /*!-----------------------------------------------------------------------------
  3. * Copyright (c) Microsoft Corporation. All rights reserved.
  4. * Version: 0.34.1(547870b6881302c5b4ff32173c16d06009e3588f)
  5. * Released under the MIT license
  6. * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
  7. *-----------------------------------------------------------------------------*/
  8. define("vs/basic-languages/scala/scala", ["require"],(require)=>{
  9. var moduleExports = (() => {
  10. var __defProp = Object.defineProperty;
  11. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  12. var __getOwnPropNames = Object.getOwnPropertyNames;
  13. var __hasOwnProp = Object.prototype.hasOwnProperty;
  14. var __export = (target, all) => {
  15. for (var name in all)
  16. __defProp(target, name, { get: all[name], enumerable: true });
  17. };
  18. var __copyProps = (to, from, except, desc) => {
  19. if (from && typeof from === "object" || typeof from === "function") {
  20. for (let key of __getOwnPropNames(from))
  21. if (!__hasOwnProp.call(to, key) && key !== except)
  22. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  23. }
  24. return to;
  25. };
  26. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  27. // src/basic-languages/scala/scala.ts
  28. var scala_exports = {};
  29. __export(scala_exports, {
  30. conf: () => conf,
  31. language: () => language
  32. });
  33. var conf = {
  34. wordPattern: /(unary_[@~!#%^&*()\-=+\\|:<>\/?]+)|([a-zA-Z_$][\w$]*?_=)|(`[^`]+`)|([a-zA-Z_$][\w$]*)/g,
  35. comments: {
  36. lineComment: "//",
  37. blockComment: ["/*", "*/"]
  38. },
  39. brackets: [
  40. ["{", "}"],
  41. ["[", "]"],
  42. ["(", ")"]
  43. ],
  44. autoClosingPairs: [
  45. { open: "{", close: "}" },
  46. { open: "[", close: "]" },
  47. { open: "(", close: ")" },
  48. { open: '"', close: '"' },
  49. { open: "'", close: "'" }
  50. ],
  51. surroundingPairs: [
  52. { open: "{", close: "}" },
  53. { open: "[", close: "]" },
  54. { open: "(", close: ")" },
  55. { open: '"', close: '"' },
  56. { open: "'", close: "'" }
  57. ],
  58. folding: {
  59. markers: {
  60. start: new RegExp("^\\s*//\\s*(?:(?:#?region\\b)|(?:<editor-fold\\b))"),
  61. end: new RegExp("^\\s*//\\s*(?:(?:#?endregion\\b)|(?:</editor-fold>))")
  62. }
  63. }
  64. };
  65. var language = {
  66. tokenPostfix: ".scala",
  67. keywords: [
  68. "asInstanceOf",
  69. "catch",
  70. "class",
  71. "classOf",
  72. "def",
  73. "do",
  74. "else",
  75. "extends",
  76. "finally",
  77. "for",
  78. "foreach",
  79. "forSome",
  80. "if",
  81. "import",
  82. "isInstanceOf",
  83. "macro",
  84. "match",
  85. "new",
  86. "object",
  87. "package",
  88. "return",
  89. "throw",
  90. "trait",
  91. "try",
  92. "type",
  93. "until",
  94. "val",
  95. "var",
  96. "while",
  97. "with",
  98. "yield",
  99. "given",
  100. "enum",
  101. "then"
  102. ],
  103. softKeywords: ["as", "export", "extension", "end", "derives", "on"],
  104. constants: ["true", "false", "null", "this", "super"],
  105. modifiers: [
  106. "abstract",
  107. "final",
  108. "implicit",
  109. "lazy",
  110. "override",
  111. "private",
  112. "protected",
  113. "sealed"
  114. ],
  115. softModifiers: ["inline", "opaque", "open", "transparent", "using"],
  116. name: /(?:[a-z_$][\w$]*|`[^`]+`)/,
  117. type: /(?:[A-Z][\w$]*)/,
  118. symbols: /[=><!~?:&|+\-*\/^\\%@#]+/,
  119. digits: /\d+(_+\d+)*/,
  120. hexdigits: /[[0-9a-fA-F]+(_+[0-9a-fA-F]+)*/,
  121. escapes: /\\(?:[btnfr\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  122. fstring_conv: /[bBhHsScCdoxXeEfgGaAt]|[Tn](?:[HIklMSLNpzZsQ]|[BbhAaCYyjmde]|[RTrDFC])/,
  123. tokenizer: {
  124. root: [
  125. [/\braw"""/, { token: "string.quote", bracket: "@open", next: "@rawstringt" }],
  126. [/\braw"/, { token: "string.quote", bracket: "@open", next: "@rawstring" }],
  127. [/\bs"""/, { token: "string.quote", bracket: "@open", next: "@sstringt" }],
  128. [/\bs"/, { token: "string.quote", bracket: "@open", next: "@sstring" }],
  129. [/\bf""""/, { token: "string.quote", bracket: "@open", next: "@fstringt" }],
  130. [/\bf"/, { token: "string.quote", bracket: "@open", next: "@fstring" }],
  131. [/"""/, { token: "string.quote", bracket: "@open", next: "@stringt" }],
  132. [/"/, { token: "string.quote", bracket: "@open", next: "@string" }],
  133. [/(@digits)[eE]([\-+]?(@digits))?[fFdD]?/, "number.float", "@allowMethod"],
  134. [/(@digits)\.(@digits)([eE][\-+]?(@digits))?[fFdD]?/, "number.float", "@allowMethod"],
  135. [/0[xX](@hexdigits)[Ll]?/, "number.hex", "@allowMethod"],
  136. [/(@digits)[fFdD]/, "number.float", "@allowMethod"],
  137. [/(@digits)[lL]?/, "number", "@allowMethod"],
  138. [/\b_\*/, "key"],
  139. [/\b(_)\b/, "keyword", "@allowMethod"],
  140. [/\bimport\b/, "keyword", "@import"],
  141. [/\b(case)([ \t]+)(class)\b/, ["keyword.modifier", "white", "keyword"]],
  142. [/\bcase\b/, "keyword", "@case"],
  143. [/\bva[lr]\b/, "keyword", "@vardef"],
  144. [
  145. /\b(def)([ \t]+)((?:unary_)?@symbols|@name(?:_=)|@name)/,
  146. ["keyword", "white", "identifier"]
  147. ],
  148. [/@name(?=[ \t]*:(?!:))/, "variable"],
  149. [/(\.)(@name|@symbols)/, ["operator", { token: "@rematch", next: "@allowMethod" }]],
  150. [/([{(])(\s*)(@name(?=\s*=>))/, ["@brackets", "white", "variable"]],
  151. [
  152. /@name/,
  153. {
  154. cases: {
  155. "@keywords": "keyword",
  156. "@softKeywords": "keyword",
  157. "@modifiers": "keyword.modifier",
  158. "@softModifiers": "keyword.modifier",
  159. "@constants": {
  160. token: "constant",
  161. next: "@allowMethod"
  162. },
  163. "@default": {
  164. token: "identifier",
  165. next: "@allowMethod"
  166. }
  167. }
  168. }
  169. ],
  170. [/@type/, "type", "@allowMethod"],
  171. { include: "@whitespace" },
  172. [/@[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*)*/, "annotation"],
  173. [/[{(]/, "@brackets"],
  174. [/[})]/, "@brackets", "@allowMethod"],
  175. [/\[/, "operator.square"],
  176. [/](?!\s*(?:va[rl]|def|type)\b)/, "operator.square", "@allowMethod"],
  177. [/]/, "operator.square"],
  178. [/([=-]>|<-|>:|<:|:>|<%)(?=[\s\w()[\]{},\."'`])/, "keyword"],
  179. [/@symbols/, "operator"],
  180. [/[;,\.]/, "delimiter"],
  181. [/'[a-zA-Z$][\w$]*(?!')/, "attribute.name"],
  182. [/'[^\\']'/, "string", "@allowMethod"],
  183. [/(')(@escapes)(')/, ["string", "string.escape", { token: "string", next: "@allowMethod" }]],
  184. [/'/, "string.invalid"]
  185. ],
  186. import: [
  187. [/;/, "delimiter", "@pop"],
  188. [/^|$/, "", "@pop"],
  189. [/[ \t]+/, "white"],
  190. [/[\n\r]+/, "white", "@pop"],
  191. [/\/\*/, "comment", "@comment"],
  192. [/@name|@type/, "type"],
  193. [/[(){}]/, "@brackets"],
  194. [/[[\]]/, "operator.square"],
  195. [/[\.,]/, "delimiter"]
  196. ],
  197. allowMethod: [
  198. [/^|$/, "", "@pop"],
  199. [/[ \t]+/, "white"],
  200. [/[\n\r]+/, "white", "@pop"],
  201. [/\/\*/, "comment", "@comment"],
  202. [/(?==>[\s\w([{])/, "keyword", "@pop"],
  203. [
  204. /(@name|@symbols)(?=[ \t]*[[({"'`]|[ \t]+(?:[+-]?\.?\d|\w))/,
  205. {
  206. cases: {
  207. "@keywords": { token: "keyword", next: "@pop" },
  208. "->|<-|>:|<:|<%": { token: "keyword", next: "@pop" },
  209. "@default": { token: "@rematch", next: "@pop" }
  210. }
  211. }
  212. ],
  213. ["", "", "@pop"]
  214. ],
  215. comment: [
  216. [/[^\/*]+/, "comment"],
  217. [/\/\*/, "comment", "@push"],
  218. [/\*\//, "comment", "@pop"],
  219. [/[\/*]/, "comment"]
  220. ],
  221. case: [
  222. [/\b_\*/, "key"],
  223. [/\b(_|true|false|null|this|super)\b/, "keyword", "@allowMethod"],
  224. [/\bif\b|=>/, "keyword", "@pop"],
  225. [/`[^`]+`/, "identifier", "@allowMethod"],
  226. [/@name/, "variable", "@allowMethod"],
  227. [/:::?|\||@(?![a-z_$])/, "keyword"],
  228. { include: "@root" }
  229. ],
  230. vardef: [
  231. [/\b_\*/, "key"],
  232. [/\b(_|true|false|null|this|super)\b/, "keyword"],
  233. [/@name/, "variable"],
  234. [/:::?|\||@(?![a-z_$])/, "keyword"],
  235. [/=|:(?!:)/, "operator", "@pop"],
  236. [/$/, "white", "@pop"],
  237. { include: "@root" }
  238. ],
  239. string: [
  240. [/[^\\"\n\r]+/, "string"],
  241. [/@escapes/, "string.escape"],
  242. [/\\./, "string.escape.invalid"],
  243. [
  244. /"/,
  245. {
  246. token: "string.quote",
  247. bracket: "@close",
  248. switchTo: "@allowMethod"
  249. }
  250. ]
  251. ],
  252. stringt: [
  253. [/[^\\"\n\r]+/, "string"],
  254. [/@escapes/, "string.escape"],
  255. [/\\./, "string.escape.invalid"],
  256. [/"(?=""")/, "string"],
  257. [
  258. /"""/,
  259. {
  260. token: "string.quote",
  261. bracket: "@close",
  262. switchTo: "@allowMethod"
  263. }
  264. ],
  265. [/"/, "string"]
  266. ],
  267. fstring: [
  268. [/@escapes/, "string.escape"],
  269. [
  270. /"/,
  271. {
  272. token: "string.quote",
  273. bracket: "@close",
  274. switchTo: "@allowMethod"
  275. }
  276. ],
  277. [/\$\$/, "string"],
  278. [/(\$)([a-z_]\w*)/, ["operator", "identifier"]],
  279. [/\$\{/, "operator", "@interp"],
  280. [/%%/, "string"],
  281. [
  282. /(%)([\-#+ 0,(])(\d+|\.\d+|\d+\.\d+)(@fstring_conv)/,
  283. ["metatag", "keyword.modifier", "number", "metatag"]
  284. ],
  285. [/(%)(\d+|\.\d+|\d+\.\d+)(@fstring_conv)/, ["metatag", "number", "metatag"]],
  286. [/(%)([\-#+ 0,(])(@fstring_conv)/, ["metatag", "keyword.modifier", "metatag"]],
  287. [/(%)(@fstring_conv)/, ["metatag", "metatag"]],
  288. [/./, "string"]
  289. ],
  290. fstringt: [
  291. [/@escapes/, "string.escape"],
  292. [/"(?=""")/, "string"],
  293. [
  294. /"""/,
  295. {
  296. token: "string.quote",
  297. bracket: "@close",
  298. switchTo: "@allowMethod"
  299. }
  300. ],
  301. [/\$\$/, "string"],
  302. [/(\$)([a-z_]\w*)/, ["operator", "identifier"]],
  303. [/\$\{/, "operator", "@interp"],
  304. [/%%/, "string"],
  305. [
  306. /(%)([\-#+ 0,(])(\d+|\.\d+|\d+\.\d+)(@fstring_conv)/,
  307. ["metatag", "keyword.modifier", "number", "metatag"]
  308. ],
  309. [/(%)(\d+|\.\d+|\d+\.\d+)(@fstring_conv)/, ["metatag", "number", "metatag"]],
  310. [/(%)([\-#+ 0,(])(@fstring_conv)/, ["metatag", "keyword.modifier", "metatag"]],
  311. [/(%)(@fstring_conv)/, ["metatag", "metatag"]],
  312. [/./, "string"]
  313. ],
  314. sstring: [
  315. [/@escapes/, "string.escape"],
  316. [
  317. /"/,
  318. {
  319. token: "string.quote",
  320. bracket: "@close",
  321. switchTo: "@allowMethod"
  322. }
  323. ],
  324. [/\$\$/, "string"],
  325. [/(\$)([a-z_]\w*)/, ["operator", "identifier"]],
  326. [/\$\{/, "operator", "@interp"],
  327. [/./, "string"]
  328. ],
  329. sstringt: [
  330. [/@escapes/, "string.escape"],
  331. [/"(?=""")/, "string"],
  332. [
  333. /"""/,
  334. {
  335. token: "string.quote",
  336. bracket: "@close",
  337. switchTo: "@allowMethod"
  338. }
  339. ],
  340. [/\$\$/, "string"],
  341. [/(\$)([a-z_]\w*)/, ["operator", "identifier"]],
  342. [/\$\{/, "operator", "@interp"],
  343. [/./, "string"]
  344. ],
  345. interp: [[/{/, "operator", "@push"], [/}/, "operator", "@pop"], { include: "@root" }],
  346. rawstring: [
  347. [/[^"]/, "string"],
  348. [
  349. /"/,
  350. {
  351. token: "string.quote",
  352. bracket: "@close",
  353. switchTo: "@allowMethod"
  354. }
  355. ]
  356. ],
  357. rawstringt: [
  358. [/[^"]/, "string"],
  359. [/"(?=""")/, "string"],
  360. [
  361. /"""/,
  362. {
  363. token: "string.quote",
  364. bracket: "@close",
  365. switchTo: "@allowMethod"
  366. }
  367. ],
  368. [/"/, "string"]
  369. ],
  370. whitespace: [
  371. [/[ \t\r\n]+/, "white"],
  372. [/\/\*/, "comment", "@comment"],
  373. [/\/\/.*$/, "comment"]
  374. ]
  375. }
  376. };
  377. return __toCommonJS(scala_exports);
  378. })();
  379. return moduleExports;
  380. });