// CHK_PAREN.VDM - check all parentheses on C file // (c) Pauli Lindgren, 2000-10-11 // // Checks that all parentheses and /* */ comments have matching pair. // Parentheses inside comments and strings are skipped. // note: starts checking from current cursor position Statline_Message("Checking parentheses...") repeat(ALL) { search('|{//,/*,*/,",|P}',ERRBREAK) match('|{//,/*,*/,"}') #101 = Cur_Pos if (match_item == 1) { // '//' line comment line(1,ERRBREAK) continue } if (match_item == 2) { // '/*' comment #100 = 1 char(2) while (#100 > 0) { // find matching pair search("|{/*,*/}", NOERR) if (error_flag) { Goto_Pos(#101) Statline_Message("** End of comment not found! **") alert() Return } if (cur_char == '/') { #100++ } else { #100-- } char(2) } continue } if (match_item == 3) { // '*/' closing comment Statline_Message("** Start of comment not found! **") alert() Return } if (match_item == 4) { // " quote char search('|{",|N}', NOERR) if (cur_char != '"') { Goto_Pos(#101) Statline_Message("** End of string not found! **") alert() Return } char() continue } if ((cur_char == '<') || (cur_char == '>')) { char // these are not used as parentheses in C continue } Match_Paren(NOERR) // parentheses found, find match if(Error_Match) { alert() Statline_Message("** No matching parrenthesis! **") Return } Match_Paren() char() } Statline_Message(" No errors.")