.NAME Preprocessor directives

.DESCRIPTION
All #else, #elif and #endif preprocessor directives shall 
reside in the same file as the #if or #ifdef directive to 
which they are related. 

.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 CurrentParameterList
  # Check all ... nodes
  utilities::filterTree $tree [list [namespace current]::check]
}

proc check { node } {
	if { [::utilities::isTreeOperator $node errortree] } {
		set content [::utilities::treeAtomString $node]
		set lines [split $content \n"]
		set level 0
		foreach l $lines {
			set li [::utilities::suppressComments $l]
			if { [regexp -- {\#\s*if} $li] } {
				incr level
			}
			if { [regexp -- {\#\s*endif} $li] } {
				incr level -1
			}
		}
		if { $level != 0 } {
			::logiscope::addViolation $node
		}
	}	
	return 1
}
