mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2025-12-27 10:33:59 -05:00
Fixes for cppfront (#4076)
* 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
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
@@ -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 [];
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
77
lib/parsers/asm-parser-cpp.ts
Normal file
77
lib/parsers/asm-parser-cpp.ts
Normal file
@@ -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,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -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';
|
||||
|
||||
48
static/modes/cppfront-mode.ts
Normal file
48
static/modes/cppfront-mode.ts
Normal file
@@ -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 {};
|
||||
@@ -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');
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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',
|
||||
},
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user