@@ -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+ }
0 commit comments