#This script is designed to run with Understand - CodeCheck #Robert Gempeler - July 18, 2010 use base ("Understand::Codecheck"); use strict; use constant ERR1 => 'Violation: File contains "continue" statement.'; sub register_tr_text() { my $check = shift; $check->add_tr_text(ERR1); } sub name { return "14.5 The continue statement shall not be used";} sub description { return "14.5 (Required) The continue statement shall not be used.";} sub detailed_description { return <<"END_DESC" The "continue" statement shall not be used. END_DESC } sub test_language { my $language = shift; return $language =~ /C\+\+/; #Handles C and C++ } sub test_entity { return 1;} sub test_global { return 0;} sub define_options{} sub check { my $check = shift; my $file = shift; return unless $file->kind->check("file"); return unless my $lexer = $file->lexer(); #check if lexeme text == "continue"; report error if match is found. foreach my $lexeme ($lexer->lexemes()) { if ($lexeme->text() eq "continue" && $lexeme->token() eq "Keyword"){ $check->violation($lexeme->ent(),$file,$lexeme->line_begin(),$lexeme->column_begin(),ERR1); } } }