Skip to content

Commit a84ddb2

Browse files
committed
add problem matcher and terminal link provider for cosmic stm8
1 parent 7713f0b commit a84ddb2

3 files changed

Lines changed: 74 additions & 2 deletions

File tree

src/EIDEProjectExplorer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ import {
107107
} from 'vscode-cpptools';
108108
import * as eclipseParser from './EclipseProjectParser';
109109
import { isArray } from 'util';
110-
import { parseIarCompilerLog, CompilerDiagnostics, parseGccCompilerLog, parseArmccCompilerLog, parseKeilc51CompilerLog, parseSdccCompilerLog } from './ProblemMatcher';
110+
import { parseIarCompilerLog, CompilerDiagnostics, parseGccCompilerLog, parseArmccCompilerLog, parseKeilc51CompilerLog, parseSdccCompilerLog, parseCosmicStm8CompilerLog } from './ProblemMatcher';
111111
import * as iarParser from './IarProjectParser';
112112
import * as ArmCpuUtils from './ArmCpuUtils';
113113
import { ShellFlasherIndexItem } from './WebInterface/WebInterface';
@@ -3993,6 +3993,9 @@ export class ProjectExplorer implements CustomConfigurationProvider {
39933993
case 'SDCC':
39943994
diag_res = parseSdccCompilerLog(prj, logFile);
39953995
break;
3996+
case 'COSMIC_STM8':
3997+
diag_res = parseCosmicStm8CompilerLog(prj, logFile);
3998+
break;
39963999
default:
39974000
diag_res = parseGccCompilerLog(prj, logFile);
39984001
break;

src/ProblemMatcher.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,3 +355,65 @@ export function parseIarCompilerLog(projApi: ProjectBaseApi, logfile: File): Com
355355

356356
return result;
357357
}
358+
359+
// #error cpstm8 acia.c:33(25) incompatible compare types
360+
// #error cpstm8 .\src\main.c:54(14+3) bad struct/union operand
361+
// #error clnk acia.lkf:1 symbol f_recept not defined (vector.o )
362+
// #error clnk acia.lkf:1 symbol f__stext not defined (vector.o )
363+
export function parseCosmicStm8CompilerLog(projApi: ProjectBaseApi, logfile: File): CompilerDiagnostics {
364+
365+
const pattern = {
366+
"regexp": "^\\s*#(\\w+) (\\w+) (.+?):(\\d+)(\\(\\d+(?:\\+\\d+)?\\))? (.+)",
367+
"severity": 1,
368+
"toolname": 2,
369+
"file": 3,
370+
"line": 4,
371+
"col": 5,
372+
"message": 6
373+
};
374+
375+
const matcher = new RegExp(pattern.regexp, 'i');
376+
const result: { [path: string]: vscode.Diagnostic[] } = {};
377+
const ccLogLines = parseLogLines(logfile);
378+
379+
for (let idx = 0; idx < ccLogLines.length; idx++) {
380+
const line = ccLogLines[idx];
381+
const m = matcher.exec(line);
382+
if (m && m.length > 5) {
383+
384+
const fspath = projApi.toAbsolutePath(m[pattern.file]);
385+
const message = m[pattern.message].trim();
386+
const line = parseInt(m[pattern.line]);
387+
const severity = m[pattern.severity].trim();
388+
const colStr = m[pattern.col]?.trim();
389+
const toolname = m[pattern.toolname].trim();
390+
391+
let column = 0;
392+
let column_rng = 1;
393+
if (colStr && colStr.length > 2) {
394+
// .\src\main.c:54(14+3)
395+
if (colStr.includes('+')) {
396+
const m_col = /(\d+)\+(\d+)/.exec(colStr);
397+
if (m_col && m_col.length > 2) {
398+
column = parseInt(m_col[1]);
399+
column_rng = parseInt(m_col[2]);
400+
}
401+
} else {
402+
column = parseInt(colStr.substring(1, colStr.length - 1));
403+
}
404+
}
405+
406+
const diags = result[fspath] || [];
407+
if (result[fspath] == undefined) result[fspath] = diags;
408+
409+
const pos_s = newVscFilePosition(projApi.toolchainName(), line, column);
410+
const pos_e = newVscFilePosition(projApi.toolchainName(), line, column + column_rng);
411+
const vscDiag = new vscode.Diagnostic(new vscode.Range(pos_s, pos_e), message, toVscServerity(severity));
412+
vscDiag.source = toolname;
413+
414+
diags.push(vscDiag);
415+
}
416+
}
417+
418+
return result;
419+
}

src/extension.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,14 @@ class EideTerminalLinkProvider implements vscode.TerminalLinkProvider<EideTermin
11991199
regexp: new RegExp("^\\s*\"([^\"]+)\",(\\d+)\\s+", 'i'),
12001200
file: 1,
12011201
line: 2
1202-
}
1202+
},
1203+
1204+
// cosmic stm8
1205+
{
1206+
regexp: new RegExp(String.raw`^#\w+ \w+stm8 (.+?):(\d+)`),
1207+
file: 1,
1208+
line: 2
1209+
},
12031210
];
12041211

12051212
constructor() {

0 commit comments

Comments
 (0)