From 6619ecb92fd2ebc06247f31223c30ee7e038900e Mon Sep 17 00:00:00 2001 From: Scott Fennell Date: Thu, 27 Sep 2018 08:10:05 -0500 Subject: [PATCH] move commented prints in FieldDescription to debug_level 4 --- .../Interface_Code_Gen/FieldDescription.cpp | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp b/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp index 7579a5ee..eaf5c59a 100644 --- a/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp +++ b/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp @@ -16,6 +16,7 @@ #include "trick/map_trick_units_to_udunits.hh" extern llvm::cl::opt< bool > units_truth_is_scary ; +extern llvm::cl::opt< int > debug_level ; static ut_system * get_u_system() { @@ -86,19 +87,17 @@ std::string FieldDescription::get_regex_field(std::string input , const char * e regmatch_t pmatch[10] ; memset(pmatch , 0 , sizeof(pmatch)) ; regcomp( ®_expr , expr , REG_EXTENDED ) ; - //std::cout << "regcomp ret = " << ret << std::endl ; ret = regexec( ®_expr , input.c_str() , 10 , pmatch , 0 ) ; - //std::cout << "regexec ret = " << ret << std::endl ; regfree(®_expr) ; if ( ret == 0 ) { - //std::cout << "pmatch range = " << pmatch[index].rm_so << " " << pmatch[index].rm_eo << std::endl ; + if(debug_level >= 4) std::cout << "pmatch range = " << pmatch[index].rm_so << " " << pmatch[index].rm_eo << std::endl ; if ( pmatch[index].rm_so != -1 ) { return input.substr(pmatch[index].rm_so , pmatch[index].rm_eo - pmatch[index].rm_so ) ; } - } else { - //char error_msg[1024] ; - //regerror( ret , ®_expr , (char *)error_msg , 1024 ) ; - //std::cerr << error_msg << std::endl ; + } else if (debug_level >= 4){ + char error_msg[1024] ; + regerror( ret , ®_expr , (char *)error_msg , 1024 ) ; + std::cerr << error_msg << std::endl ; } return std::string() ; } @@ -127,21 +126,21 @@ void FieldDescription::parseComment(std::string comment) { // remove open comment chars comment = get_regex_field(comment , "^(//|/\\*)(.*)" , 2) ; - //std::cout << "1. " << comment << std::endl ; + if(debug_level >= 4) std::cout << "1. " << comment << std::endl ; // remove optional doxygen comment chars // Note: I had to use [ \t\n\r] for \s because the Mac don't understand! comment = get_regex_field(comment , "^((\\*|!)<)?[ \t\n\r]*(.*)" , 3) ; - //std::cout << "2. " << comment << std::endl ; + if(debug_level >= 4) std::cout << "2. " << comment << std::endl ; // remove optional doxygen keyword comment = get_regex_field(comment , "(\\\\[a-zA-Z0-9]+)?[ \t\n\r]*(.*)" , 2) ; - //std::cout << "3. " << comment << std::endl ; + if(debug_level >= 4) std::cout << "3. " << comment << std::endl ; ret_str = get_regex_field(comment , "@?trick_chkpnt_io[\\({]([^\\)}]+)[\\)}]" , 1) ; if ( ! ret_str.empty()) { chkpnt_io = io_map[ret_str] ; - //std::cout << "go for trick_chkpnt_io " << io << std::endl ; + if(debug_level >= 4) std::cout << "go for trick_chkpnt_io " << io << std::endl ; chkpnt_io_found = true ; comment = get_regex_field(comment , "(.*)@?trick_chkpnt_io[\\({]([^\\)}]+)[\\)}]" , 1) + get_regex_field(comment , "@?trick_chkpnt_io[\\({]([^\\)}]+)[\\)}](.*)" , 2) ; @@ -150,7 +149,7 @@ void FieldDescription::parseComment(std::string comment) { ret_str = get_regex_field(comment , "@?trick_io[\\({]([^\\)}]+)[\\)}]" , 1) ; if ( ! ret_str.empty()) { io = io_map[ret_str] ; - //std::cout << "go for trick_io " << io << std::endl ; + if(debug_level >= 4) std::cout << "go for trick_io " << io << std::endl ; io_found = true ; comment = get_regex_field(comment , "(.*)@?trick_io[\\({]([^\\)}]+)[\\)}]" , 1) + get_regex_field(comment , "@?trick_io[\\({]([^\\)}]+)[\\)}](.*)" , 2) ; @@ -200,28 +199,28 @@ void FieldDescription::parseComment(std::string comment) { if ( ! io_found ) { // Note: I had to use [ \t\n\r] for \s because the Mac don't understand! ret_str = get_regex_field(comment , "^[ \t\n\r]*(\\*io|\\*oi|\\*i|\\*o|\\*\\*)" , 1) ; - //std::cout << "3. " << ret_str << std::endl ; + if(debug_level >= 4) std::cout << "3. " << ret_str << std::endl ; if ( ! ret_str.empty()) { io = io_map[ret_str] ; - //std::cout << "stand-alone io " << io << std::endl ; + if(debug_level >= 4) std::cout << "stand-alone io " << io << std::endl ; io_found = true ; comment = get_regex_field(comment , "^[ \t\n\r]*(\\*io|\\*oi|\\*i|\\*o|\\*\\*)[ \t\n\r]*(.*)" , 2) ; } } - //std::cout << "3. " << comment << std::endl ; + if(debug_level >= 4) std::cout << "3. " << comment << std::endl ; if ( ! units_found ) { ret_str = get_regex_field(comment , "^[ \t\n\r]*\\(([^\\)]*)\\)" , 1) ; if ( ! ret_str.empty()) { units = ret_str ; - //std::cout << "stand-alone units " << units << std::endl ; + if(debug_level >= 4) std::cout << "stand-alone units " << units << std::endl ; units_found = true ; comment = get_regex_field(comment , "^[ \t\n\r]*\\(([^\\)]*)\\)(.*)" , 2) ; } else { ret_str = get_regex_field(comment , "^[ \t\n\r]*([^ \t\n\r)]*)" , 1) ; if ( ! ret_str.empty()) { units = ret_str ; - //std::cout << "stand-alone units " << units << " " << comment << std::endl ; + if(debug_level >= 4) std::cout << "stand-alone units " << units << " " << comment << std::endl ; units_found = true ; comment = get_regex_field(comment , "^[ \t\n\r]*([^ \t\n\r)]*)(.*)" , 2) ; }