You wrote me on: Wed, 05 Oct 94 17:52:15 CDT |>> Okay here's a flame: |>> |>> Don't be a Mud IMP unless you know C. Not some C, not a little C. |>> But know enough to recognize a parse error :). |>> |>I have to agree with you on that one :) Er.. recognize what one is perhaps. Finding is sometimes another matter *groan* Some semi advice from a newbie coder.. Don't make massive changes before you compile, that way you can limit your search for errors to hopefully a few functions. Whether or not this is appropriate, it may or may not help. It's a simple C program that counts the number of braces, etc that are in a program. If you have UNIX, you can also use grep and wordcount to check grep '(' filename | wc -l and grep ')' filename | wc -l will tell you how many of each () you have. If the numbers are not the same, yer missing one somewhere perhaps :) The following program will also do the same thing. You can pipe a file to the executable and it will count the []'s , ()'s and {}'s, and tell you if the number of each is the same or different. Of course, if the parse error is caused by something else, you are on your own :P To use: brace_check < file_to_check #include <stdio.h> main() { int lbc, /* NUMBER OF LEFT BRACES */ rbc, /* NUMBER OF RIGHT BRACES */ lbr, /* NUMBER OF LEFT BRACKETS */ rbr, /* NUMBER OF RIGHT BRACKETS */ lpar, /* NUMBER OF LEFT PARENTHESES */ rpar; /* NUMBER OF RIGHT PARENTHESES */ char ch; /* INPUT CHARACTER */ /* INITIALIZE COUNTING VARIABLES */ lbc = 0; rbc = 0; lbr = 0; rbr = 0; lpar = 0; rpar = 0; while ( ( ch = getchar() ) != EOF) { if ( ch == '{' ) lbc += 1; else if ( ch == '}' ) rbc += 1; else if ( ch == '[' ) lbr += 1; else if ( ch == ']' ) rbr += 1; else if ( ch == '(' ) lpar += 1; else if ( ch == ')' ) rpar += 1; } if ( lbc == rbc ) printf ( "There are the same number of {'s and }'s\n" ); else printf ( "There are not the same number of {'s and }'s\n" ); if ( lbr == rbr ) printf ( "There are the same number of ['s and ]'s\n" ); else printf ( "There are not the same number of ['s and ]'s\n" ); if ( lpar == rpar ) printf ( "There are the same number of ('s and )'s\n" ); else printf ( "There are not the same number of ('s and )'s\n" ); }
This archive was generated by hypermail 2b30 : 12/07/00 PST