.NAME Null statement

.DESCRIPTION
Before preprocessing, a null statement shall only occur 
on a line by itself; it may be followed by a comment, 
provided that the first character following the null 
statement is a white-space character. 

.COMMENT V7.0

.SEVERITY Required

.COMMENT
Please refer to the MISRA C++:2008 document for further details (www.misra-cpp.com)

.COMMAND tcl

.CODE

::logiscope::include -once common utilities.tcl

proc compute {standardName tree} {
  variable allLines 
  variable allNodes
  set allLines {}
  set allNodes {}
  # Check all empty_stmt nodes
  utilities::filterTree $tree [list [namespace current]::check]

  if { [llength $allLines] > 0 } {
	set chan [open [::logiscope::fileFullName]]
	set lineNumber 0
	while {[gets $chan line] >= 0} {
		incr lineNumber
		set idx [lsearch $allLines $lineNumber]
		if { $idx >= 0 } {
			if { ![regexp {^\s*;($|\s//|\s/\*.*?\*/\s*$)} $line] } {
				::logiscope::addViolation [lindex $allNodes $idx]
			}
		}
	}
	close $chan	
  }
}

proc check { node } {
	variable allLines 
	variable allNodes
	if { [::utilities::isTreeOperator $node empty_stmt] } {
		lappend allLines [::logiscope::treeGetStartLine $node]
		lappend allNodes $node
	}
	return 1
}
