aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Godbolt <matt@godbolt.org>2022-09-20 07:42:41 -0500
committerGitHub <noreply@github.com>2022-09-20 07:42:41 -0500
commita8a666aeacde683a8ef1e027f26a5cdd08bade8f (patch)
tree73c7039fd4aa4c0a0060aaec31eb315e3626f2a4
parent377c907af44348fd6859f2def84a4971ccc1e2c2 (diff)
downloadcompiler-explorer-a8a666aeacde683a8ef1e027f26a5cdd08bade8f.tar.gz
compiler-explorer-a8a666aeacde683a8ef1e027f26a5cdd08bade8f.zip
Fixes for cppfront (#4076)gh-4280
* Rename cppx_cppfront to cpp2_cppfront * Add some blurb about the compiler * Some syntax highlighting * Better output highlighting * Some form of line tracking and filtering
-rw-r--r--etc/config/cpp2_cppfront.amazon.properties (renamed from etc/config/cppx_cppfront.amazon.properties)1
-rw-r--r--etc/config/cpp2_cppfront.defaults.properties (renamed from etc/config/cppx_cppfront.defaults.properties)1
-rw-r--r--examples/cpp2_cppfront/default.cpp2 (renamed from examples/cppx_cppfront/default.cpp2)0
-rw-r--r--lib/compilers/cppfront.ts24
-rw-r--r--lib/languages.ts64
-rw-r--r--lib/parsers/asm-parser-cpp.ts77
-rw-r--r--static/modes/_all.ts1
-rw-r--r--static/modes/cppfront-mode.ts48
-rw-r--r--static/modes/cppx-blue-mode.ts2
-rw-r--r--static/panes/compiler.js17
-rw-r--r--static/themes.ts6
-rw-r--r--types/languages.interfaces.ts4
12 files changed, 199 insertions, 46 deletions
diff --git a/etc/config/cppx_cppfront.amazon.properties b/etc/config/cpp2_cppfront.amazon.properties
index 0d75086de..7a75fa195 100644
--- a/etc/config/cppx_cppfront.amazon.properties
+++ b/etc/config/cpp2_cppfront.amazon.properties
@@ -2,6 +2,7 @@
compilers=&cppfront
group.cppfront.compilers=cppfront_trunk
+group.cppfront.notification=<a href="https://github.com/hsutter/cppfront" target="_blank">Cppfront</a> is an experimental compiler from a potential C++ 'syntax 2' (Cpp2) to today's 'syntax 1' (Cpp1), to learn some things, prove out some concepts, and share some ideas.
compiler.cppfront_trunk.exe=/opt/compiler-explorer/cppfront-trunk/cppfront
compiler.cppfront_trunk.name=cppfront trunk
defaultCompiler=cppfront_trunk
diff --git a/etc/config/cppx_cppfront.defaults.properties b/etc/config/cpp2_cppfront.defaults.properties
index cfa3e1559..eeec2eaf8 100644
--- a/etc/config/cppx_cppfront.defaults.properties
+++ b/etc/config/cpp2_cppfront.defaults.properties
@@ -2,6 +2,7 @@
compilers=&cppfront
group.cppfront.compilers=cppfront_trunk
+group.cppfront.notification=<a href="https://github.com/hsutter/cppfront" target="_blank">Cppfront</a> is an experimental compiler from a potential C++ 'syntax 2' (Cpp2) to today's 'syntax 1' (Cpp1), to learn some things, prove out some concepts, and share some ideas.
compiler.cppfront_trunk.exe=cppfront
compiler.cppfront_trunk.name=cppfront trunk
defaultCompiler=cppfront_trunk
diff --git a/examples/cppx_cppfront/default.cpp2 b/examples/cpp2_cppfront/default.cpp2
index 99fc51b6c..99fc51b6c 100644
--- a/examples/cppx_cppfront/default.cpp2
+++ b/examples/cpp2_cppfront/default.cpp2
diff --git a/lib/compilers/cppfront.ts b/lib/compilers/cppfront.ts
index ebbca43b9..37db5aee0 100644
--- a/lib/compilers/cppfront.ts
+++ b/lib/compilers/cppfront.ts
@@ -24,10 +24,9 @@
import path from 'path';
-import {ExecutionOptions} from '../../types/compilation/compilation.interfaces';
import {ParseFilters} from '../../types/features/filters.interfaces';
import {BaseCompiler} from '../base-compiler';
-import * as exec from '../exec';
+import {AsmParserCpp} from '../parsers/asm-parser-cpp';
export class CppFrontCompiler extends BaseCompiler {
static get key() {
@@ -37,29 +36,10 @@ export class CppFrontCompiler extends BaseCompiler {
constructor(info, env) {
super(info, env);
+ this.asm = new AsmParserCpp();
this.outputFilebase = 'example';
}
- override orderArguments(
- options: string[],
- inputFilename: string,
- libIncludes: string[],
- libOptions: string[],
- libPaths: string[],
- libLinks: string[],
- userOptions: string[],
- staticLibLinks: string[],
- ) {
- return options.concat(
- userOptions,
- ['example.cpp2'], // Grotesque hack to handle the fact we can't use abs filenames with current
- libIncludes,
- libOptions,
- libPaths,
- libLinks,
- staticLibLinks,
- );
- }
override optionsForFilter(filters: ParseFilters, outputFilename: any) {
return [];
}
diff --git a/lib/languages.ts b/lib/languages.ts
index 15789c0f0..296f2bf07 100644
--- a/lib/languages.ts
+++ b/lib/languages.ts
@@ -29,7 +29,16 @@ import _ from 'underscore';
import {Language, LanguageKey} from '../types/languages.interfaces';
-type DefKeys = 'name' | 'monaco' | 'extensions' | 'alias' | 'previewFilter' | 'formatter' | 'logoUrl' | 'logoUrlDark';
+type DefKeys =
+ | 'name'
+ | 'monaco'
+ | 'extensions'
+ | 'alias'
+ | 'previewFilter'
+ | 'formatter'
+ | 'logoUrl'
+ | 'logoUrlDark'
+ | 'monacoDisassembly';
type LanguageDefinition = Pick<Language, DefKeys>;
const definitions: Record<LanguageKey, LanguageDefinition> = {
@@ -42,6 +51,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: 'cppp',
},
'c++': {
name: 'C++',
@@ -52,6 +62,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: 'clangformat',
previewFilter: /^\s*#include/,
+ monacoDisassembly: null,
},
ada: {
name: 'Ada',
@@ -62,6 +73,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: 'ada-dark.svg',
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
analysis: {
name: 'Analysis',
@@ -72,6 +84,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
assembly: {
name: 'Assembly',
@@ -82,6 +95,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
c: {
name: 'C',
@@ -92,6 +106,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: 'clangformat',
previewFilter: /^\s*#include/,
+ monacoDisassembly: null,
},
carbon: {
name: 'Carbon',
@@ -102,6 +117,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
circle: {
name: 'C++ (Circle)',
@@ -112,6 +128,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrl: 'c++.svg', // TODO: Find a better alternative
logoUrlDark: null,
formatter: null,
+ monacoDisassembly: null,
},
circt: {
name: 'CIRCT',
@@ -122,6 +139,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
formatter: null,
logoUrlDark: null,
previewFilter: null,
+ monacoDisassembly: 'mlir',
},
clean: {
name: 'Clean',
@@ -132,6 +150,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
cmake: {
name: 'CMake',
@@ -142,6 +161,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
cpp_for_opencl: {
name: 'C++ for OpenCL',
@@ -152,6 +172,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: 'opencl-dark.svg',
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
mlir: {
name: 'MLIR',
@@ -162,6 +183,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
formatter: null,
logoUrlDark: null,
previewFilter: null,
+ monacoDisassembly: null,
},
cppx: {
name: 'Cppx',
@@ -172,6 +194,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: /^\s*#include/,
+ monacoDisassembly: null,
},
cppx_blue: {
name: 'Cppx-Blue',
@@ -182,6 +205,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
cppx_gold: {
name: 'Cppx-Gold',
@@ -192,16 +216,18 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
- cppx_cppfront: {
- name: 'Cppx-cppfront',
- monaco: 'cppx-cppfront',
+ cpp2_cppfront: {
+ name: 'Cpp2-cppfront',
+ monaco: 'cpp2-cppfront',
extensions: ['.cpp2'],
alias: [],
logoUrl: 'c++.svg', // TODO: Find a better alternative
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: 'cppp',
},
crystal: {
name: 'Crystal',
@@ -212,6 +238,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: 'crystal-dark.svg',
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
csharp: {
name: 'C#',
@@ -222,6 +249,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
cuda: {
name: 'CUDA C++',
@@ -232,6 +260,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: 'cuda-dark.svg',
formatter: null,
previewFilter: null,
+ monacoDisassembly: 'ptx',
},
d: {
name: 'D',
@@ -242,6 +271,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
dart: {
name: 'Dart',
@@ -252,6 +282,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: 'dartformat',
previewFilter: null,
+ monacoDisassembly: null,
},
erlang: {
name: 'Erlang',
@@ -262,6 +293,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
fortran: {
name: 'Fortran',
@@ -272,6 +304,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
fsharp: {
name: 'F#',
@@ -282,6 +315,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
go: {
name: 'Go',
@@ -292,6 +326,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
haskell: {
name: 'Haskell',
@@ -302,6 +337,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
hlsl: {
name: 'HLSL',
@@ -312,6 +348,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
ispc: {
name: 'ispc',
@@ -322,6 +359,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
java: {
name: 'Java',
@@ -332,6 +370,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
kotlin: {
name: 'Kotlin',
@@ -342,6 +381,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
llvm: {
name: 'LLVM IR',
@@ -352,6 +392,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
nim: {
name: 'Nim',
@@ -362,6 +403,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
ocaml: {
name: 'OCaml',
@@ -372,6 +414,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
openclc: {
name: 'OpenCL C',
@@ -382,6 +425,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: 'opencl-dark.svg',
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
pascal: {
name: 'Pascal',
@@ -392,6 +436,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: 'pascal-dark.svg',
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
pony: {
name: 'Pony',
@@ -402,6 +447,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
python: {
name: 'Python',
@@ -412,6 +458,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
ruby: {
name: 'Ruby',
@@ -422,6 +469,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: 'asmruby',
},
rust: {
name: 'Rust',
@@ -432,6 +480,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: 'rust-dark.svg',
formatter: 'rustfmt',
previewFilter: null,
+ monacoDisassembly: null,
},
scala: {
name: 'Scala',
@@ -442,6 +491,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
solidity: {
name: 'Solidity',
@@ -452,6 +502,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
swift: {
name: 'Swift',
@@ -462,6 +513,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
toit: {
name: 'Toit',
@@ -472,6 +524,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
typescript: {
name: 'TypeScript Native',
@@ -482,6 +535,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
vb: {
name: 'Visual Basic',
@@ -492,6 +546,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
zig: {
name: 'Zig',
@@ -502,6 +557,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
logoUrlDark: null,
formatter: null,
previewFilter: null,
+ monacoDisassembly: null,
},
};
diff --git a/lib/parsers/asm-parser-cpp.ts b/lib/parsers/asm-parser-cpp.ts
new file mode 100644
index 000000000..dc28a8c27
--- /dev/null
+++ b/lib/parsers/asm-parser-cpp.ts
@@ -0,0 +1,77 @@
+// Copyright (c) 2022, Compiler Explorer Authors
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+import {ParseFilters} from '../../types/features/filters.interfaces';
+import * as utils from '../utils';
+
+import {IAsmParser} from './asm-parser.interfaces';
+
+type InlineLabel = {name: string; range: {startCol: number; endCol: number}};
+type Source = {file: string | null; line: number};
+
+const lineRe = /^\s*#line\s+(?<line>\d+)\s+"(?<file>[^"]+)"/;
+
+export class AsmParserCpp implements IAsmParser {
+ process(asmResult: string, filters: ParseFilters) {
+ const startTime = process.hrtime.bigint();
+
+ const asm: {
+ text: string;
+ source: Source | null;
+ labels: InlineLabel[];
+ }[] = [];
+
+ let source: Source | null = null;
+ for (const line of utils.splitLines(asmResult)) {
+ let advance = true;
+ const match = line.match(lineRe);
+ if (match && match.groups) {
+ // TODO perhaps we'll need to check the file here at some point in the future.
+ // TODO I've temporarily disabled this as the result is visually too noisy
+ // was: source = {file: null, line: parseInt(match.groups.line)};
+ source = {file: match.groups.file, line: parseInt(match.groups.line)};
+ if (filters.directives) {
+ continue;
+ }
+ advance = false;
+ }
+ asm.push({
+ text: line,
+ source: source,
+ labels: [],
+ });
+ if (source && advance) {
+ source = {...source, line: source.line + 1};
+ }
+ }
+
+ const endTime = process.hrtime.bigint();
+ return {
+ asm: asm,
+ labelDefinitions: [],
+ parsingTime: ((endTime - startTime) / BigInt(1000000)).toString(),
+ filteredCount: 0,
+ };
+ }
+}
diff --git a/static/modes/_all.ts b/static/modes/_all.ts
index 657656f48..1dcd0390d 100644
--- a/static/modes/_all.ts
+++ b/static/modes/_all.ts
@@ -31,6 +31,7 @@ import './clean-mode';
import './cmake-mode';
import './cppcircle-mode';
import './cpp-for-opencl-mode';
+import './cppfront-mode';
import './cppp-mode';
import './cppx-blue-mode';
import './cppx-gold-mode';
diff --git a/static/modes/cppfront-mode.ts b/static/modes/cppfront-mode.ts
new file mode 100644
index 000000000..d00663620
--- /dev/null
+++ b/static/modes/cppfront-mode.ts
@@ -0,0 +1,48 @@
+// Copyright (c) 2022, Compiler Explorer Authors
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+import $ from 'jquery';
+
+const monaco = require('monaco-editor');
+const cpp = require('monaco-editor/esm/vs/basic-languages/cpp/cpp');
+const cppp = require('./cppp-mode');
+
+function definition() {
+ const cppfront = $.extend(true, {}, cppp); // deep copy
+ cppfront.tokenPostfix = '.herb';
+
+ cppfront.keywords.push('type', 'next', 'inout');
+
+ // pick up 'identifier:' as a definition. This is a hack; ideally we'd have "optional whitespace after beginning of
+ // line" but here I just try to disambiguate `::` and don't worry about labels.
+ cppfront.tokenizer.root.unshift([/[a-zA-Z_]\w*\s*:(?!:)/, 'identifier.definition']);
+
+ return cppfront;
+}
+
+monaco.languages.register({id: 'cpp2-cppfront'});
+monaco.languages.setLanguageConfiguration('cpp2-cppfront', cpp.conf);
+monaco.languages.setMonarchTokensProvider('cpp2-cppfront', definition());
+
+export {};
diff --git a/static/modes/cppx-blue-mode.ts b/static/modes/cppx-blue-mode.ts
index 2f4a6b341..e3972bdf4 100644
--- a/static/modes/cppx-blue-mode.ts
+++ b/static/modes/cppx-blue-mode.ts
@@ -30,7 +30,7 @@ const cppp = require('./cppp-mode');
function definition() {
const cppx_blue = $.extend(true, {}, cppp); // deep copy
- cppx_blue.tokenPostfix = '.cppx-blue';
+ cppx_blue.tokenPostfix = '.herb';
// add the 'type' keyword
cppx_blue.keywords.push('type');
diff --git a/static/panes/compiler.js b/static/panes/compiler.js
index 652d09c4d..bdae64ba4 100644
--- a/static/panes/compiler.js
+++ b/static/panes/compiler.js
@@ -128,21 +128,8 @@ function Compiler(hub, container, state) {
this.initButtons(state);
- var monacoDisassembly = 'asm';
- // Bandaid fix to not have to include monacoDisassembly everywhere in languages.js
- if (languages[this.currentLangId]) {
- switch (languages[this.currentLangId].id) {
- case 'cuda':
- monacoDisassembly = 'ptx';
- break;
- case 'ruby':
- monacoDisassembly = 'asmruby';
- break;
- case 'mlir':
- monacoDisassembly = 'mlir';
- break;
- }
- }
+ var monacoDisassembly =
+ (languages[this.currentLangId] ? languages[this.currentLangId].monacoDisassembly : null) || 'asm';
this.outputEditor = monaco.editor.create(
this.monacoPlaceholder[0],
diff --git a/static/themes.ts b/static/themes.ts
index cf8e9ca2e..acc2d3460 100644
--- a/static/themes.ts
+++ b/static/themes.ts
@@ -65,7 +65,7 @@ editor.defineTheme('ce', {
inherit: true,
rules: [
{
- token: 'identifier.definition.cppx-blue',
+ token: 'identifier.definition.herb',
foreground: '008a00',
fontStyle: 'bold',
},
@@ -78,7 +78,7 @@ editor.defineTheme('ce-dark', {
inherit: true,
rules: [
{
- token: 'identifier.definition.cppx-blue',
+ token: 'identifier.definition.herb',
foreground: '7c9c7c',
fontStyle: 'bold',
},
@@ -91,7 +91,7 @@ editor.defineTheme('ce-dark-plus', {
inherit: true,
rules: [
{
- token: 'identifier.definition.cppx-blue',
+ token: 'identifier.definition.herb',
foreground: '7c9c7c',
fontStyle: 'bold',
},
diff --git a/types/languages.interfaces.ts b/types/languages.interfaces.ts
index 699289295..77eeb1ec8 100644
--- a/types/languages.interfaces.ts
+++ b/types/languages.interfaces.ts
@@ -37,7 +37,7 @@ export type LanguageKey =
| 'cppx'
| 'cppx_blue'
| 'cppx_gold'
- | 'cppx_cppfront'
+ | 'cpp2_cppfront'
| 'crystal'
| 'csharp'
| 'cuda'
@@ -93,4 +93,6 @@ export interface Language {
/** Example code to show in the language's editor */
example: string;
previewFilter: RegExp | null;
+ /** The override for the output (default is "asm") */
+ monacoDisassembly: string | null;
}