1#!/usr/bin/tclsh 2 3# Copyright JS Foundation and other contributors, http://js.foundation 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17proc check_part_of_the_file {file line_num col_start col_end} { 18 if {$col_start == $col_end} { 19 return 20 } 21 22 set line [getLine $file $line_num] 23 set line [string range $line $col_start $col_end] 24 25 if {[regexp {[[:alnum:]_][\s]+\[} $line]} { 26 report $file $line_num "there should be no spaces between identifier and left bracket" 27 } 28} 29 30foreach fileName [getSourceFileNames] { 31 set checkLine 1 32 set checkColStart 0 33 set seenOmitToken false 34 foreach token [getTokens $fileName 1 0 -1 -1 {}] { 35 set lineNumber [lindex $token 1] 36 set colNumber [lindex $token 2] 37 set tokenType [lindex $token 3] 38 39 if {$checkLine != $lineNumber} { 40 if {!$seenOmitToken} { 41 check_part_of_the_file $fileName $checkLine $checkColStart end 42 } 43 set checkColStart $colNumber 44 set checkLine $lineNumber 45 } elseif {$seenOmitToken} { 46 set checkColStart $colNumber 47 } 48 49 if {$tokenType in {ccomment cppcomment stringlit}} { 50 check_part_of_the_file $fileName $checkLine $checkColStart $colNumber 51 set seenOmitToken true 52 } else { 53 set seenOmitToken false 54 } 55 } 56} 57