.NAME Octal constants

.DESCRIPTION
	Octal constants (other than zero) and octal escape 
sequences (other than "\0") shall not be used. 

.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
  # Look for octal values declarations
  utilities::filterTree $tree [list [namespace current]::check]
}

proc check { node } {

	    set curOperator [::logiscope::treeOperator $node]
		set curOperatorName [::logiscope::opName $curOperator]

		# Look for integers with octal prefix
	    if {[string equal $curOperatorName integer]} {
		  set curAtom [::logiscope::treeAtomValue $node]
		  set stringToCheck [::logiscope::stringValue $curAtom]
		  if {[regexp {\A0[0-9]+.*} $stringToCheck]} {
		    ::logiscope::addViolation $node
	        return 0
		  }
		}

		# Look for characters with octal notation
	    if {[string equal $curOperatorName character]} {
		  set curAtom [::logiscope::treeAtomValue $node]
		  set stringToCheck [::logiscope::stringValue $curAtom]
		  if {![string equal $stringToCheck "'\\0'"]} {
			  if {[regexp {\\[0-7][0-7]?[0-7]?} $stringToCheck]} {
				::logiscope::addViolation $node
				return 0
			  }
		  }
		}

  return 1
}
