Mercurial > irccd
comparison vera/rules/T004.tcl @ 510:6ec510722582
CMake: enable vera++ as code checking, closes #603
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 19 Oct 2017 13:01:39 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
509:c9a6d9df083f | 510:6ec510722582 |
---|---|
1 #!/usr/bin/tclsh | |
2 # Some keywords should be immediately followed by a colon | |
3 | |
4 set keywords { | |
5 default | |
6 private | |
7 protected | |
8 public | |
9 } | |
10 | |
11 proc isKeyword {s} { | |
12 global keywords | |
13 return [expr [lsearch $keywords $s] != -1] | |
14 } | |
15 | |
16 foreach f [getSourceFileNames] { | |
17 set lastKeywordLine 0 | |
18 set lastKeywordColumn 0 | |
19 set lastKeywordValue "" | |
20 set last "" | |
21 foreach t [getTokens $f 1 0 -1 -1 [concat $keywords colon]] { | |
22 set tokenValue [lindex $t 0] | |
23 set tokenName [lindex $t 3] | |
24 if {$tokenName == "colon"} { | |
25 if {$last == "keyword" && $lastKeywordLine != 0} { | |
26 set line [lindex $t 1] | |
27 set column [lindex $t 2] | |
28 if {$line != $lastKeywordLine || | |
29 $column != [expr $lastKeywordColumn + [string length $lastKeywordValue]]} { | |
30 set nonWhiteFound "false" | |
31 foreach tb [getTokens $f $lastKeywordLine [expr $lastKeywordColumn + 1] $line $column {}] { | |
32 set tbName [lindex $tb 3] | |
33 if {[lsearch {space newline ccomment cppcomment} $tbName] == -1} { | |
34 set nonWhiteFound "true" | |
35 break | |
36 } | |
37 } | |
38 if {$nonWhiteFound == "false"} { | |
39 report $f $line "colon not immediately after the \'$lastKeywordValue\' keyword" | |
40 } | |
41 } | |
42 } | |
43 set last "colon" | |
44 } else { | |
45 set lastKeywordLine [lindex $t 1] | |
46 set lastKeywordColumn [lindex $t 2] | |
47 set lastKeywordValue $tokenValue | |
48 set last "keyword" | |
49 } | |
50 } | |
51 } |