rust.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. "use strict";
  2. /*!-----------------------------------------------------------------------------
  3. * Copyright (c) Microsoft Corporation. All rights reserved.
  4. * Version: 0.38.0(0e330ae453813de4e6cf272460fb79c7117073d0)
  5. * Released under the MIT license
  6. * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
  7. *-----------------------------------------------------------------------------*/
  8. define("vs/basic-languages/rust/rust", ["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/rust/rust.ts
  28. var rust_exports = {};
  29. __export(rust_exports, {
  30. conf: () => conf,
  31. language: () => language
  32. });
  33. var conf = {
  34. comments: {
  35. lineComment: "//",
  36. blockComment: ["/*", "*/"]
  37. },
  38. brackets: [
  39. ["{", "}"],
  40. ["[", "]"],
  41. ["(", ")"]
  42. ],
  43. autoClosingPairs: [
  44. { open: "[", close: "]" },
  45. { open: "{", close: "}" },
  46. { open: "(", close: ")" },
  47. { open: '"', close: '"', notIn: ["string"] }
  48. ],
  49. surroundingPairs: [
  50. { open: "{", close: "}" },
  51. { open: "[", close: "]" },
  52. { open: "(", close: ")" },
  53. { open: '"', close: '"' },
  54. { open: "'", close: "'" }
  55. ],
  56. folding: {
  57. markers: {
  58. start: new RegExp("^\\s*#pragma\\s+region\\b"),
  59. end: new RegExp("^\\s*#pragma\\s+endregion\\b")
  60. }
  61. }
  62. };
  63. var language = {
  64. tokenPostfix: ".rust",
  65. defaultToken: "invalid",
  66. keywords: [
  67. "as",
  68. "async",
  69. "await",
  70. "box",
  71. "break",
  72. "const",
  73. "continue",
  74. "crate",
  75. "dyn",
  76. "else",
  77. "enum",
  78. "extern",
  79. "false",
  80. "fn",
  81. "for",
  82. "if",
  83. "impl",
  84. "in",
  85. "let",
  86. "loop",
  87. "match",
  88. "mod",
  89. "move",
  90. "mut",
  91. "pub",
  92. "ref",
  93. "return",
  94. "self",
  95. "static",
  96. "struct",
  97. "super",
  98. "trait",
  99. "true",
  100. "try",
  101. "type",
  102. "unsafe",
  103. "use",
  104. "where",
  105. "while",
  106. "catch",
  107. "default",
  108. "union",
  109. "static",
  110. "abstract",
  111. "alignof",
  112. "become",
  113. "do",
  114. "final",
  115. "macro",
  116. "offsetof",
  117. "override",
  118. "priv",
  119. "proc",
  120. "pure",
  121. "sizeof",
  122. "typeof",
  123. "unsized",
  124. "virtual",
  125. "yield"
  126. ],
  127. typeKeywords: [
  128. "Self",
  129. "m32",
  130. "m64",
  131. "m128",
  132. "f80",
  133. "f16",
  134. "f128",
  135. "int",
  136. "uint",
  137. "float",
  138. "char",
  139. "bool",
  140. "u8",
  141. "u16",
  142. "u32",
  143. "u64",
  144. "f32",
  145. "f64",
  146. "i8",
  147. "i16",
  148. "i32",
  149. "i64",
  150. "str",
  151. "Option",
  152. "Either",
  153. "c_float",
  154. "c_double",
  155. "c_void",
  156. "FILE",
  157. "fpos_t",
  158. "DIR",
  159. "dirent",
  160. "c_char",
  161. "c_schar",
  162. "c_uchar",
  163. "c_short",
  164. "c_ushort",
  165. "c_int",
  166. "c_uint",
  167. "c_long",
  168. "c_ulong",
  169. "size_t",
  170. "ptrdiff_t",
  171. "clock_t",
  172. "time_t",
  173. "c_longlong",
  174. "c_ulonglong",
  175. "intptr_t",
  176. "uintptr_t",
  177. "off_t",
  178. "dev_t",
  179. "ino_t",
  180. "pid_t",
  181. "mode_t",
  182. "ssize_t"
  183. ],
  184. constants: ["true", "false", "Some", "None", "Left", "Right", "Ok", "Err"],
  185. supportConstants: [
  186. "EXIT_FAILURE",
  187. "EXIT_SUCCESS",
  188. "RAND_MAX",
  189. "EOF",
  190. "SEEK_SET",
  191. "SEEK_CUR",
  192. "SEEK_END",
  193. "_IOFBF",
  194. "_IONBF",
  195. "_IOLBF",
  196. "BUFSIZ",
  197. "FOPEN_MAX",
  198. "FILENAME_MAX",
  199. "L_tmpnam",
  200. "TMP_MAX",
  201. "O_RDONLY",
  202. "O_WRONLY",
  203. "O_RDWR",
  204. "O_APPEND",
  205. "O_CREAT",
  206. "O_EXCL",
  207. "O_TRUNC",
  208. "S_IFIFO",
  209. "S_IFCHR",
  210. "S_IFBLK",
  211. "S_IFDIR",
  212. "S_IFREG",
  213. "S_IFMT",
  214. "S_IEXEC",
  215. "S_IWRITE",
  216. "S_IREAD",
  217. "S_IRWXU",
  218. "S_IXUSR",
  219. "S_IWUSR",
  220. "S_IRUSR",
  221. "F_OK",
  222. "R_OK",
  223. "W_OK",
  224. "X_OK",
  225. "STDIN_FILENO",
  226. "STDOUT_FILENO",
  227. "STDERR_FILENO"
  228. ],
  229. supportMacros: [
  230. "format!",
  231. "print!",
  232. "println!",
  233. "panic!",
  234. "format_args!",
  235. "unreachable!",
  236. "write!",
  237. "writeln!"
  238. ],
  239. operators: [
  240. "!",
  241. "!=",
  242. "%",
  243. "%=",
  244. "&",
  245. "&=",
  246. "&&",
  247. "*",
  248. "*=",
  249. "+",
  250. "+=",
  251. "-",
  252. "-=",
  253. "->",
  254. ".",
  255. "..",
  256. "...",
  257. "/",
  258. "/=",
  259. ":",
  260. ";",
  261. "<<",
  262. "<<=",
  263. "<",
  264. "<=",
  265. "=",
  266. "==",
  267. "=>",
  268. ">",
  269. ">=",
  270. ">>",
  271. ">>=",
  272. "@",
  273. "^",
  274. "^=",
  275. "|",
  276. "|=",
  277. "||",
  278. "_",
  279. "?",
  280. "#"
  281. ],
  282. escapes: /\\([nrt0\"''\\]|x\h{2}|u\{\h{1,6}\})/,
  283. delimiters: /[,]/,
  284. symbols: /[\#\!\%\&\*\+\-\.\/\:\;\<\=\>\@\^\|_\?]+/,
  285. intSuffixes: /[iu](8|16|32|64|128|size)/,
  286. floatSuffixes: /f(32|64)/,
  287. tokenizer: {
  288. root: [
  289. [/r(#*)"/, { token: "string.quote", bracket: "@open", next: "@stringraw.$1" }],
  290. [
  291. /[a-zA-Z][a-zA-Z0-9_]*!?|_[a-zA-Z0-9_]+/,
  292. {
  293. cases: {
  294. "@typeKeywords": "keyword.type",
  295. "@keywords": "keyword",
  296. "@supportConstants": "keyword",
  297. "@supportMacros": "keyword",
  298. "@constants": "keyword",
  299. "@default": "identifier"
  300. }
  301. }
  302. ],
  303. [/\$/, "identifier"],
  304. [/'[a-zA-Z_][a-zA-Z0-9_]*(?=[^\'])/, "identifier"],
  305. [/'(\S|@escapes)'/, "string.byteliteral"],
  306. [/"/, { token: "string.quote", bracket: "@open", next: "@string" }],
  307. { include: "@numbers" },
  308. { include: "@whitespace" },
  309. [
  310. /@delimiters/,
  311. {
  312. cases: {
  313. "@keywords": "keyword",
  314. "@default": "delimiter"
  315. }
  316. }
  317. ],
  318. [/[{}()\[\]<>]/, "@brackets"],
  319. [/@symbols/, { cases: { "@operators": "operator", "@default": "" } }]
  320. ],
  321. whitespace: [
  322. [/[ \t\r\n]+/, "white"],
  323. [/\/\*/, "comment", "@comment"],
  324. [/\/\/.*$/, "comment"]
  325. ],
  326. comment: [
  327. [/[^\/*]+/, "comment"],
  328. [/\/\*/, "comment", "@push"],
  329. ["\\*/", "comment", "@pop"],
  330. [/[\/*]/, "comment"]
  331. ],
  332. string: [
  333. [/[^\\"]+/, "string"],
  334. [/@escapes/, "string.escape"],
  335. [/\\./, "string.escape.invalid"],
  336. [/"/, { token: "string.quote", bracket: "@close", next: "@pop" }]
  337. ],
  338. stringraw: [
  339. [/[^"#]+/, { token: "string" }],
  340. [
  341. /"(#*)/,
  342. {
  343. cases: {
  344. "$1==$S2": { token: "string.quote", bracket: "@close", next: "@pop" },
  345. "@default": { token: "string" }
  346. }
  347. }
  348. ],
  349. [/["#]/, { token: "string" }]
  350. ],
  351. numbers: [
  352. [/(0o[0-7_]+)(@intSuffixes)?/, { token: "number" }],
  353. [/(0b[0-1_]+)(@intSuffixes)?/, { token: "number" }],
  354. [/[\d][\d_]*(\.[\d][\d_]*)?[eE][+-][\d_]+(@floatSuffixes)?/, { token: "number" }],
  355. [/\b(\d\.?[\d_]*)(@floatSuffixes)?\b/, { token: "number" }],
  356. [/(0x[\da-fA-F]+)_?(@intSuffixes)?/, { token: "number" }],
  357. [/[\d][\d_]*(@intSuffixes?)?/, { token: "number" }]
  358. ]
  359. }
  360. };
  361. return __toCommonJS(rust_exports);
  362. })();
  363. return moduleExports;
  364. });