MCPcopy Create free account
hub / github.com/compiler-explorer/compiler-explorer / definition

Function definition

static/modes/cppp-mode.ts:31–117  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29// We need to create a new definition for cpp so we can remove invalid keywords
30
31function definition(): monaco.languages.IMonarchLanguage {
32 const cppp = $.extend(true, {}, cpp.language); // deep copy
33
34 function removeKeyword(keyword: string) {
35 const index = cppp.keywords.indexOf(keyword);
36 if (index > -1) {
37 cppp.keywords.splice(index, 1);
38 }
39 }
40
41 function removeKeywords(keywords: string[]) {
42 for (let i = 0; i < keywords.length; ++i) {
43 removeKeyword(keywords[i]);
44 }
45 }
46
47 function addKeywords(keywords: string[]) {
48 // (Ruben) Done one by one as if you just push them all, Monaco complains that they're not strings, but as
49 // far as I can tell, they indeed are all strings. This somehow fixes it. If you know how to fix it, plz go
50 for (let i = 0; i < keywords.length; ++i) {
51 cppp.keywords.push(keywords[i]);
52 }
53 }
54
55 // We remove everything that's not an identifier, underscore reserved name and not an official C++ keyword...
56 // Regarding #617, final is a identifier with special meaning, not a fully qualified keyword
57 removeKeywords([
58 'abstract',
59 'amp',
60 'array',
61 'cpu',
62 'delegate',
63 'each',
64 'event',
65 'finally',
66 'gcnew',
67 'generic',
68 'in',
69 'initonly',
70 'interface',
71 'interior_ptr',
72 'internal',
73 'literal',
74 'partial',
75 'pascal',
76 'pin_ptr',
77 'property',
78 'ref',
79 'restrict',
80 'safe_cast',
81 'sealed',
82 'title_static',
83 'where',
84 ]);
85
86 addKeywords([
87 'alignas',
88 'alignof',

Callers 1

cppp-mode.tsFile · 0.70

Calls 2

removeKeywordsFunction · 0.70
addKeywordsFunction · 0.70

Tested by

no test coverage detected