cpp.js 9.2 KB

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