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

Method preprocessOutput

lib/compilers/clean.ts:58–89  ·  view source on GitHub ↗
(output: string)

Source from the content-addressed store, hash-verified

56 }
57
58 preprocessOutput(output: string) {
59 const errorRegex = /^error \[.*,(\d*),(.*)]:\s?(.*)/i;
60 const errorLineRegex = /^error \[.*,(\d*)]:\s?(.*)/i;
61 const parseerrorRegex = /^parse error \[.*,(\d*);(\d*),(.*)]:\s?(.*)/i;
62 const typeeerrorRegex = /^type error \[.*,(\d*),(.*)]:\s?(.*)/i;
63 return utils
64 .splitLines(output)
65 .map(line => {
66 let matches = line.match(errorRegex);
67 if (!matches) matches = line.match(typeeerrorRegex);
68
69 if (matches) {
70 return '<source>:' + matches[1] + ',0: error: (' + matches[2] + ') ' + matches[3];
71 }
72
73 matches = line.match(errorLineRegex);
74 if (matches) {
75 return '<source>:' + matches[1] + ',0: error: ' + matches[2];
76 }
77
78 matches = line.match(parseerrorRegex);
79 if (matches) {
80 if (matches[3] === '') {
81 return '<source>:' + matches[1] + ',' + matches[2] + ': error: ' + matches[4];
82 }
83 return '<source>:' + matches[1] + ',' + matches[2] + ': error: (' + matches[3] + ') ' + matches[4];
84 }
85
86 return line;
87 })
88 .join('\n');
89 }
90
91 override async runCompiler(
92 compiler: string,

Callers 1

runCompilerMethod · 0.95

Calls 2

splitLinesMethod · 0.80
matchMethod · 0.80

Tested by

no test coverage detected