mirror of
https://github.com/google/pebble.git
synced 2025-11-18 21:40:57 -05:00
Import of the watch repository from Pebble
This commit is contained in:
87
third_party/jerryscript/tools/vera++/scripts/rules/jerry_always_curly.tcl
vendored
Normal file
87
third_party/jerryscript/tools/vera++/scripts/rules/jerry_always_curly.tcl
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
#!/usr/bin/tclsh
|
||||
|
||||
# Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
foreach file_name [getSourceFileNames] {
|
||||
set state "control"
|
||||
set do_marks {}
|
||||
set prev_tok_type ""
|
||||
set prev_ctrl ""
|
||||
set expect_while false
|
||||
set expect_open_brace false
|
||||
set paren_count 0
|
||||
|
||||
foreach token [getTokens $file_name 1 0 -1 -1 {if do while else for leftparen rightparen semicolon leftbrace rightbrace}] {
|
||||
set tok_val [lindex $token 0]
|
||||
set line_num [lindex $token 1]
|
||||
set col_num [lindex $token 2]
|
||||
set tok_type [lindex $token 3]
|
||||
|
||||
if {$state == "expression"} {
|
||||
# puts "expression $paren_count $tok_type ($line_num , $col_num)"
|
||||
if {$tok_type == "leftparen"} {
|
||||
incr paren_count
|
||||
} elseif {$tok_type == "rightparen"} {
|
||||
incr paren_count -1
|
||||
if {$paren_count == 0} {
|
||||
set state "control"
|
||||
set expect_open_brace true
|
||||
} elseif {$paren_count < 0 } {
|
||||
report $file_name $line_num "unexpected right parentheses"
|
||||
}
|
||||
} elseif {$tok_type != "semicolon"} {
|
||||
report $file_name $line_num "unexpected token: $tok_type"
|
||||
}
|
||||
} else {
|
||||
if {$expect_open_brace == true} {
|
||||
if {$tok_type == "if" && $prev_tok_type == "else"} {
|
||||
# empty
|
||||
} elseif {$tok_type != "leftbrace"} {
|
||||
report $file_name [lindex $prev_ctrl 1] "brace after \'[lindex $prev_ctrl 3]\' required"
|
||||
}
|
||||
set expect_open_brace false
|
||||
}
|
||||
|
||||
if {$tok_type == "while" && ($expect_while == true || [lindex $prev_ctrl 3] == "do")} {
|
||||
set expect_while false
|
||||
set prev_ctrl ""
|
||||
} elseif {$tok_type in {if for while}} {
|
||||
set state "expression"
|
||||
set prev_ctrl $token
|
||||
} elseif {$tok_type in {do else}} {
|
||||
set expect_open_brace true
|
||||
set prev_ctrl $token
|
||||
} elseif {$tok_type == "leftbrace"} {
|
||||
if {[lindex $prev_ctrl 3] == "do"} {
|
||||
lappend do_marks 1
|
||||
} else {
|
||||
lappend do_marks 0
|
||||
}
|
||||
set prev_ctrl ""
|
||||
} elseif {$tok_type == "rightbrace"} {
|
||||
if {[llength $do_marks] > 0} {
|
||||
if {[lindex $do_marks end] == 1} {
|
||||
set expect_while true
|
||||
}
|
||||
set do_marks [lreplace $do_marks end end]
|
||||
} else {
|
||||
report $file_name $line_num "unmatched brace"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
set prev_tok_type $tok_type
|
||||
}
|
||||
}
|
||||
115
third_party/jerryscript/tools/vera++/scripts/rules/jerry_braces_on_separate_line.tcl
vendored
Normal file
115
third_party/jerryscript/tools/vera++/scripts/rules/jerry_braces_on_separate_line.tcl
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
#!/usr/bin/tclsh
|
||||
|
||||
# Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
foreach file_name [getSourceFileNames] {
|
||||
set state "normal"
|
||||
set lines {}
|
||||
set cols {}
|
||||
set struct_marks {}
|
||||
set expect_struct_name false
|
||||
set prev_tok ""
|
||||
set def_start false
|
||||
set expect_newline false
|
||||
set check_newline true
|
||||
|
||||
foreach token [getTokens $file_name 1 0 -1 -1 {}] {
|
||||
set tok_val [lindex $token 0]
|
||||
set line_num [lindex $token 1]
|
||||
set col_num [lindex $token 2]
|
||||
set tok_type [lindex $token 3]
|
||||
|
||||
if {$state == "macro"} {
|
||||
if {$col_num == 0} {
|
||||
set state "normal"
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if {$tok_type in {space ccomment cppcomment newline}} {
|
||||
continue
|
||||
}
|
||||
|
||||
if {$tok_type == "pp_define"} {
|
||||
set state "macro"
|
||||
set prev_tok ""
|
||||
set def_start false
|
||||
continue
|
||||
}
|
||||
|
||||
if {$expect_struct_name == true} {
|
||||
if {$tok_type == "identifier" && $line_num != [lindex $prev_tok 1]} {
|
||||
report $file_name $line_num "type name should be on the same line with the rightbrace"
|
||||
}
|
||||
set expect_struct_name false
|
||||
}
|
||||
|
||||
# check that rightbrace and typename (in struct, union and enum definitons) are on the same line
|
||||
if {$tok_type in {struct enum union}} {
|
||||
set def_start true
|
||||
} elseif {$tok_type == "semicolon"} {
|
||||
set def_start false
|
||||
} elseif {$tok_type == "leftbrace"} {
|
||||
lappend cols $col_num
|
||||
lappend lines $line_num
|
||||
if {$def_start == true} {
|
||||
lappend struct_marks 1
|
||||
set def_start false
|
||||
} elseif {[lindex $prev_tok 3] == "assign"} {
|
||||
lappend struct_marks 2
|
||||
set check_newline false
|
||||
} else {
|
||||
lappend struct_marks 0
|
||||
}
|
||||
} elseif {$tok_type == "rightbrace"} {
|
||||
if {[llength $lines] > 0} {
|
||||
if {[lindex $struct_marks end] == 1} {
|
||||
set expect_struct_name true
|
||||
set check_newline false
|
||||
} elseif {[lindex $struct_marks end] == 2} {
|
||||
set check_newline false
|
||||
}
|
||||
set lines [lreplace $lines end end]
|
||||
set cols [lreplace $cols end end]
|
||||
set struct_marks [lreplace $struct_marks end end]
|
||||
} else {
|
||||
report $file_name $line_num "unmatched brace"
|
||||
}
|
||||
}
|
||||
|
||||
# check that braces are on separate lines
|
||||
if {$check_newline == true} {
|
||||
if {$expect_newline == true} {
|
||||
if {$tok_type == "semicolon"} {
|
||||
# empty
|
||||
} elseif {[lindex $prev_tok 1] == $line_num} {
|
||||
report $file_name $line_num "brace should be placed on a separate line"
|
||||
} else {
|
||||
set expect_newline false
|
||||
}
|
||||
} elseif {$tok_type in {leftbrace rightbrace}} {
|
||||
if {[lindex $prev_tok 1] == $line_num} {
|
||||
report $file_name $line_num "brace should be placed on a separate line"
|
||||
}
|
||||
set expect_newline true
|
||||
}
|
||||
} else {
|
||||
set check_newline true
|
||||
}
|
||||
|
||||
set prev_tok $token
|
||||
}
|
||||
}
|
||||
61
third_party/jerryscript/tools/vera++/scripts/rules/jerry_braces_same_line_or_column.tcl
vendored
Normal file
61
third_party/jerryscript/tools/vera++/scripts/rules/jerry_braces_same_line_or_column.tcl
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/tclsh
|
||||
|
||||
# Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
foreach file_name [getSourceFileNames] {
|
||||
set state "normal"
|
||||
set lines {}
|
||||
set cols {}
|
||||
|
||||
foreach token [getTokens $file_name 1 0 -1 -1 {}] {
|
||||
set tok_val [lindex $token 0]
|
||||
set line_num [lindex $token 1]
|
||||
set col_num [lindex $token 2]
|
||||
set tok_type [lindex $token 3]
|
||||
|
||||
if {$state == "macro"} {
|
||||
if {$col_num == 0} {
|
||||
set state "normal"
|
||||
} else {
|
||||
set prev_tok_line $line_num
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if {$tok_type in {space ccomment cppcomment newline}} {
|
||||
continue
|
||||
}
|
||||
|
||||
if {$tok_type == "pp_define"} {
|
||||
set state "macro"
|
||||
continue
|
||||
}
|
||||
|
||||
if {$tok_type == "leftbrace"} {
|
||||
lappend cols $col_num
|
||||
lappend lines $line_num
|
||||
} elseif {$tok_type == "rightbrace"} {
|
||||
if {[llength $lines] > 0} {
|
||||
if {[lindex $lines end] != $line_num && [lindex $cols end] != $col_num} {
|
||||
report $file_name $line_num "matching braces should be on the same line or column"
|
||||
}
|
||||
set lines [lreplace $lines end end]
|
||||
set cols [lreplace $cols end end]
|
||||
} else {
|
||||
report $file_name $line_num "unmatched brace"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
53
third_party/jerryscript/tools/vera++/scripts/rules/jerry_comment_function_end.tcl
vendored
Normal file
53
third_party/jerryscript/tools/vera++/scripts/rules/jerry_comment_function_end.tcl
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/tclsh
|
||||
|
||||
# Copyright 2016 Samsung Electronics Co., Ltd.
|
||||
# Copyright 2016 University of Szeged
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
foreach fileName [getSourceFileNames] {
|
||||
set funcStart 0
|
||||
set funcName ""
|
||||
set lineNumber 1
|
||||
foreach line [getAllLines $fileName] {
|
||||
if {[regexp {^((static |const )*\w+ )*\w+ \(.*[,\)]} $line]} {
|
||||
set type {}
|
||||
set modifier {}
|
||||
if {$funcStart == 0} {
|
||||
regexp {^((static |const )*\w+ )*(\w+) \(} $line matched type modifier funcName
|
||||
}
|
||||
}
|
||||
|
||||
if {[regexp {^\{$} $line]} {
|
||||
set funcStart 1
|
||||
}
|
||||
|
||||
if {$funcStart == 1} {
|
||||
if {[regexp {^\}$} $line] && [string length $funcName] != 0} {
|
||||
report $fileName $lineNumber "missing comment at the end of function: /* $funcName */"
|
||||
set funcStart 0
|
||||
} elseif {[regexp {^\} /\*\s*\w+\s*\*/$} $line] && [string length $funcName] != 0} {
|
||||
set comment {}
|
||||
regexp {^\} /\*\s*(\w+)\s*\*/$} $line -> comment
|
||||
if {$comment != $funcName} {
|
||||
report $fileName $lineNumber "comment missmatch. (Current: $comment, Expected: $funcName) "
|
||||
}
|
||||
set funcStart 0
|
||||
} elseif {[regexp {^\}.*;?$} $line]} {
|
||||
set funcStart 0
|
||||
}
|
||||
}
|
||||
|
||||
incr lineNumber
|
||||
}
|
||||
}
|
||||
60
third_party/jerryscript/tools/vera++/scripts/rules/jerry_funcname_space_parentheses.tcl
vendored
Normal file
60
third_party/jerryscript/tools/vera++/scripts/rules/jerry_funcname_space_parentheses.tcl
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/tclsh
|
||||
|
||||
# Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
proc check_part_of_the_file {file line_num col_start col_end} {
|
||||
if {$col_start == $col_end} {
|
||||
return
|
||||
}
|
||||
set line [getLine $file $line_num]
|
||||
|
||||
if {[regexp {^\s*#[ ]*define} $line]} {
|
||||
return
|
||||
}
|
||||
|
||||
set line [string range $line $col_start $col_end]
|
||||
|
||||
if {[regexp {([[:alnum:]][\s]{2,}\()|([[:alnum:]]\()} $line]} {
|
||||
report $file $line_num "there should be exactly one space before left parentheses"
|
||||
}
|
||||
}
|
||||
|
||||
foreach fileName [getSourceFileNames] {
|
||||
set checkLine 1
|
||||
set checkColStart 0
|
||||
set seenOmitToken false
|
||||
foreach token [getTokens $fileName 1 0 -1 -1 {}] {
|
||||
set lineNumber [lindex $token 1]
|
||||
set colNumber [lindex $token 2]
|
||||
set tokenType [lindex $token 3]
|
||||
|
||||
if {$checkLine != $lineNumber} {
|
||||
if {!$seenOmitToken} {
|
||||
check_part_of_the_file $fileName $checkLine $checkColStart end
|
||||
}
|
||||
set checkColStart $colNumber
|
||||
set checkLine $lineNumber
|
||||
} elseif {$seenOmitToken} {
|
||||
set checkColStart $colNumber
|
||||
}
|
||||
|
||||
if {$tokenType in {ccomment cppcomment stringlit}} {
|
||||
check_part_of_the_file $fileName $checkLine $checkColStart $colNumber
|
||||
set seenOmitToken true
|
||||
} else {
|
||||
set seenOmitToken false
|
||||
}
|
||||
}
|
||||
}
|
||||
56
third_party/jerryscript/tools/vera++/scripts/rules/jerry_identifier_no_space_bracket.tcl
vendored
Normal file
56
third_party/jerryscript/tools/vera++/scripts/rules/jerry_identifier_no_space_bracket.tcl
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/tclsh
|
||||
|
||||
# Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
proc check_part_of_the_file {file line_num col_start col_end} {
|
||||
if {$col_start == $col_end} {
|
||||
return
|
||||
}
|
||||
|
||||
set line [getLine $file $line_num]
|
||||
set line [string range $line $col_start $col_end]
|
||||
|
||||
if {[regexp {[[:alnum:]_][\s]+\[} $line]} {
|
||||
report $file $line_num "there should be no spaces between identifier and left bracket"
|
||||
}
|
||||
}
|
||||
|
||||
foreach fileName [getSourceFileNames] {
|
||||
set checkLine 1
|
||||
set checkColStart 0
|
||||
set seenOmitToken false
|
||||
foreach token [getTokens $fileName 1 0 -1 -1 {}] {
|
||||
set lineNumber [lindex $token 1]
|
||||
set colNumber [lindex $token 2]
|
||||
set tokenType [lindex $token 3]
|
||||
|
||||
if {$checkLine != $lineNumber} {
|
||||
if {!$seenOmitToken} {
|
||||
check_part_of_the_file $fileName $checkLine $checkColStart end
|
||||
}
|
||||
set checkColStart $colNumber
|
||||
set checkLine $lineNumber
|
||||
} elseif {$seenOmitToken} {
|
||||
set checkColStart $colNumber
|
||||
}
|
||||
|
||||
if {$tokenType in {ccomment cppcomment stringlit}} {
|
||||
check_part_of_the_file $fileName $checkLine $checkColStart $colNumber
|
||||
set seenOmitToken true
|
||||
} else {
|
||||
set seenOmitToken false
|
||||
}
|
||||
}
|
||||
}
|
||||
127
third_party/jerryscript/tools/vera++/scripts/rules/jerry_indentation.tcl
vendored
Normal file
127
third_party/jerryscript/tools/vera++/scripts/rules/jerry_indentation.tcl
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
#!/usr/bin/tclsh
|
||||
|
||||
# Copyright 2014-2016 Samsung Electronics Co., Ltd.
|
||||
# Copyright 2016 University of Szeged.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Indentation
|
||||
|
||||
foreach fileName [getSourceFileNames] {
|
||||
set indent 0
|
||||
set lastCheckedLineNumber -1
|
||||
set is_in_comment "no"
|
||||
set is_in_pp_define "no"
|
||||
set is_in_class "no"
|
||||
set is_in_template "no"
|
||||
set parentheses_level 0
|
||||
set template_brackets_level 0
|
||||
|
||||
foreach token [getTokens $fileName 1 0 -1 -1 {}] {
|
||||
set type [lindex $token 3]
|
||||
set lineNumber [lindex $token 1]
|
||||
|
||||
if {$is_in_comment == "yes"} {
|
||||
set is_in_comment "no"
|
||||
}
|
||||
|
||||
if {$type == "newline"} {
|
||||
set is_in_pp_define "no"
|
||||
} elseif {$type == "class"} {
|
||||
set is_in_class "yes"
|
||||
} elseif {$type == "template"} {
|
||||
set is_in_template "yes"
|
||||
} elseif {$is_in_class == "yes" && $type == "semicolon" && $indent == 0} {
|
||||
set is_in_class "no"
|
||||
} elseif {$type == "ccomment"} {
|
||||
set is_in_comment "yes"
|
||||
} elseif {[string first "pp_" $type] == 0} {
|
||||
if {$type == "pp_define"} {
|
||||
set is_in_pp_define "yes"
|
||||
}
|
||||
|
||||
set lastCheckedLineNumber $lineNumber
|
||||
} elseif {$type == "space"} {
|
||||
} elseif {$type != "eof"} {
|
||||
if {$type == "rightbrace" && $indent > 0} {
|
||||
incr indent -2
|
||||
}
|
||||
|
||||
if {$is_in_pp_define == "no" && $is_in_comment == "no" && $parentheses_level == 0 &&
|
||||
$is_in_template == "no"} {
|
||||
set line [getLine $fileName $lineNumber]
|
||||
|
||||
if {$lineNumber != $lastCheckedLineNumber} {
|
||||
if {[regexp {^[[:blank:]]*} $line match]} {
|
||||
set real_indent [string length $match]
|
||||
if {$indent != $real_indent} {
|
||||
if {[regexp {^[[:blank:]]*(private:|public:|protected:)} $line]} {
|
||||
if {$indent != $real_indent + 2} {
|
||||
set exp_indent [expr {$indent - 2}]
|
||||
report $fileName $lineNumber "Indentation: $real_indent -> $exp_indent. Line: '$line'"
|
||||
}
|
||||
} elseif {![regexp {^[[:alnum:]_]{1,}:$} $line] || $real_indent != 0} {
|
||||
report $fileName $lineNumber "Indentation: $real_indent -> $indent. Line: '$line'"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if {$lineNumber == $lastCheckedLineNumber} {
|
||||
if {$type == "leftbrace"} {
|
||||
if {![regexp {^[[:blank:]]*\{[[:blank:]]*$} $line]
|
||||
&& ![regexp {[^\{=]=[^\{=]\{.*\},?} $line]} {
|
||||
report $fileName $lineNumber "Left brace is not the only non-space character in the line: '$line'"
|
||||
}
|
||||
}
|
||||
if {$type == "rightbrace"} {
|
||||
if {![regexp {^.* = .*\{.*\}[,;]?$} $line]
|
||||
&& ![regexp {[^\{=]=[^\{=]\{.*\}[,;]?} $line]} {
|
||||
report $fileName $lineNumber "Right brace is not first non-space character in the line: '$line'"
|
||||
}
|
||||
}
|
||||
}
|
||||
if {$type == "rightbrace"} {
|
||||
if {![regexp {^[[:blank:]]*\};?((( [a-z_\(][a-z0-9_\(\)]{0,}){1,})?;| /\*.*\*/| //.*)?$} $line]
|
||||
&& ![regexp {[^\{=]=[^\{=]\{.*\}[,;]?} $line]} {
|
||||
report $fileName $lineNumber "Right brace is not the only non-space character in the line and \
|
||||
is not single right brace followed by \[a-z0-9_() \] string and single semicolon character: '$line'"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if {$type == "leftbrace"} {
|
||||
if {![regexp {^extern "C"} [getLine $fileName [expr {$lineNumber - 1}]]]} {
|
||||
incr indent 2
|
||||
}
|
||||
} elseif {$type == "leftparen"} {
|
||||
incr parentheses_level 1
|
||||
} elseif {$type == "rightparen"} {
|
||||
incr parentheses_level -1
|
||||
}
|
||||
|
||||
if {$is_in_template == "yes"} {
|
||||
if {$type == "less"} {
|
||||
incr template_brackets_level
|
||||
} elseif {$type == "greater"} {
|
||||
incr template_brackets_level -1
|
||||
if {$template_brackets_level == 0} {
|
||||
set is_in_template "no"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
set lastCheckedLineNumber $lineNumber
|
||||
}
|
||||
}
|
||||
}
|
||||
27
third_party/jerryscript/tools/vera++/scripts/rules/jerry_max_line_length.tcl
vendored
Normal file
27
third_party/jerryscript/tools/vera++/scripts/rules/jerry_max_line_length.tcl
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/tclsh
|
||||
|
||||
# Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set maxLen 120
|
||||
|
||||
foreach f [getSourceFileNames] {
|
||||
set lineNumber 1
|
||||
foreach line [getAllLines $f] {
|
||||
if {[string length $line] > $maxLen} {
|
||||
report $f $lineNumber "line is longer than ${maxLen} characters"
|
||||
}
|
||||
incr lineNumber
|
||||
}
|
||||
}
|
||||
56
third_party/jerryscript/tools/vera++/scripts/rules/jerry_no_space_after_opening_parentheses.tcl
vendored
Normal file
56
third_party/jerryscript/tools/vera++/scripts/rules/jerry_no_space_after_opening_parentheses.tcl
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/tclsh
|
||||
|
||||
# Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
proc check_part_of_the_file {file line_num col_start col_end} {
|
||||
if {$col_start == $col_end} {
|
||||
return
|
||||
}
|
||||
|
||||
set line [getLine $file $line_num]
|
||||
set line [string range $line $col_start $col_end]
|
||||
|
||||
if {[regexp {\(+[[:blank:]]} $line]} {
|
||||
report $file $line_num "there should be no blank characters after opening parentheses"
|
||||
}
|
||||
}
|
||||
|
||||
foreach fileName [getSourceFileNames] {
|
||||
set checkLine 1
|
||||
set checkColStart 0
|
||||
set seenOmitToken false
|
||||
foreach token [getTokens $fileName 1 0 -1 -1 {}] {
|
||||
set lineNumber [lindex $token 1]
|
||||
set colNumber [lindex $token 2]
|
||||
set tokenType [lindex $token 3]
|
||||
|
||||
if {$checkLine != $lineNumber} {
|
||||
if {!$seenOmitToken} {
|
||||
check_part_of_the_file $fileName $checkLine $checkColStart end
|
||||
}
|
||||
set checkColStart $colNumber
|
||||
set checkLine $lineNumber
|
||||
} elseif {$seenOmitToken} {
|
||||
set checkColStart $colNumber
|
||||
}
|
||||
|
||||
if {$tokenType in {ccomment cppcomment stringlit}} {
|
||||
check_part_of_the_file $fileName $checkLine $checkColStart $colNumber
|
||||
set seenOmitToken true
|
||||
} else {
|
||||
set seenOmitToken false
|
||||
}
|
||||
}
|
||||
}
|
||||
57
third_party/jerryscript/tools/vera++/scripts/rules/jerry_no_space_before_closing_parentheses.tcl
vendored
Normal file
57
third_party/jerryscript/tools/vera++/scripts/rules/jerry_no_space_before_closing_parentheses.tcl
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/tclsh
|
||||
|
||||
# Copyright 2015-2016 Samsung Electronics Co., Ltd.
|
||||
# Copyright 2016 University of Szeged
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
proc check_part_of_the_file {file line_num col_start col_end} {
|
||||
if {$col_start == $col_end} {
|
||||
return
|
||||
}
|
||||
|
||||
set line [getLine $file $line_num]
|
||||
set line [string range $line $col_start $col_end]
|
||||
|
||||
if {[regexp {[[:graph:]][[:blank:]]+\)} $line]} {
|
||||
report $file $line_num "there should be no blank characters before closing parentheses"
|
||||
}
|
||||
}
|
||||
|
||||
foreach fileName [getSourceFileNames] {
|
||||
set checkLine 1
|
||||
set checkColStart 0
|
||||
set seenOmitToken false
|
||||
foreach token [getTokens $fileName 1 0 -1 -1 {}] {
|
||||
set lineNumber [lindex $token 1]
|
||||
set colNumber [lindex $token 2]
|
||||
set tokenType [lindex $token 3]
|
||||
|
||||
if {$checkLine != $lineNumber} {
|
||||
if {!$seenOmitToken} {
|
||||
check_part_of_the_file $fileName $checkLine $checkColStart end
|
||||
}
|
||||
set checkColStart $colNumber
|
||||
set checkLine $lineNumber
|
||||
} elseif {$seenOmitToken} {
|
||||
set checkColStart $colNumber
|
||||
}
|
||||
|
||||
if {$tokenType in {ccomment cppcomment stringlit}} {
|
||||
check_part_of_the_file $fileName $checkLine $checkColStart $colNumber
|
||||
set seenOmitToken true
|
||||
} else {
|
||||
set seenOmitToken false
|
||||
}
|
||||
}
|
||||
}
|
||||
25
third_party/jerryscript/tools/vera++/scripts/rules/jerry_no_tabs.tcl
vendored
Normal file
25
third_party/jerryscript/tools/vera++/scripts/rules/jerry_no_tabs.tcl
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/tclsh
|
||||
|
||||
# Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
foreach f [getSourceFileNames] {
|
||||
set lineNumber 1
|
||||
foreach line [getAllLines $f] {
|
||||
if {[regexp {\t} $line]} {
|
||||
report $f $lineNumber "tabs are not allowed"
|
||||
}
|
||||
incr lineNumber
|
||||
}
|
||||
}
|
||||
25
third_party/jerryscript/tools/vera++/scripts/rules/jerry_no_trailing_spaces.tcl
vendored
Normal file
25
third_party/jerryscript/tools/vera++/scripts/rules/jerry_no_trailing_spaces.tcl
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/tclsh
|
||||
|
||||
# Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
foreach f [getSourceFileNames] {
|
||||
set lineNumber 1
|
||||
foreach line [getAllLines $f] {
|
||||
if {[regexp {[[:blank:]]$} $line]} {
|
||||
report $f $lineNumber "trailing space is not allowed"
|
||||
}
|
||||
incr lineNumber
|
||||
}
|
||||
}
|
||||
59
third_party/jerryscript/tools/vera++/scripts/rules/jerry_pointer_declarator_space.tcl
vendored
Normal file
59
third_party/jerryscript/tools/vera++/scripts/rules/jerry_pointer_declarator_space.tcl
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/tclsh
|
||||
|
||||
# Copyright 2016 Samsung Electronics Co., Ltd.
|
||||
# Copyright 2016 University of Szeged.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
proc check_part_of_the_file {file line_num col_start col_end} {
|
||||
if {$col_start == $col_end} {
|
||||
return
|
||||
}
|
||||
|
||||
set line [getLine $file $line_num]
|
||||
set line [string range $line $col_start $col_end]
|
||||
|
||||
if {[regexp {\w\*\s\w+} $line]
|
||||
|| [regexp {\w\*\)} $line]
|
||||
|| [regexp {\w\*$} $line]} {
|
||||
report $file $line_num "there should be a space between the referenced type and the pointer declarator."
|
||||
}
|
||||
}
|
||||
|
||||
foreach fileName [getSourceFileNames] {
|
||||
set checkLine 1
|
||||
set checkColStart 0
|
||||
set seenOmitToken false
|
||||
foreach token [getTokens $fileName 1 0 -1 -1 {}] {
|
||||
set lineNumber [lindex $token 1]
|
||||
set colNumber [lindex $token 2]
|
||||
set tokenType [lindex $token 3]
|
||||
|
||||
if {$checkLine != $lineNumber} {
|
||||
if {!$seenOmitToken} {
|
||||
check_part_of_the_file $fileName $checkLine $checkColStart end
|
||||
}
|
||||
set checkColStart $colNumber
|
||||
set checkLine $lineNumber
|
||||
} elseif {$seenOmitToken} {
|
||||
set checkColStart $colNumber
|
||||
}
|
||||
|
||||
if {$tokenType in {ccomment cppcomment stringlit}} {
|
||||
check_part_of_the_file $fileName $checkLine $checkColStart $colNumber
|
||||
set seenOmitToken true
|
||||
} else {
|
||||
set seenOmitToken false
|
||||
}
|
||||
}
|
||||
}
|
||||
282
third_party/jerryscript/tools/vera++/scripts/rules/jerry_switch_case.tcl
vendored
Normal file
282
third_party/jerryscript/tools/vera++/scripts/rules/jerry_switch_case.tcl
vendored
Normal file
@@ -0,0 +1,282 @@
|
||||
#!/usr/bin/tclsh
|
||||
|
||||
# Copyright 2014-2015 Samsung Electronics Co., Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# switch-case
|
||||
|
||||
foreach fileName [getSourceFileNames] {
|
||||
set is_in_comment "no"
|
||||
set is_in_pp_define "no"
|
||||
|
||||
foreach token [getTokens $fileName 1 0 -1 -1 {}] {
|
||||
set type [lindex $token 3]
|
||||
set lineNumber [lindex $token 1]
|
||||
|
||||
if {$is_in_comment == "yes"} {
|
||||
set is_in_comment "no"
|
||||
}
|
||||
|
||||
if {$type == "newline"} {
|
||||
set is_in_pp_define "no"
|
||||
} elseif {$type == "ccomment"} {
|
||||
set is_in_comment "yes"
|
||||
} elseif {[string first "pp_" $type] == 0} {
|
||||
if {$type == "pp_define"} {
|
||||
set is_in_pp_define "yes"
|
||||
}
|
||||
} elseif {$type == "space"} {
|
||||
} elseif {$type != "eof"} {
|
||||
if {$is_in_pp_define == "no" && $type == "switch"} {
|
||||
set next_token_start [lindex $token 2]
|
||||
incr next_token_start 1
|
||||
set line_num 0
|
||||
set state "switch"
|
||||
set case_block "no"
|
||||
set seen_braces 0
|
||||
foreach next_token [getTokens $fileName $lineNumber $next_token_start -1 -1 {}] {
|
||||
set next_token_type [lindex $next_token 3]
|
||||
set next_token_value [lindex $next_token 0]
|
||||
if {$state == "switch"} {
|
||||
if {$next_token_type == "ccomment" || $next_token_type == "space" || $next_token_type == "newline"} {
|
||||
continue
|
||||
} elseif {$next_token_type == "leftbrace"} {
|
||||
set state "first-case"
|
||||
continue
|
||||
} else {
|
||||
# TODO: check switch
|
||||
continue
|
||||
}
|
||||
} elseif {$state == "first-case"} {
|
||||
if {$next_token_type == "ccomment" || $next_token_type == "space" || $next_token_type == "newline"} {
|
||||
continue
|
||||
} elseif {$next_token_type == "case"} {
|
||||
set state "case"
|
||||
continue
|
||||
} elseif {$next_token_type == "default"} {
|
||||
set state "default"
|
||||
continue
|
||||
} else {
|
||||
# Macros magic: give up
|
||||
break
|
||||
}
|
||||
} elseif {$state == "case"} {
|
||||
if {$next_token_type == "space"} {
|
||||
set state "space-after-case"
|
||||
continue
|
||||
} else {
|
||||
report $fileName [lindex $next_token 1] "There should be single space character after 'case' keyword (state $state)"
|
||||
}
|
||||
} elseif {$state == "space-after-case"} {
|
||||
if {$next_token_type != "identifier" && $next_token_type != "intlit" && $next_token_type != "charlit" && $next_token_type != "sizeof"} {
|
||||
report $fileName [lindex $next_token 1] "There should be single space character after 'case' keyword (state $state, next_token_type $next_token_type)"
|
||||
} else {
|
||||
set state "case-label"
|
||||
continue
|
||||
}
|
||||
} elseif {$state == "case-label" || $state == "default"} {
|
||||
set case_block "no"
|
||||
if {$next_token_type != "colon"} {
|
||||
continue
|
||||
} else {
|
||||
set state "colon"
|
||||
continue
|
||||
}
|
||||
} elseif {$state == "after-colon-preprocessor"} {
|
||||
if {$next_token_type == "newline"} {
|
||||
set state "colon"
|
||||
}
|
||||
} elseif {$state == "colon"} {
|
||||
if {$next_token_type == "space" || $next_token_type == "newline"} {
|
||||
continue
|
||||
} elseif {$next_token_type == "ccomment"} {
|
||||
if {[string match "*FALL*" $next_token_value]} {
|
||||
set state "fallthru"
|
||||
set line_num [lindex $next_token 1]
|
||||
continue
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
} elseif {$next_token_type == "case"} {
|
||||
set state "case"
|
||||
continue
|
||||
} elseif {$next_token_type == "default"} {
|
||||
set state "default"
|
||||
continue
|
||||
} elseif {$next_token_type == "leftbrace"} {
|
||||
set case_block "yes"
|
||||
set state "wait-for-break"
|
||||
continue
|
||||
} elseif {$next_token_type == "identifier"} {
|
||||
if {[string compare "JERRY_UNREACHABLE" $next_token_value] == 0
|
||||
|| [string first "JERRY_UNIMPLEMENTED" $next_token_value] == 0} {
|
||||
set state "wait-for-semicolon"
|
||||
continue
|
||||
} else {
|
||||
set state "wait-for-break"
|
||||
continue
|
||||
}
|
||||
} elseif {$next_token_type == "break"
|
||||
|| $next_token_type == "continue"
|
||||
|| $next_token_type == "return"} {
|
||||
set state "wait-for-semicolon"
|
||||
continue
|
||||
} elseif {[string first "pp_" $next_token_type] == 0} {
|
||||
set state "after-colon-preprocessor"
|
||||
} else {
|
||||
set state "wait-for-break"
|
||||
continue
|
||||
}
|
||||
} elseif {$state == "wait-for-semicolon"} {
|
||||
if {$next_token_type == "semicolon"} {
|
||||
set state "break"
|
||||
}
|
||||
continue
|
||||
} elseif {$state == "wait-for-break"} {
|
||||
if {$next_token_type == "case" || $next_token_type == "default"} {
|
||||
report $fileName [lindex $next_token 1] "Missing break, continue or FALLTHRU comment before case (state $state)"
|
||||
} elseif {$next_token_type == "leftbrace"} {
|
||||
set state "inside-braces"
|
||||
incr seen_braces 1
|
||||
continue
|
||||
} elseif {$next_token_type == "rightbrace"} {
|
||||
if {$case_block == "yes"} {
|
||||
set state "case-blocks-end"
|
||||
continue
|
||||
} else {
|
||||
break
|
||||
}
|
||||
} elseif {[string compare "JERRY_UNREACHABLE" $next_token_value] == 0
|
||||
|| [string first "JERRY_UNIMPLEMENTED" $next_token_value] == 0} {
|
||||
set state "wait-for-semicolon"
|
||||
continue
|
||||
} elseif {$next_token_type == "ccomment" && [string match "*FALL*" $next_token_value]} {
|
||||
set state "fallthru"
|
||||
set line_num [lindex $next_token 1]
|
||||
continue
|
||||
} elseif {$next_token_type == "break"
|
||||
|| $next_token_type == "continue"
|
||||
|| $next_token_type == "return"
|
||||
|| $next_token_type == "goto"} {
|
||||
set state "wait-for-semicolon"
|
||||
continue
|
||||
}
|
||||
continue
|
||||
} elseif {$state == "break" || $state == "fallthru"} {
|
||||
if {$case_block == "no"} {
|
||||
if {$next_token_type == "ccomment" || $next_token_type == "space" || $next_token_type == "newline"} {
|
||||
continue
|
||||
} elseif {$next_token_type == "case"} {
|
||||
set state "case"
|
||||
continue
|
||||
} elseif {$next_token_type == "default"} {
|
||||
set state "default"
|
||||
continue
|
||||
} elseif {$next_token_type == "leftbrace"} {
|
||||
set state "inside-braces"
|
||||
incr seen_braces 1
|
||||
continue
|
||||
} elseif {$next_token_type == "rightbrace"} {
|
||||
lappend switch_ends [lindex $next_token 1]
|
||||
break
|
||||
} elseif {$next_token_type == "break"
|
||||
|| $next_token_type == "continue"
|
||||
|| $next_token_type == "return"} {
|
||||
set state "wait-for-semicolon"
|
||||
continue
|
||||
} else {
|
||||
set state "wait-for-break"
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
if {$next_token_type == "ccomment" || $next_token_type == "space" || $next_token_type == "newline"} {
|
||||
continue
|
||||
} elseif {$next_token_type == "case"} {
|
||||
set state "case"
|
||||
continue
|
||||
} elseif {$next_token_type == "default"} {
|
||||
set state "default"
|
||||
continue
|
||||
} elseif {$next_token_type == "leftbrace"} {
|
||||
set state "inside-braces"
|
||||
incr seen_braces 1
|
||||
continue
|
||||
} elseif {$next_token_type == "rightbrace"} {
|
||||
set state "after-rightbrace"
|
||||
continue
|
||||
} elseif {$next_token_type == "break"
|
||||
|| $next_token_type == "continue"
|
||||
|| $next_token_type == "return"} {
|
||||
set state "wait-for-semicolon"
|
||||
continue
|
||||
} else {
|
||||
set state "wait-for-break"
|
||||
continue
|
||||
}
|
||||
}
|
||||
} elseif {$state == "inside-braces"} {
|
||||
if {$next_token_type == "rightbrace"} {
|
||||
incr seen_braces -1
|
||||
if {$seen_braces == 0} {
|
||||
set state "wait-for-break"
|
||||
continue
|
||||
}
|
||||
} elseif {$next_token_type == "leftbrace"} {
|
||||
incr seen_braces 1
|
||||
}
|
||||
continue
|
||||
} elseif {$state == "after-rightbrace-preprocessor"} {
|
||||
if {$next_token_type == "newline"} {
|
||||
set state "after-rightbrace"
|
||||
}
|
||||
} elseif {$state == "after-rightbrace"} {
|
||||
if {$next_token_type == "ccomment" || $next_token_type == "space" || $next_token_type == "newline"} {
|
||||
continue
|
||||
} elseif {$next_token_type == "case"} {
|
||||
set state "case"
|
||||
continue
|
||||
} elseif {$next_token_type == "default"} {
|
||||
set state "default"
|
||||
continue
|
||||
} elseif {$next_token_type == "rightbrace"} {
|
||||
lappend switch_ends [lindex $next_token 1]
|
||||
break
|
||||
} elseif {[string first "pp_" $next_token_type] == 0} {
|
||||
set state "after-rightbrace-preprocessor"
|
||||
} else {
|
||||
report $fileName [lindex $next_token 1] "There should be 'case' or 'default' (state $state)"
|
||||
}
|
||||
} elseif {$state == "case-blocks-end-preprocessor"} {
|
||||
if {$next_token_type == "newline"} {
|
||||
set state "case-blocks-end"
|
||||
}
|
||||
} elseif {$state == "case-blocks-end"} {
|
||||
if {$next_token_type == "ccomment" || $next_token_type == "space" || $next_token_type == "newline"} {
|
||||
continue
|
||||
} elseif {$next_token_type == "rightbrace"} {
|
||||
lappend switch_ends [lindex $next_token 1]
|
||||
break
|
||||
} elseif {[string first "pp_" $next_token_type] == 0} {
|
||||
set state "case-blocks-end-preprocessor"
|
||||
} else {
|
||||
report $fileName [lindex $next_token 1] "Missing break, continue or FALLTHRU comment before rightbrace (state $state)"
|
||||
}
|
||||
} else {
|
||||
report $fileName [lindex $next_token 1] "Unknown state: $state"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
57
third_party/jerryscript/tools/vera++/scripts/rules/jerry_typecast_space_parentheses.tcl
vendored
Normal file
57
third_party/jerryscript/tools/vera++/scripts/rules/jerry_typecast_space_parentheses.tcl
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/tclsh
|
||||
|
||||
# Copyright 2016 Samsung Electronics Co., Ltd.
|
||||
# Copyright 2016 University of Szeged.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
proc check_part_of_the_file {file line_num col_start col_end} {
|
||||
if {$col_start == $col_end} {
|
||||
return
|
||||
}
|
||||
|
||||
set line [getLine $file $line_num]
|
||||
set line [string range $line $col_start $col_end]
|
||||
|
||||
if {[regexp {\)\w} $line]} {
|
||||
report $file $line_num "there should be exactly one space after right parentheses"
|
||||
}
|
||||
}
|
||||
|
||||
foreach fileName [getSourceFileNames] {
|
||||
set checkLine 1
|
||||
set checkColStart 0
|
||||
set seenOmitToken false
|
||||
foreach token [getTokens $fileName 1 0 -1 -1 {}] {
|
||||
set lineNumber [lindex $token 1]
|
||||
set colNumber [lindex $token 2]
|
||||
set tokenType [lindex $token 3]
|
||||
|
||||
if {$checkLine != $lineNumber} {
|
||||
if {!$seenOmitToken} {
|
||||
check_part_of_the_file $fileName $checkLine $checkColStart end
|
||||
}
|
||||
set checkColStart $colNumber
|
||||
set checkLine $lineNumber
|
||||
} elseif {$seenOmitToken} {
|
||||
set checkColStart $colNumber
|
||||
}
|
||||
|
||||
if {$tokenType in {ccomment cppcomment stringlit}} {
|
||||
check_part_of_the_file $fileName $checkLine $checkColStart $colNumber
|
||||
set seenOmitToken true
|
||||
} else {
|
||||
set seenOmitToken false
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user