Skip to content

Commit da820f6

Browse files
committed
feat: gcc 9.2 output support
merged from particle-iot/gcc-output-parser commit c9a6665
1 parent a45afa1 commit da820f6

File tree

3 files changed

+70
-4
lines changed

3 files changed

+70
-4
lines changed

lib/main.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ function parseString(stdout) {
1212
function parseGcc(stdout) {
1313
const messages = [];
1414
let match = null;
15-
const deepRegex = /([^:^\r?\n]+):(\d+):(\d+):\s(\w+\s*\w*):\s(.+)\r?\n(\s+)(.*)\s+(~*\^~*)/gm;
16-
// ^ ^ ^ ^ ^ ^ ^ ^
17-
// | | | | | | | +- token marker
18-
// | | | | | | +- affected code
15+
const deepRegex = /([^:^\r?\n]+):(\d+):(\d+):\s(\w+\s*\w*):\s(.+)\r?\n(\s+)\d*\s*[|]*\s*(.*)\s+[|]*\s*(~*\^~*)/gm;
16+
// ^ ^ ^ ^ ^ ^ | ^ ^
17+
// | | | | | | | | +- token marker
18+
// | | | | | | | +- affected code
19+
// | | | | | | +- optional gcc 9.2 markup
1920
// | | | | | +- whitespace before code
2021
// | | | | +- message text
2122
// | | | +- type (error|warning|note)

spec/9_gcc_9.2.txt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
201204_fc_recv_1.ino:561:9: warning: "/*" within comment [-Wcomment]
2+
561 | /*
3+
|
4+
201204_fc_recv_1.ino:64:25: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
5+
64 | char *rStates[] = { "NO Run State", "SYNC", "RUN" } ;
6+
| ^~~~~~~~~~~~~~
7+
201204_fc_recv_1.ino:64:41: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
8+
64 | char *rStates[] = { "NO Run State", "SYNC", "RUN" } ;
9+
| ^~~~~~
10+
201204_fc_recv_1.ino:64:49: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
11+
64 | char *rStates[] = { "NO Run State", "SYNC", "RUN" } ;
12+
| ^~~~~
13+
201204_fc_recv_1.ino:65:25: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
14+
65 | char *rSyncs[] = { "No Sync State","LOOKing for SYNC" };
15+
| ^~~~~~~~~~~~~~~
16+
201204_fc_recv_1.ino:65:41: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
17+
65 | char *rSyncs[] = { "No Sync State","LOOKing for SYNC" };
18+
| ^~~~~~~~~~~~~~~~~~
19+
201204_fc_recv_1.ino:76:23: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
20+
76 | char *workNames[] = { "1-On ","1-Off","2-On ","2-Off","PAF"," nc " };
21+
| ^~~~~~~
22+
201204_fc_recv_1.ino:76:31: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
23+
76 | char *workNames[] = { "1-On ","1-Off","2-On ","2-Off","PAF"," nc " };
24+
| ^~~~~~~
25+
201204_fc_recv_1.ino:76:39: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
26+
76 | char *workNames[] = { "1-On ","1-Off","2-On ","2-Off","PAF"," nc " };
27+
| ^~~~~~~
28+
201204_fc_recv_1.ino:76:47: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
29+
76 | char *workNames[] = { "1-On ","1-Off","2-On ","2-Off","PAF"," nc " };
30+
| ^~~~~~~
31+
201204_fc_recv_1.ino:76:55: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
32+
76 | char *workNames[] = { "1-On ","1-Off","2-On ","2-Off","PAF"," nc " };
33+
| ^~~~~
34+
201204_fc_recv_1.ino:76:61: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
35+
76 | char *workNames[] = { "1-On ","1-Off","2-On ","2-Off","PAF"," nc " };
36+
| ^~~~~~~
37+
201204_fc_recv_1.ino:583:5: error: expected declaration before '}' token
38+
583 | }
39+
| ^
40+
201204_fc_recv_1.ino: In function 'void announce()':
41+
201204_fc_recv_1.ino:639:9: warning: unused variable 'averagePulseTime' [-Wunused-variable]
42+
639 | int averagePulseTime;
43+
| ^~~~~~~~~~~~~~~~
44+
201204_fc_recv_1.ino:640:9: warning: unused variable 'averageNonPulseTime' [-Wunused-variable]
45+
640 | int averageNonPulseTime;
46+
| ^~~~~~~~~~~~~~~~~~~
47+
../build/module.mk:274: recipe for target '../build/target/user/platform-6-m201204_fc_recv_1.o' failed
48+
make[2]: *** [../build/target/user/platform-6-m201204_fc_recv_1.o] Error 1

spec/errors.spec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,20 @@ describe('error marker prefixed by ~', () => {
196196
output[0].tokenLength.should.equal(26);
197197
});
198198
});
199+
200+
describe('parsing gcc 9.2 errors', () => {
201+
let stdout = null;
202+
before(() => {
203+
stdout = fs.readFileSync(__dirname + '/9_gcc_9.2.txt');
204+
});
205+
it('should return an object', () => {
206+
const output = parser.parseString(stdout);
207+
208+
output.length.should.equal(14);
209+
output[11].type.should.equal('error');
210+
output[11].filename.should.equal('201204_fc_recv_1.ino');
211+
output[11].line.should.equal(583);
212+
output[11].column.should.equal(5);
213+
output[11].text.should.equal(`expected declaration before '}' token`);
214+
});
215+
});

0 commit comments

Comments
 (0)