rust.js 7.4 KB

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