File: T007.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 (22 lines) | stat: -rwxr-xr-x 933 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
#!/usr/bin/tclsh
# Semicolons should not be isolated by spaces or comments from the rest of the code

foreach f [getSourceFileNames] {
    foreach t [getTokens $f 1 0 -1 -1 {semicolon}] {
        set line [lindex $t 1]
        set column [lindex $t 2]
        set previousTokens [getTokens $f $line 0 $line $column {}]
        if {$previousTokens == {}} {
            report $f $line "semicolon is isolated from other tokens"
        } else {
            set lastToken [lindex $previousTokens end]
            set lastName [lindex $lastToken 3]
            if {[lsearch {space ccomment} $lastName] != -1} {
                set forTokens [getTokens $f $line 0 $line $column {for leftparen}]
                if {[list [lindex [lindex $forTokens 0] 3] [lindex [lindex $forTokens 1] 3]] != {for leftparen}} {
                    report $f $line "semicolon is isolated from other tokens"
                }
            }
        }
    }
}