cpp.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  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/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. "__m64",
  221. "__multiple_inheritance",
  222. "__newslot",
  223. "__nogc",
  224. "__noop",
  225. "__nounwind",
  226. "__novtordisp",
  227. "__pascal",
  228. "__pin",
  229. "__pragma",
  230. "__property",
  231. "__ptr32",
  232. "__ptr64",
  233. "__raise",
  234. "__restrict",
  235. "__resume",
  236. "__sealed",
  237. "__single_inheritance",
  238. "__stdcall",
  239. "__super",
  240. "__thiscall",
  241. "__try",
  242. "__try_cast",
  243. "__typeof",
  244. "__unaligned",
  245. "__unhook",
  246. "__uuidof",
  247. "__value",
  248. "__virtual_inheritance",
  249. "__w64",
  250. "__wchar_t"
  251. ],
  252. operators: [
  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. "/=",
  283. "&=",
  284. "|=",
  285. "^=",
  286. "%=",
  287. "<<=",
  288. ">>=",
  289. ">>>="
  290. ],
  291. symbols: /[=><!~?:&|+\-*\/\^%]+/,
  292. escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  293. integersuffix: /([uU](ll|LL|l|L)|(ll|LL|l|L)?[uU]?)/,
  294. floatsuffix: /[fFlL]?/,
  295. encoding: /u|u8|U|L/,
  296. tokenizer: {
  297. root: [
  298. [/@encoding?R\"(?:([^ ()\\\t]*))\(/, { token: "string.raw.begin", next: "@raw.$1" }],
  299. [
  300. /[a-zA-Z_]\w*/,
  301. {
  302. cases: {
  303. "@keywords": { token: "keyword.$0" },
  304. "@default": "identifier"
  305. }
  306. }
  307. ],
  308. [/^\s*#\s*include/, { token: "keyword.directive.include", next: "@include" }],
  309. [/^\s*#\s*\w+/, "keyword.directive"],
  310. { include: "@whitespace" },
  311. [/\[\s*\[/, { token: "annotation", next: "@annotation" }],
  312. [/[{}()\[\]]/, "@brackets"],
  313. [/[<>](?!@symbols)/, "@brackets"],
  314. [
  315. /@symbols/,
  316. {
  317. cases: {
  318. "@operators": "delimiter",
  319. "@default": ""
  320. }
  321. }
  322. ],
  323. [/\d*\d+[eE]([\-+]?\d+)?(@floatsuffix)/, "number.float"],
  324. [/\d*\.\d+([eE][\-+]?\d+)?(@floatsuffix)/, "number.float"],
  325. [/0[xX][0-9a-fA-F']*[0-9a-fA-F](@integersuffix)/, "number.hex"],
  326. [/0[0-7']*[0-7](@integersuffix)/, "number.octal"],
  327. [/0[bB][0-1']*[0-1](@integersuffix)/, "number.binary"],
  328. [/\d[\d']*\d(@integersuffix)/, "number"],
  329. [/\d(@integersuffix)/, "number"],
  330. [/[;,.]/, "delimiter"],
  331. [/"([^"\\]|\\.)*$/, "string.invalid"],
  332. [/"/, "string", "@string"],
  333. [/'[^\\']'/, "string"],
  334. [/(')(@escapes)(')/, ["string", "string.escape", "string"]],
  335. [/'/, "string.invalid"]
  336. ],
  337. whitespace: [
  338. [/[ \t\r\n]+/, ""],
  339. [/\/\*\*(?!\/)/, "comment.doc", "@doccomment"],
  340. [/\/\*/, "comment", "@comment"],
  341. [/\/\/.*\\$/, "comment", "@linecomment"],
  342. [/\/\/.*$/, "comment"]
  343. ],
  344. comment: [
  345. [/[^\/*]+/, "comment"],
  346. [/\*\//, "comment", "@pop"],
  347. [/[\/*]/, "comment"]
  348. ],
  349. linecomment: [
  350. [/.*[^\\]$/, "comment", "@pop"],
  351. [/[^]+/, "comment"]
  352. ],
  353. doccomment: [
  354. [/[^\/*]+/, "comment.doc"],
  355. [/\*\//, "comment.doc", "@pop"],
  356. [/[\/*]/, "comment.doc"]
  357. ],
  358. string: [
  359. [/[^\\"]+/, "string"],
  360. [/@escapes/, "string.escape"],
  361. [/\\./, "string.escape.invalid"],
  362. [/"/, "string", "@pop"]
  363. ],
  364. raw: [
  365. [
  366. /(.*)(\))(?:([^ ()\\\t"]*))(\")/,
  367. {
  368. cases: {
  369. "$3==$S2": [
  370. "string.raw",
  371. "string.raw.end",
  372. "string.raw.end",
  373. { token: "string.raw.end", next: "@pop" }
  374. ],
  375. "@default": ["string.raw", "string.raw", "string.raw", "string.raw"]
  376. }
  377. }
  378. ],
  379. [/.*/, "string.raw"]
  380. ],
  381. annotation: [
  382. { include: "@whitespace" },
  383. [/using|alignas/, "keyword"],
  384. [/[a-zA-Z0-9_]+/, "annotation"],
  385. [/[,:]/, "delimiter"],
  386. [/[()]/, "@brackets"],
  387. [/\]\s*\]/, { token: "annotation", next: "@pop" }]
  388. ],
  389. include: [
  390. [
  391. /(\s*)(<)([^<>]*)(>)/,
  392. [
  393. "",
  394. "keyword.directive.include.begin",
  395. "string.include.identifier",
  396. { token: "keyword.directive.include.end", next: "@pop" }
  397. ]
  398. ],
  399. [
  400. /(\s*)(")([^"]*)(")/,
  401. [
  402. "",
  403. "keyword.directive.include.begin",
  404. "string.include.identifier",
  405. { token: "keyword.directive.include.end", next: "@pop" }
  406. ]
  407. ]
  408. ]
  409. }
  410. };
  411. return __toCommonJS(cpp_exports);
  412. })();
  413. return moduleExports;
  414. });