File: T004.tcl

package info (click to toggle)
vera%2B%2B 1.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,184 kB
  • sloc: cpp: 10,361; tcl: 921; python: 32; makefile: 5
file content (51 lines) | stat: -rwxr-xr-x 1,708 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/tclsh
# Some keywords should be immediately followed by a colon

set keywords {
    default
    private
    protected
    public
}

proc isKeyword {s} {
    global keywords
    return [expr [lsearch $keywords $s] != -1]
}

foreach f [getSourceFileNames] {
    set lastKeywordLine 0
    set lastKeywordColumn 0
    set lastKeywordValue ""
    set last ""
    foreach t [getTokens $f 1 0 -1 -1 [concat $keywords colon]] {
        set tokenValue [lindex $t 0]
        set tokenName [lindex $t 3]
        if {$tokenName == "colon"} {
            if {$last == "keyword" && $lastKeywordLine != 0} {
                set line [lindex $t 1]
                set column [lindex $t 2]
                if {$line != $lastKeywordLine ||
                    $column != [expr $lastKeywordColumn + [string length $lastKeywordValue]]} {
                    set nonWhiteFound "false"
                    foreach tb [getTokens $f $lastKeywordLine [expr $lastKeywordColumn + 1] $line $column {}] {
                        set tbName [lindex $tb 3]
                        if {[lsearch {space newline ccomment cppcomment} $tbName] == -1} {
                            set nonWhiteFound "true"
                            break
                        }
                    }
                    if {$nonWhiteFound == "false"} {
                        report $f $line "colon not immediately after the \'$lastKeywordValue\' keyword"
                    }
                }
            }
            set last "colon"
        } else {
            set lastKeywordLine [lindex $t 1]
            set lastKeywordColumn [lindex $t 2]
            set lastKeywordValue $tokenValue
            set last "keyword"
        }
    }
}