cpp.js 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  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/cpp/cpp", ["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/cpp/cpp.ts
  28. var cpp_exports = {};
  29. __export(cpp_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", "comment"] },
  48. { open: '"', close: '"', notIn: ["string"] }
  49. ],
  50. surroundingPairs: [
  51. { open: "{", close: "}" },
  52. { open: "[", close: "]" },
  53. { open: "(", close: ")" },
  54. { open: '"', close: '"' },
  55. { open: "'", close: "'" }
  56. ],
  57. folding: {
  58. markers: {
  59. start: new RegExp("^\\s*#pragma\\s+region\\b"),
  60. end: new RegExp("^\\s*#pragma\\s+endregion\\b")
  61. }
  62. }
  63. };
  64. var language = {
  65. defaultToken: "",
  66. tokenPostfix: ".cpp",
  67. brackets: [
  68. { token: "delimiter.curly", open: "{", close: "}" },
  69. { token: "delimiter.parenthesis", open: "(", close: ")" },
  70. { token: "delimiter.square", open: "[", close: "]" },
  71. { token: "delimiter.angle", open: "<", close: ">" }
  72. ],
  73. keywords: [
  74. "abstract",
  75. "amp",
  76. "array",
  77. "auto",
  78. "bool",
  79. "break",
  80. "case",
  81. "catch",
  82. "char",
  83. "class",
  84. "const",
  85. "constexpr",
  86. "const_cast",
  87. "continue",
  88. "cpu",
  89. "decltype",
  90. "default",
  91. "delegate",
  92. "delete",
  93. "do",
  94. "double",
  95. "dynamic_cast",
  96. "each",
  97. "else",
  98. "enum",
  99. "event",
  100. "explicit",
  101. "export",
  102. "extern",
  103. "false",
  104. "final",
  105. "finally",
  106. "float",
  107. "for",
  108. "friend",
  109. "gcnew",
  110. "generic",
  111. "goto",
  112. "if",
  113. "in",
  114. "initonly",
  115. "inline",
  116. "int",
  117. "interface",
  118. "interior_ptr",
  119. "internal",
  120. "literal",
  121. "long",
  122. "mutable",
  123. "namespace",
  124. "new",
  125. "noexcept",
  126. "nullptr",
  127. "__nullptr",
  128. "operator",
  129. "override",
  130. "partial",
  131. "pascal",
  132. "pin_ptr",
  133. "private",
  134. "property",
  135. "protected",
  136. "public",
  137. "ref",
  138. "register",
  139. "reinterpret_cast",
  140. "restrict",
  141. "return",
  142. "safe_cast",
  143. "sealed",
  144. "short",
  145. "signed",
  146. "sizeof",
  147. "static",
  148. "static_assert",
  149. "static_cast",
  150. "struct",
  151. "switch",
  152. "template",
  153. "this",
  154. "thread_local",
  155. "throw",
  156. "tile_static",
  157. "true",
  158. "try",
  159. "typedef",
  160. "typeid",
  161. "typename",
  162. "union",
  163. "unsigned",
  164. "using",
  165. "virtual",
  166. "void",
  167. "volatile",
  168. "wchar_t",
  169. "where",
  170. "while",
  171. "_asm",
  172. "_based",
  173. "_cdecl",
  174. "_declspec",
  175. "_fastcall",
  176. "_if_exists",
  177. "_if_not_exists",
  178. "_inline",
  179. "_multiple_inheritance",
  180. "_pascal",
  181. "_single_inheritance",
  182. "_stdcall",
  183. "_virtual_inheritance",
  184. "_w64",
  185. "__abstract",
  186. "__alignof",
  187. "__asm",
  188. "__assume",
  189. "__based",
  190. "__box",
  191. "__builtin_alignof",
  192. "__cdecl",
  193. "__clrcall",
  194. "__declspec",
  195. "__delegate",
  196. "__event",
  197. "__except",
  198. "__fastcall",
  199. "__finally",
  200. "__forceinline",
  201. "__gc",
  202. "__hook",
  203. "__identifier",
  204. "__if_exists",
  205. "__if_not_exists",
  206. "__inline",
  207. "__int128",
  208. "__int16",
  209. "__int32",
  210. "__int64",
  211. "__int8",
  212. "__interface",
  213. "__leave",
  214. "__m128",
  215. "__m128d",
  216. "__m128i",
  217. "__m256",
  218. "__m256d",
  219. "__m256i",
  220. "__m512",
  221. "__m512d",
  222. "__m512i",
  223. "__m64",
  224. "__multiple_inheritance",
  225. "__newslot",
  226. "__nogc",
  227. "__noop",
  228. "__nounwind",
  229. "__novtordisp",
  230. "__pascal",
  231. "__pin",
  232. "__pragma",
  233. "__property",
  234. "__ptr32",
  235. "__ptr64",
  236. "__raise",
  237. "__restrict",
  238. "__resume",
  239. "__sealed",
  240. "__single_inheritance",
  241. "__stdcall",
  242. "__super",
  243. "__thiscall",
  244. "__try",
  245. "__try_cast",
  246. "__typeof",
  247. "__unaligned",
  248. "__unhook",
  249. "__uuidof",
  250. "__value",
  251. "__virtual_inheritance",
  252. "__w64",
  253. "__wchar_t"
  254. ],
  255. operators: [
  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. "+=",
  283. "-=",
  284. "*=",
  285. "/=",
  286. "&=",
  287. "|=",
  288. "^=",
  289. "%=",
  290. "<<=",
  291. ">>=",
  292. ">>>="
  293. ],
  294. symbols: /[=><!~?:&|+\-*\/\^%]+/,
  295. escapes: /\\(?:[0abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  296. integersuffix: /([uU](ll|LL|l|L)|(ll|LL|l|L)?[uU]?)/,
  297. floatsuffix: /[fFlL]?/,
  298. encoding: /u|u8|U|L/,
  299. tokenizer: {
  300. root: [
  301. [/@encoding?R\"(?:([^ ()\\\t]*))\(/, { token: "string.raw.begin", next: "@raw.$1" }],
  302. [
  303. /[a-zA-Z_]\w*/,
  304. {
  305. cases: {
  306. "@keywords": { token: "keyword.$0" },
  307. "@default": "identifier"
  308. }
  309. }
  310. ],
  311. [/^\s*#\s*include/, { token: "keyword.directive.include", next: "@include" }],
  312. [/^\s*#\s*\w+/, "keyword.directive"],
  313. { include: "@whitespace" },
  314. [/\[\s*\[/, { token: "annotation", next: "@annotation" }],
  315. [/[{}()\[\]]/, "@brackets"],
  316. [/[<>](?!@symbols)/, "@brackets"],
  317. [
  318. /@symbols/,
  319. {
  320. cases: {
  321. "@operators": "delimiter",
  322. "@default": ""
  323. }
  324. }
  325. ],
  326. [/\d*\d+[eE]([\-+]?\d+)?(@floatsuffix)/, "number.float"],
  327. [/\d*\.\d+([eE][\-+]?\d+)?(@floatsuffix)/, "number.float"],
  328. [/0[xX][0-9a-fA-F']*[0-9a-fA-F](@integersuffix)/, "number.hex"],
  329. [/0[0-7']*[0-7](@integersuffix)/, "number.octal"],
  330. [/0[bB][0-1']*[0-1](@integersuffix)/, "number.binary"],
  331. [/\d[\d']*\d(@integersuffix)/, "number"],
  332. [/\d(@integersuffix)/, "number"],
  333. [/[;,.]/, "delimiter"],
  334. [/"([^"\\]|\\.)*$/, "string.invalid"],
  335. [/"/, "string", "@string"],
  336. [/'[^\\']'/, "string"],
  337. [/(')(@escapes)(')/, ["string", "string.escape", "string"]],
  338. [/'/, "string.invalid"]
  339. ],
  340. whitespace: [
  341. [/[ \t\r\n]+/, ""],
  342. [/\/\*\*(?!\/)/, "comment.doc", "@doccomment"],
  343. [/\/\*/, "comment", "@comment"],
  344. [/\/\/.*\\$/, "comment", "@linecomment"],
  345. [/\/\/.*$/, "comment"]
  346. ],
  347. comment: [
  348. [/[^\/*]+/, "comment"],
  349. [/\*\//, "comment", "@pop"],
  350. [/[\/*]/, "comment"]
  351. ],
  352. linecomment: [
  353. [/.*[^\\]$/, "comment", "@pop"],
  354. [/[^]+/, "comment"]
  355. ],
  356. doccomment: [
  357. [/[^\/*]+/, "comment.doc"],
  358. [/\*\//, "comment.doc", "@pop"],
  359. [/[\/*]/, "comment.doc"]
  360. ],
  361. string: [
  362. [/[^\\"]+/, "string"],
  363. [/@escapes/, "string.escape"],
  364. [/\\./, "string.escape.invalid"],
  365. [/"/, "string", "@pop"]
  366. ],
  367. raw: [
  368. [
  369. /(.*)(\))(?:([^ ()\\\t"]*))(\")/,
  370. {
  371. cases: {
  372. "$3==$S2": [
  373. "string.raw",
  374. "string.raw.end",
  375. "string.raw.end",
  376. { token: "string.raw.end", next: "@pop" }
  377. ],
  378. "@default": ["string.raw", "string.raw", "string.raw", "string.raw"]
  379. }
  380. }
  381. ],
  382. [/.*/, "string.raw"]
  383. ],
  384. annotation: [
  385. { include: "@whitespace" },
  386. [/using|alignas/, "keyword"],
  387. [/[a-zA-Z0-9_]+/, "annotation"],
  388. [/[,:]/, "delimiter"],
  389. [/[()]/, "@brackets"],
  390. [/\]\s*\]/, { token: "annotation", next: "@pop" }]
  391. ],
  392. include: [
  393. [
  394. /(\s*)(<)([^<>]*)(>)/,
  395. [
  396. "",
  397. "keyword.directive.include.begin",
  398. "string.include.identifier",
  399. { token: "keyword.directive.include.end", next: "@pop" }
  400. ]
  401. ],
  402. [
  403. /(\s*)(")([^"]*)(")/,
  404. [
  405. "",
  406. "keyword.directive.include.begin",
  407. "string.include.identifier",
  408. { token: "keyword.directive.include.end", next: "@pop" }
  409. ]
  410. ]
  411. ]
  412. }
  413. };
  414. return __toCommonJS(cpp_exports);
  415. })();
  416. return moduleExports;
  417. });